@prosopo/procaptcha-bundle 1.0.2 → 2.0.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/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/index.d.ts +8 -8
- package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/index.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/index.js +128 -80
- package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/index.js.map +1 -1
- package/dist/bundle/Captcha-DmelpUdl.js +162 -0
- package/dist/bundle/ProcaptchaWidget-BJBQxbCd.js +783 -0
- package/dist/bundle/index-jr-ls0GZ.js +15023 -0
- package/dist/bundle/index.d.ts +8 -8
- package/dist/bundle/index.d.ts.map +1 -1
- package/dist/bundle/procaptcha.bundle.js +2 -2
- package/dist/bundle/utils-CHbJaqXT.js +12251 -0
- package/dist/cjs/index.cjs +81 -23
- package/dist/index.d.ts +8 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +128 -80
- package/dist/index.js.map +1 -1
- package/package.json +57 -66
- package/stats.html +1 -1
- package/vite.cjs.config.ts +7 -3
- package/vite.config.ts +39 -37
- package/webpack.config.cjs +42 -0
- package/dist/bundle/Captcha-VFcjC-TM.js +0 -119
- package/dist/bundle/ProcaptchaWidget-YCG6trDR.js +0 -906
- package/dist/bundle/index-Bvarorfv.js +0 -11607
- package/dist/bundle/utils-o59wPRMZ.js +0 -35879
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { Features, ProcaptchaToken } from
|
|
1
|
+
import { type Features, type ProcaptchaToken } from "@prosopo/types";
|
|
2
2
|
interface ProcaptchaRenderOptions {
|
|
3
3
|
siteKey: string;
|
|
4
|
-
theme?:
|
|
4
|
+
theme?: "light" | "dark";
|
|
5
5
|
captchaType?: Features;
|
|
6
6
|
callback?: string | ((token: ProcaptchaToken) => void);
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
"challenge-valid-length"?: string;
|
|
8
|
+
"chalexpired-callback"?: string | (() => void);
|
|
9
|
+
"expired-callback"?: string | (() => void);
|
|
10
|
+
"open-callback"?: string | (() => void);
|
|
11
|
+
"close-callback"?: string | (() => void);
|
|
12
|
+
"error-callback"?: string | (() => void);
|
|
13
13
|
}
|
|
14
14
|
export declare const render: (element: Element, renderOptions: ProcaptchaRenderOptions) => void;
|
|
15
15
|
export default function ready(fn: () => void): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAGL,KAAK,QAAQ,EAMb,KAAK,eAAe,EACrB,MAAM,gBAAgB,CAAC;AAIxB,UAAU,uBAAuB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,QAAQ,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC,CAAC;IACvD,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,sBAAsB,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;IAC/C,kBAAkB,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;IAC3C,eAAe,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;IACxC,gBAAgB,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;IACzC,gBAAgB,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;CAC1C;AAoUD,eAAO,MAAM,MAAM,YACR,OAAO,iBACD,uBAAuB,SAKvC,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAAE,EAAE,MAAM,IAAI,QAQ3C;AAGD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,UAAU,EAAE;YAAE,KAAK,EAAE,OAAO,KAAK,CAAC;YAAC,MAAM,EAAE,OAAO,MAAM,CAAA;SAAE,CAAC;KAC5D;CACF"}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { at } from
|
|
7
|
-
import { createRoot } from
|
|
8
|
-
const BUNDLE_NAME =
|
|
2
|
+
import { ProcaptchaFrictionless } from "@prosopo/procaptcha-frictionless";
|
|
3
|
+
import { ProcaptchaPow } from "@prosopo/procaptcha-pow";
|
|
4
|
+
import { Procaptcha } from "@prosopo/procaptcha-react";
|
|
5
|
+
import { ApiParams, EnvironmentTypesSchema, FeaturesEnum, NetworkNamesSchema, ProcaptchaConfigSchema, } from "@prosopo/types";
|
|
6
|
+
import { at } from "@prosopo/util";
|
|
7
|
+
import { createRoot } from "react-dom/client";
|
|
8
|
+
const BUNDLE_NAME = "procaptcha.bundle.js";
|
|
9
9
|
const getProcaptchaScript = () => document.querySelector(`script[src*="${BUNDLE_NAME}"]`);
|
|
10
10
|
const extractParams = (name) => {
|
|
11
11
|
const script = getProcaptchaScript();
|
|
12
12
|
if (script && script.src.indexOf(`${name}`) !== -1) {
|
|
13
|
-
const params = new URLSearchParams(script.src.split(
|
|
13
|
+
const params = new URLSearchParams(script.src.split("?")[1]);
|
|
14
14
|
return {
|
|
15
|
-
onloadUrlCallback: params.get(
|
|
16
|
-
renderExplicit: params.get(
|
|
15
|
+
onloadUrlCallback: params.get("onload") || undefined,
|
|
16
|
+
renderExplicit: params.get("render") || undefined,
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
return { onloadUrlCallback: undefined, renderExplicit: undefined };
|
|
20
20
|
};
|
|
21
21
|
const getConfig = (siteKey) => {
|
|
22
22
|
if (!siteKey) {
|
|
23
|
-
siteKey = process.env.PROSOPO_SITE_KEY ||
|
|
23
|
+
siteKey = process.env.PROSOPO_SITE_KEY || "";
|
|
24
24
|
}
|
|
25
25
|
return ProcaptchaConfigSchema.parse({
|
|
26
26
|
defaultEnvironment: process.env.PROSOPO_DEFAULT_ENVIRONMENT
|
|
@@ -29,160 +29,208 @@ const getConfig = (siteKey) => {
|
|
|
29
29
|
defaultNetwork: process.env.PROSOPO_DEFAULT_NETWORK
|
|
30
30
|
? NetworkNamesSchema.parse(process.env.PROSOPO_DEFAULT_NETWORK)
|
|
31
31
|
: NetworkNamesSchema.enum.development,
|
|
32
|
-
userAccountAddress:
|
|
32
|
+
userAccountAddress: "",
|
|
33
33
|
account: {
|
|
34
34
|
address: siteKey,
|
|
35
35
|
},
|
|
36
|
-
serverUrl: process.env.PROSOPO_SERVER_URL ||
|
|
37
|
-
mongoAtlasUri: process.env.PROSOPO_MONGO_EVENTS_URI ||
|
|
38
|
-
devOnlyWatchEvents: process.env._DEV_ONLY_WATCH_EVENTS ===
|
|
36
|
+
serverUrl: process.env.PROSOPO_SERVER_URL || "",
|
|
37
|
+
mongoAtlasUri: process.env.PROSOPO_MONGO_EVENTS_URI || "",
|
|
38
|
+
devOnlyWatchEvents: process.env._DEV_ONLY_WATCH_EVENTS === "true" || false,
|
|
39
39
|
});
|
|
40
40
|
};
|
|
41
|
-
const getParentForm = (element) => element.closest(
|
|
41
|
+
const getParentForm = (element) => element.closest("form");
|
|
42
42
|
const getWindowCallback = (callbackName) => {
|
|
43
|
-
const fn = window[callbackName.replace(
|
|
44
|
-
if (typeof fn !==
|
|
43
|
+
const fn = window[callbackName.replace("window.", "")];
|
|
44
|
+
if (typeof fn !== "function") {
|
|
45
45
|
throw new Error(`Callback ${callbackName} is not defined on the window object`);
|
|
46
46
|
}
|
|
47
47
|
return fn;
|
|
48
48
|
};
|
|
49
49
|
const handleOnHuman = (element, token) => {
|
|
50
|
+
removeProcaptchaResponse();
|
|
50
51
|
const form = getParentForm(element);
|
|
51
52
|
if (!form) {
|
|
52
|
-
console.error(
|
|
53
|
+
console.error("Parent form not found for the element:", element);
|
|
53
54
|
return;
|
|
54
55
|
}
|
|
55
|
-
const input = document.createElement(
|
|
56
|
-
input.type =
|
|
56
|
+
const input = document.createElement("input");
|
|
57
|
+
input.type = "hidden";
|
|
57
58
|
input.name = ApiParams.procaptchaResponse;
|
|
58
59
|
input.value = token;
|
|
59
60
|
form.appendChild(input);
|
|
60
61
|
};
|
|
61
|
-
const customThemeSet = new Set([
|
|
62
|
-
const validateTheme = (themeAttribute) => customThemeSet.has(themeAttribute)
|
|
62
|
+
const customThemeSet = new Set(["light", "dark"]);
|
|
63
|
+
const validateTheme = (themeAttribute) => customThemeSet.has(themeAttribute)
|
|
64
|
+
? themeAttribute
|
|
65
|
+
: "light";
|
|
63
66
|
const setValidChallengeLength = (renderOptions, element, config) => {
|
|
64
|
-
const challengeValidLengthAttribute = renderOptions?.[
|
|
67
|
+
const challengeValidLengthAttribute = renderOptions?.["challenge-valid-length"] ||
|
|
68
|
+
element.getAttribute("data-challenge-valid-length");
|
|
65
69
|
if (challengeValidLengthAttribute) {
|
|
66
|
-
config.captchas.image.solutionTimeout = parseInt(challengeValidLengthAttribute);
|
|
67
|
-
config.captchas.pow.solutionTimeout = parseInt(challengeValidLengthAttribute);
|
|
70
|
+
config.captchas.image.solutionTimeout = Number.parseInt(challengeValidLengthAttribute);
|
|
71
|
+
config.captchas.pow.solutionTimeout = Number.parseInt(challengeValidLengthAttribute);
|
|
68
72
|
}
|
|
69
73
|
};
|
|
74
|
+
const removeProcaptchaResponse = () => {
|
|
75
|
+
const element = Array.from(document.getElementsByName(ApiParams.procaptchaResponse));
|
|
76
|
+
element.map((el) => el.remove());
|
|
77
|
+
};
|
|
70
78
|
const getDefaultCallbacks = (element) => ({
|
|
71
79
|
onHuman: (token) => handleOnHuman(element, token),
|
|
72
80
|
onChallengeExpired: () => {
|
|
73
|
-
|
|
81
|
+
removeProcaptchaResponse();
|
|
82
|
+
console.log("Challenge expired");
|
|
74
83
|
},
|
|
75
84
|
onExpired: () => {
|
|
76
|
-
|
|
85
|
+
removeProcaptchaResponse();
|
|
86
|
+
alert("Completed challenge has expired, please try again");
|
|
77
87
|
},
|
|
78
88
|
onError: (error) => {
|
|
89
|
+
removeProcaptchaResponse();
|
|
79
90
|
console.error(error);
|
|
80
91
|
},
|
|
81
92
|
onClose: () => {
|
|
82
|
-
console.log(
|
|
93
|
+
console.log("Challenge closed");
|
|
83
94
|
},
|
|
84
95
|
onOpen: () => {
|
|
85
|
-
console.log(
|
|
96
|
+
console.log("Challenge opened");
|
|
86
97
|
},
|
|
87
98
|
});
|
|
88
99
|
const setTheme = (renderOptions, element, config) => {
|
|
89
|
-
const themeAttribute = renderOptions?.theme || element.getAttribute(
|
|
100
|
+
const themeAttribute = renderOptions?.theme || element.getAttribute("data-theme") || "light";
|
|
90
101
|
config.theme = validateTheme(themeAttribute);
|
|
91
102
|
};
|
|
92
103
|
function setUserCallbacks(renderOptions, callbacks, element) {
|
|
93
|
-
if (typeof renderOptions?.callback ===
|
|
94
|
-
|
|
104
|
+
if (typeof renderOptions?.callback === "function") {
|
|
105
|
+
const fn = renderOptions.callback;
|
|
106
|
+
callbacks.onHuman = (token) => {
|
|
107
|
+
handleOnHuman(element, token);
|
|
108
|
+
fn(token);
|
|
109
|
+
};
|
|
95
110
|
}
|
|
96
111
|
else {
|
|
97
|
-
const callbackName = typeof renderOptions?.callback ===
|
|
112
|
+
const callbackName = typeof renderOptions?.callback === "string"
|
|
98
113
|
? renderOptions?.callback
|
|
99
|
-
: element.getAttribute(
|
|
114
|
+
: element.getAttribute("data-callback");
|
|
100
115
|
if (callbackName)
|
|
101
|
-
callbacks.onHuman =
|
|
116
|
+
callbacks.onHuman = (token) => {
|
|
117
|
+
handleOnHuman(element, token);
|
|
118
|
+
const fn = getWindowCallback(callbackName);
|
|
119
|
+
fn(token);
|
|
120
|
+
};
|
|
102
121
|
}
|
|
103
|
-
if (
|
|
104
|
-
|
|
122
|
+
if (renderOptions &&
|
|
123
|
+
renderOptions["chalexpired-callback"] &&
|
|
124
|
+
typeof renderOptions["chalexpired-callback"] === "function") {
|
|
125
|
+
const fn = renderOptions["chalexpired-callback"];
|
|
126
|
+
callbacks.onChallengeExpired = () => {
|
|
127
|
+
removeProcaptchaResponse();
|
|
128
|
+
fn();
|
|
129
|
+
};
|
|
105
130
|
}
|
|
106
131
|
else {
|
|
107
|
-
const chalExpiredCallbackName = typeof renderOptions?.[
|
|
108
|
-
? renderOptions?.[
|
|
109
|
-
: element.getAttribute(
|
|
132
|
+
const chalExpiredCallbackName = typeof renderOptions?.["chalexpired-callback"] === "string"
|
|
133
|
+
? renderOptions?.["chalexpired-callback"]
|
|
134
|
+
: element.getAttribute("data-chalexpired-callback");
|
|
110
135
|
if (chalExpiredCallbackName)
|
|
111
|
-
callbacks.onChallengeExpired =
|
|
136
|
+
callbacks.onChallengeExpired = () => {
|
|
137
|
+
const fn = getWindowCallback(chalExpiredCallbackName);
|
|
138
|
+
removeProcaptchaResponse();
|
|
139
|
+
fn();
|
|
140
|
+
};
|
|
112
141
|
}
|
|
113
|
-
if (
|
|
114
|
-
|
|
142
|
+
if (renderOptions &&
|
|
143
|
+
renderOptions["expired-callback"] &&
|
|
144
|
+
typeof renderOptions["expired-callback"] === "function") {
|
|
145
|
+
const fn = renderOptions["expired-callback"];
|
|
146
|
+
callbacks.onExpired = () => {
|
|
147
|
+
removeProcaptchaResponse();
|
|
148
|
+
fn();
|
|
149
|
+
};
|
|
115
150
|
}
|
|
116
151
|
else {
|
|
117
|
-
const onExpiredCallbackName = typeof renderOptions?.[
|
|
118
|
-
? renderOptions?.[
|
|
119
|
-
: element.getAttribute(
|
|
152
|
+
const onExpiredCallbackName = typeof renderOptions?.["expired-callback"] === "string"
|
|
153
|
+
? renderOptions?.["expired-callback"]
|
|
154
|
+
: element.getAttribute("data-expired-callback");
|
|
120
155
|
if (onExpiredCallbackName)
|
|
121
|
-
callbacks.onExpired =
|
|
156
|
+
callbacks.onExpired = () => {
|
|
157
|
+
const fn = getWindowCallback(onExpiredCallbackName);
|
|
158
|
+
removeProcaptchaResponse();
|
|
159
|
+
fn();
|
|
160
|
+
};
|
|
122
161
|
}
|
|
123
|
-
if (
|
|
124
|
-
|
|
162
|
+
if (renderOptions &&
|
|
163
|
+
renderOptions?.["error-callback"] &&
|
|
164
|
+
typeof renderOptions["error-callback"] === "function") {
|
|
165
|
+
const fn = renderOptions["error-callback"];
|
|
166
|
+
callbacks.onError = () => {
|
|
167
|
+
removeProcaptchaResponse();
|
|
168
|
+
fn();
|
|
169
|
+
};
|
|
125
170
|
}
|
|
126
171
|
else {
|
|
127
|
-
const errorCallbackName = typeof renderOptions?.[
|
|
128
|
-
? renderOptions?.[
|
|
129
|
-
: element.getAttribute(
|
|
172
|
+
const errorCallbackName = typeof renderOptions?.["error-callback"] === "string"
|
|
173
|
+
? renderOptions?.["error-callback"]
|
|
174
|
+
: element.getAttribute("data-error-callback");
|
|
130
175
|
if (errorCallbackName)
|
|
131
|
-
callbacks.onError =
|
|
176
|
+
callbacks.onError = () => {
|
|
177
|
+
const fn = getWindowCallback(errorCallbackName);
|
|
178
|
+
removeProcaptchaResponse();
|
|
179
|
+
fn();
|
|
180
|
+
};
|
|
132
181
|
}
|
|
133
|
-
if (typeof renderOptions?.[
|
|
134
|
-
callbacks.onClose = renderOptions[
|
|
182
|
+
if (typeof renderOptions?.["close-callback"] === "function") {
|
|
183
|
+
callbacks.onClose = renderOptions["close-callback"];
|
|
135
184
|
}
|
|
136
185
|
else {
|
|
137
|
-
const onCloseCallbackName = typeof renderOptions?.[
|
|
138
|
-
? renderOptions?.[
|
|
139
|
-
: element.getAttribute(
|
|
186
|
+
const onCloseCallbackName = typeof renderOptions?.["close-callback"] === "string"
|
|
187
|
+
? renderOptions?.["close-callback"]
|
|
188
|
+
: element.getAttribute("data-close-callback");
|
|
140
189
|
if (onCloseCallbackName)
|
|
141
190
|
callbacks.onClose = getWindowCallback(onCloseCallbackName);
|
|
142
191
|
}
|
|
143
|
-
if (renderOptions?.[
|
|
144
|
-
if (typeof renderOptions[
|
|
145
|
-
callbacks.onOpen = renderOptions[
|
|
192
|
+
if (renderOptions?.["open-callback"]) {
|
|
193
|
+
if (typeof renderOptions["open-callback"] === "function") {
|
|
194
|
+
callbacks.onOpen = renderOptions["open-callback"];
|
|
146
195
|
}
|
|
147
196
|
else {
|
|
148
|
-
const onOpenCallbackName = typeof renderOptions?.[
|
|
149
|
-
? renderOptions?.[
|
|
150
|
-
: element.getAttribute(
|
|
197
|
+
const onOpenCallbackName = typeof renderOptions?.["open-callback"] === "string"
|
|
198
|
+
? renderOptions?.["open-callback"]
|
|
199
|
+
: element.getAttribute("data-open-callback");
|
|
151
200
|
if (onOpenCallbackName)
|
|
152
201
|
callbacks.onOpen = getWindowCallback(onOpenCallbackName);
|
|
153
202
|
}
|
|
154
203
|
}
|
|
155
204
|
}
|
|
156
205
|
const renderLogic = (elements, config, renderOptions) => {
|
|
157
|
-
|
|
206
|
+
for (const element of elements) {
|
|
158
207
|
const callbacks = getDefaultCallbacks(element);
|
|
159
208
|
setUserCallbacks(renderOptions, callbacks, element);
|
|
160
209
|
setTheme(renderOptions, element, config);
|
|
161
210
|
setValidChallengeLength(renderOptions, element, config);
|
|
162
211
|
switch (renderOptions?.captchaType) {
|
|
163
|
-
case
|
|
212
|
+
case "pow":
|
|
164
213
|
createRoot(element).render(_jsx(ProcaptchaPow, { config: config, callbacks: callbacks }));
|
|
165
214
|
break;
|
|
166
|
-
case
|
|
215
|
+
case "frictionless":
|
|
167
216
|
createRoot(element).render(_jsx(ProcaptchaFrictionless, { config: config, callbacks: callbacks }));
|
|
168
217
|
break;
|
|
169
218
|
default:
|
|
170
219
|
createRoot(element).render(_jsx(Procaptcha, { config: config, callbacks: callbacks }));
|
|
171
220
|
break;
|
|
172
221
|
}
|
|
173
|
-
}
|
|
222
|
+
}
|
|
174
223
|
};
|
|
175
224
|
const implicitRender = () => {
|
|
176
|
-
const elements = Array.from(document.getElementsByClassName(
|
|
225
|
+
const elements = Array.from(document.getElementsByClassName("procaptcha"));
|
|
177
226
|
if (elements.length) {
|
|
178
|
-
const siteKey = at(elements, 0).getAttribute(
|
|
227
|
+
const siteKey = at(elements, 0).getAttribute("data-sitekey");
|
|
179
228
|
if (!siteKey) {
|
|
180
|
-
console.error(
|
|
229
|
+
console.error("No siteKey found");
|
|
181
230
|
return;
|
|
182
231
|
}
|
|
183
232
|
const features = Object.values(FeaturesEnum);
|
|
184
|
-
const captchaType = features.find((feature) => feature === at(elements, 0).getAttribute(
|
|
185
|
-
'frictionless';
|
|
233
|
+
const captchaType = features.find((feature) => feature === at(elements, 0).getAttribute("data-captcha-type")) || "frictionless";
|
|
186
234
|
renderLogic(elements, getConfig(siteKey), { captchaType, siteKey });
|
|
187
235
|
}
|
|
188
236
|
};
|
|
@@ -191,23 +239,23 @@ export const render = (element, renderOptions) => {
|
|
|
191
239
|
renderLogic([element], getConfig(siteKey), renderOptions);
|
|
192
240
|
};
|
|
193
241
|
export default function ready(fn) {
|
|
194
|
-
if (document && document.readyState !==
|
|
195
|
-
console.log(
|
|
242
|
+
if (document && document.readyState !== "loading") {
|
|
243
|
+
console.log("document.readyState ready!");
|
|
196
244
|
fn();
|
|
197
245
|
}
|
|
198
246
|
else {
|
|
199
|
-
console.log(
|
|
200
|
-
document.addEventListener(
|
|
247
|
+
console.log("DOMContentLoaded listener!");
|
|
248
|
+
document.addEventListener("DOMContentLoaded", fn);
|
|
201
249
|
}
|
|
202
250
|
}
|
|
203
251
|
window.procaptcha = { ready, render };
|
|
204
252
|
const { onloadUrlCallback, renderExplicit } = extractParams(BUNDLE_NAME);
|
|
205
|
-
if (renderExplicit !==
|
|
253
|
+
if (renderExplicit !== "explicit") {
|
|
206
254
|
ready(implicitRender);
|
|
207
255
|
}
|
|
208
256
|
if (onloadUrlCallback) {
|
|
209
257
|
const onloadCallback = getWindowCallback(onloadUrlCallback);
|
|
210
|
-
getProcaptchaScript()?.addEventListener(
|
|
258
|
+
getProcaptchaScript()?.addEventListener("load", () => {
|
|
211
259
|
ready(onloadCallback);
|
|
212
260
|
});
|
|
213
261
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAcvD,OAAO,EACL,SAAS,EACT,sBAAsB,EAEtB,YAAY,EACZ,kBAAkB,EAGlB,sBAAsB,GAEvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAe9C,MAAM,WAAW,GAAG,sBAAsB,CAAC;AAE3C,MAAM,mBAAmB,GAAG,GAAG,EAAE,CAC/B,QAAQ,CAAC,aAAa,CAAoB,gBAAgB,WAAW,IAAI,CAAC,CAAC;AAE7E,MAAM,aAAa,GAAG,CAAC,IAAY,EAAE,EAAE;IACrC,MAAM,MAAM,GAAG,mBAAmB,EAAE,CAAC;IACrC,IAAI,MAAM,IAAI,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE;QAClD,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,GAAG,CAA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E,CAAC,CAAC;KACnD;AACH,CAAC;AAUD,MAAM,CAAC,UAAU,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAItC,MAAM,EAAE,iBAAiB,EAAE,cAAc,EAAE,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;AAGzE,IAAI,cAAc,KAAK,UAAU,EAAE;IACjC,KAAK,CAAC,cAAc,CAAC,CAAC;CACvB;AAED,IAAI,iBAAiB,EAAE;IACrB,MAAM,cAAc,GAAG,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IAE5D,mBAAmB,EAAE,EAAE,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE;QACnD,KAAK,CAAC,cAAc,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;CACJ"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { A as o, e as G, a as H, P as L, r as v, j as n, C as U, W as j, b as D, c as M, f as B, g as F, h as K, i as V, L as X, k as Y, m as $, n as q, l as z, d as J } from "./index-jr-ls0GZ.js";
|
|
2
|
+
import { v as Q, k as _, E as Z, p as ee, n as te, f as w, o as ne, s as oe, q as ae, l as k, t as re, C as se } from "./utils-CHbJaqXT.js";
|
|
3
|
+
const ce = (s, e) => {
|
|
4
|
+
let r = 0;
|
|
5
|
+
const d = "0".repeat(e);
|
|
6
|
+
for (; ; ) {
|
|
7
|
+
const p = new TextEncoder().encode(r + s);
|
|
8
|
+
if (ie(Q(p)).startsWith(d))
|
|
9
|
+
return r;
|
|
10
|
+
r += 1;
|
|
11
|
+
}
|
|
12
|
+
}, ie = (s) => Array.from(s).map((e) => e.toString(16).padStart(2, "0")).join(""), le = (s, e, r, d) => {
|
|
13
|
+
const p = _(r, e, d), u = () => ({
|
|
14
|
+
showModal: !1,
|
|
15
|
+
loading: !1,
|
|
16
|
+
index: 0,
|
|
17
|
+
challenge: void 0,
|
|
18
|
+
solutions: void 0,
|
|
19
|
+
isHuman: !1,
|
|
20
|
+
captchaApi: void 0,
|
|
21
|
+
account: void 0
|
|
22
|
+
}), b = () => {
|
|
23
|
+
window.clearTimeout(e.timeout), a({ timeout: void 0 });
|
|
24
|
+
}, T = () => {
|
|
25
|
+
window.clearTimeout(e.successfullChallengeTimeout), a({ successfullChallengeTimeout: void 0 });
|
|
26
|
+
}, i = () => {
|
|
27
|
+
const t = {
|
|
28
|
+
userAccountAddress: "",
|
|
29
|
+
...s
|
|
30
|
+
};
|
|
31
|
+
return e.account && (t.userAccountAddress = e.account.account.address), L.parse(t);
|
|
32
|
+
}, E = (t) => {
|
|
33
|
+
const c = t.networks[t.defaultNetwork];
|
|
34
|
+
if (!c)
|
|
35
|
+
throw new w("DEVELOPER.NETWORK_NOT_FOUND", {
|
|
36
|
+
context: {
|
|
37
|
+
error: `No network found for environment ${t.defaultEnvironment}`
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
return c;
|
|
41
|
+
}, g = () => {
|
|
42
|
+
if (!e.account)
|
|
43
|
+
throw new w("GENERAL.ACCOUNT_NOT_FOUND", {
|
|
44
|
+
context: { error: "Account not loaded" }
|
|
45
|
+
});
|
|
46
|
+
return { account: e.account };
|
|
47
|
+
}, l = () => {
|
|
48
|
+
if (!e.dappAccount)
|
|
49
|
+
throw new w("GENERAL.SITE_KEY_MISSING");
|
|
50
|
+
return e.dappAccount;
|
|
51
|
+
}, a = k(e, r), I = () => {
|
|
52
|
+
b(), T(), a(u());
|
|
53
|
+
}, P = () => {
|
|
54
|
+
const t = i().captchas.pow.solutionTimeout, c = setTimeout(() => {
|
|
55
|
+
a({ isHuman: !1 }), p.onExpired();
|
|
56
|
+
}, t);
|
|
57
|
+
a({ successfullChallengeTimeout: c });
|
|
58
|
+
}, W = async () => {
|
|
59
|
+
var y;
|
|
60
|
+
if (e.loading || e.isHuman)
|
|
61
|
+
return;
|
|
62
|
+
I(), a({
|
|
63
|
+
loading: !0
|
|
64
|
+
});
|
|
65
|
+
const t = i(), c = t.web2 ? new Z() : new ee(), h = t.userAccountAddress || (await c.getAccount(t)).account.address;
|
|
66
|
+
if (a({
|
|
67
|
+
account: { account: { address: h } }
|
|
68
|
+
}), a({ dappAccount: t.account.address }), await te(100), !t.web2 && !t.userAccountAddress)
|
|
69
|
+
throw new w("GENERAL.ACCOUNT_NOT_FOUND", {
|
|
70
|
+
context: { error: "Account address has not been set for web3 mode" }
|
|
71
|
+
});
|
|
72
|
+
const f = O(), x = _(r, e, d), A = f.provider.url, N = new ne(E(i()), A, l()), m = await N.getPowCaptchaChallenge(h, l()), R = ce(m.challenge, m.difficulty), C = (y = (await c.getAccount(i())).extension) == null ? void 0 : y.signer;
|
|
73
|
+
if (!C || !C.signRaw)
|
|
74
|
+
throw new w("GENERAL.CANT_FIND_KEYRINGPAIR", {
|
|
75
|
+
context: {
|
|
76
|
+
error: "Signer is not defined, cannot sign message to prove account ownership"
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
const S = await C.signRaw({
|
|
80
|
+
address: h,
|
|
81
|
+
data: oe(m[o.timestamp].toString()),
|
|
82
|
+
type: "bytes"
|
|
83
|
+
});
|
|
84
|
+
(await N.submitPowCaptchaSolution(m, g().account.account.address, l(), R, S.signature.toString(), t.captchas.pow.verifiedTimeout))[o.verified] && (a({
|
|
85
|
+
isHuman: !0,
|
|
86
|
+
loading: !1
|
|
87
|
+
}), x.onHuman(G({
|
|
88
|
+
[o.providerUrl]: A,
|
|
89
|
+
[o.user]: g().account.account.address,
|
|
90
|
+
[o.dapp]: l(),
|
|
91
|
+
[o.challenge]: m.challenge,
|
|
92
|
+
[o.blockNumber]: f.blockNumber,
|
|
93
|
+
[o.nonce]: R,
|
|
94
|
+
[o.timestamp]: m.timestamp,
|
|
95
|
+
[o.signature]: {
|
|
96
|
+
[o.provider]: m.signature.provider,
|
|
97
|
+
[o.user]: {
|
|
98
|
+
[o.timestamp]: S.signature.toString()
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
})), P());
|
|
102
|
+
}, O = () => {
|
|
103
|
+
const t = (x, A) => Math.floor(Math.random() * (A - x + 1) + x), c = i().defaultEnvironment, h = ae(c), f = H(h, t(0, h.length - 1));
|
|
104
|
+
return {
|
|
105
|
+
providerAccount: f.address,
|
|
106
|
+
provider: {
|
|
107
|
+
url: f.url,
|
|
108
|
+
datasetId: f.datasetId,
|
|
109
|
+
datasetIdContent: f.datasetIdContent
|
|
110
|
+
},
|
|
111
|
+
blockNumber: 0
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
return {
|
|
115
|
+
start: W,
|
|
116
|
+
resetState: I
|
|
117
|
+
};
|
|
118
|
+
}, he = (s) => {
|
|
119
|
+
const e = s.config, r = e.theme === "light" ? "light" : "dark", d = s.config.theme === "light" ? z : J, p = s.callbacks || {}, [u, b] = re(v.useState, v.useRef), T = k(u, b), i = v.useRef(le(e, u, T, p)), E = v.useRef(null);
|
|
120
|
+
return v.useEffect(() => {
|
|
121
|
+
const g = E.current;
|
|
122
|
+
if (!g)
|
|
123
|
+
return;
|
|
124
|
+
const l = g.closest("form");
|
|
125
|
+
if (!l)
|
|
126
|
+
return;
|
|
127
|
+
const a = () => {
|
|
128
|
+
i.current.resetState();
|
|
129
|
+
};
|
|
130
|
+
return l.addEventListener("submit", a), () => {
|
|
131
|
+
l.removeEventListener("submit", a);
|
|
132
|
+
};
|
|
133
|
+
}, []), n("div", { ref: E, children: n("div", { style: { maxWidth: "100%", maxHeight: "100%", overflowX: "auto" }, children: n(U, { children: n(j, { children: D("div", { style: M, "data-cy": "button-human", children: [" ", D("div", { style: {
|
|
134
|
+
padding: B,
|
|
135
|
+
border: F,
|
|
136
|
+
backgroundColor: d.palette.background.default,
|
|
137
|
+
borderColor: d.palette.grey[300],
|
|
138
|
+
borderRadius: K,
|
|
139
|
+
display: "flex",
|
|
140
|
+
alignItems: "center",
|
|
141
|
+
flexWrap: "wrap",
|
|
142
|
+
justifyContent: "space-between",
|
|
143
|
+
minHeight: `${V}px`,
|
|
144
|
+
overflow: "hidden"
|
|
145
|
+
}, children: [n("div", { style: { display: "inline-flex", flexDirection: "column" }, children: n("div", { style: {
|
|
146
|
+
display: "flex",
|
|
147
|
+
justifyContent: "flex-start",
|
|
148
|
+
alignItems: "center",
|
|
149
|
+
flexWrap: "wrap"
|
|
150
|
+
}, children: n("div", { style: {
|
|
151
|
+
display: "flex",
|
|
152
|
+
alignItems: "center",
|
|
153
|
+
justifyContent: "center",
|
|
154
|
+
flexDirection: "column",
|
|
155
|
+
verticalAlign: "middle"
|
|
156
|
+
}, children: n("div", { style: {
|
|
157
|
+
display: "flex"
|
|
158
|
+
}, children: n("div", { style: { flex: 1 }, children: u.loading ? n(X, { themeColor: r, "aria-label": "Loading spinner" }) : n(se, { checked: u.isHuman, onChange: i.current.start, themeColor: r, labelText: "I am human", "aria-label": "human checkbox" }) }) }) }) }) }), n("div", { style: { display: "inline-flex", flexDirection: "column" }, children: n("a", { href: Y, target: "_blank", "aria-label": $, rel: "noreferrer", children: n("div", { style: { flex: 1 }, children: n(q, { themeColor: r, "aria-label": "Prosopo logo" }) }) }) })] })] }) }) }) }) });
|
|
159
|
+
};
|
|
160
|
+
export {
|
|
161
|
+
he as default
|
|
162
|
+
};
|