@prosopo/procaptcha-frictionless 2.12.21 → 2.12.23

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.
@@ -1,143 +1,108 @@
1
- "use strict";
2
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const api = require("@prosopo/api");
4
- const common = require("@prosopo/common");
5
- const procaptchaCommon = require("@prosopo/procaptcha-common");
6
- const detectorLoader = require("./detectorLoader.cjs");
7
- const sanitiseHref = (href) => {
8
- try {
9
- const u = new URL(href);
10
- if (!u.origin || u.origin === "null") return void 0;
11
- return `${u.origin}${u.pathname || ""}`;
12
- } catch {
13
- return void 0;
14
- }
1
+ const require_detectorLoader = require("./detectorLoader.cjs");
2
+ let _prosopo_procaptcha_common = require("@prosopo/procaptcha-common");
3
+ let _prosopo_api = require("@prosopo/api");
4
+ let _prosopo_common = require("@prosopo/common");
5
+ //#region src/customDetectBot.ts
6
+ var sanitiseHref = (href) => {
7
+ try {
8
+ const u = new URL(href);
9
+ if (!u.origin || u.origin === "null") return void 0;
10
+ return `${u.origin}${u.pathname || ""}`;
11
+ } catch {
12
+ return;
13
+ }
15
14
  };
16
- const getCurrentPageUrls = () => {
17
- if (typeof window === "undefined" || !window.location) {
18
- return { currentUrl: void 0, iframeUrl: void 0 };
19
- }
20
- const local = (() => {
21
- const { origin, pathname } = window.location;
22
- if (!origin || origin === "null") return void 0;
23
- return `${origin}${pathname || ""}`;
24
- })();
25
- if (window === window.top) {
26
- return { currentUrl: local, iframeUrl: void 0 };
27
- }
28
- try {
29
- const topHref = window.top?.location?.href;
30
- const sanitised = topHref ? sanitiseHref(topHref) : void 0;
31
- if (sanitised) return { currentUrl: sanitised, iframeUrl: local };
32
- } catch {
33
- }
34
- if (typeof document !== "undefined" && document.referrer) {
35
- const fromReferrer = sanitiseHref(document.referrer);
36
- if (fromReferrer) return { currentUrl: fromReferrer, iframeUrl: local };
37
- }
38
- return { currentUrl: local, iframeUrl: local };
15
+ var getCurrentPageUrls = () => {
16
+ if (typeof window === "undefined" || !window.location) return {
17
+ currentUrl: void 0,
18
+ iframeUrl: void 0
19
+ };
20
+ const local = (() => {
21
+ const { origin, pathname } = window.location;
22
+ if (!origin || origin === "null") return void 0;
23
+ return `${origin}${pathname || ""}`;
24
+ })();
25
+ if (window === window.top) return {
26
+ currentUrl: local,
27
+ iframeUrl: void 0
28
+ };
29
+ try {
30
+ const topHref = window.top?.location?.href;
31
+ const sanitised = topHref ? sanitiseHref(topHref) : void 0;
32
+ if (sanitised) return {
33
+ currentUrl: sanitised,
34
+ iframeUrl: local
35
+ };
36
+ } catch {}
37
+ if (typeof document !== "undefined" && document.referrer) {
38
+ const fromReferrer = sanitiseHref(document.referrer);
39
+ if (fromReferrer) return {
40
+ currentUrl: fromReferrer,
41
+ iframeUrl: local
42
+ };
43
+ }
44
+ return {
45
+ currentUrl: local,
46
+ iframeUrl: local
47
+ };
39
48
  };
40
- const withTimeout = async (promise, ms) => {
41
- let timeoutId;
42
- const timeoutPromise = new Promise((_, reject) => {
43
- timeoutId = setTimeout(() => {
44
- reject(new common.ProsopoEnvError("API.UNKNOWN"));
45
- }, ms);
46
- });
47
- try {
48
- const result = await Promise.race([promise, timeoutPromise]);
49
- if (timeoutId) {
50
- clearTimeout(timeoutId);
51
- }
52
- return result;
53
- } catch (error) {
54
- if (timeoutId) {
55
- clearTimeout(timeoutId);
56
- }
57
- throw error;
58
- }
49
+ var withTimeout = async (promise, ms) => {
50
+ let timeoutId;
51
+ const timeoutPromise = new Promise((_, reject) => {
52
+ timeoutId = setTimeout(() => {
53
+ reject(new _prosopo_common.ProsopoEnvError("API.UNKNOWN"));
54
+ }, ms);
55
+ });
56
+ try {
57
+ const result = await Promise.race([promise, timeoutPromise]);
58
+ if (timeoutId) clearTimeout(timeoutId);
59
+ return result;
60
+ } catch (error) {
61
+ if (timeoutId) clearTimeout(timeoutId);
62
+ throw error;
63
+ }
59
64
  };
60
- const customDetectBot = async (config, container, restartFn, retryContext) => {
61
- const ipMode = procaptchaCommon.pickIpMode(config);
62
- void procaptchaCommon.getProcaptchaRandomActiveProvider(config.defaultEnvironment).catch(
63
- () => void 0
64
- );
65
- if (ipMode !== void 0) {
66
- void procaptchaCommon.getProcaptchaRandomActiveProvider(
67
- config.defaultEnvironment,
68
- ipMode,
69
- retryContext
70
- ).catch(() => void 0);
71
- }
72
- const [ExtClass, detect] = await Promise.all([
73
- procaptchaCommon.ExtensionLoader(config.web2),
74
- detectorLoader.DetectorLoader()
75
- ]);
76
- const ext = new ExtClass();
77
- const detectionResult = await detect(
78
- config.defaultEnvironment,
79
- async () => procaptchaCommon.getProcaptchaRandomActiveProvider(config.defaultEnvironment),
80
- container,
81
- restartFn,
82
- () => ext.getAccount(config)
83
- );
84
- const userAccount = detectionResult.userAccount;
85
- if (!config.account.address) {
86
- throw new common.ProsopoEnvError("GENERAL.SITE_KEY_MISSING");
87
- }
88
- const provider = await procaptchaCommon.getProcaptchaRandomActiveProvider(
89
- config.defaultEnvironment,
90
- ipMode,
91
- retryContext
92
- );
93
- const providerApi = new api.ProviderApi(
94
- provider.provider.url,
95
- config.account.address
96
- );
97
- const { currentUrl, iframeUrl } = getCurrentPageUrls();
98
- const captchaPromise = providerApi.getFrictionlessCaptcha(
99
- detectionResult.token,
100
- detectionResult.encryptHeadHash,
101
- config.account.address,
102
- userAccount.account.address,
103
- config.mode,
104
- void 0,
105
- currentUrl,
106
- iframeUrl
107
- );
108
- if (detectionResult.getSimdReadings) {
109
- void detectionResult.getSimdReadings(6e4).catch(() => void 0);
110
- }
111
- const captcha = await withTimeout(captchaPromise, 1e4);
112
- if (captcha.dns_url) {
113
- try {
114
- void fetch(captcha.dns_url, {
115
- method: "GET",
116
- mode: "no-cors",
117
- credentials: "omit",
118
- keepalive: true,
119
- cache: "no-store"
120
- }).catch(() => void 0);
121
- } catch {
122
- }
123
- }
124
- return {
125
- captchaType: captcha.captchaType,
126
- sessionId: captcha.sessionId,
127
- provider,
128
- status: captcha.status,
129
- userAccount,
130
- error: captcha.error,
131
- hp: captcha.hp,
132
- // Map specific trackers to generic behavioral collectors
133
- behaviorCollector1: detectionResult.mouseTracker,
134
- behaviorCollector2: detectionResult.touchTracker,
135
- behaviorCollector3: detectionResult.clickTracker,
136
- deviceCapability: detectionResult.hasTouchSupport,
137
- encryptBehavioralData: detectionResult.encryptBehavioralData,
138
- packBehavioralData: detectionResult.packBehavioralData,
139
- getSimdReadings: detectionResult.getSimdReadings
140
- };
65
+ var customDetectBot = async (config, container, restartFn, retryContext) => {
66
+ const ipMode = (0, _prosopo_procaptcha_common.pickIpMode)(config);
67
+ (0, _prosopo_procaptcha_common.getProcaptchaRandomActiveProvider)(config.defaultEnvironment).catch(() => void 0);
68
+ if (ipMode !== void 0) (0, _prosopo_procaptcha_common.getProcaptchaRandomActiveProvider)(config.defaultEnvironment, ipMode, retryContext).catch(() => void 0);
69
+ const [ExtClass, detect] = await Promise.all([(0, _prosopo_procaptcha_common.ExtensionLoader)(config.web2), require_detectorLoader.DetectorLoader()]);
70
+ const ext = new ExtClass();
71
+ const detectionResult = await detect(config.defaultEnvironment, async () => (0, _prosopo_procaptcha_common.getProcaptchaRandomActiveProvider)(config.defaultEnvironment), container, restartFn, () => ext.getAccount(config));
72
+ const userAccount = detectionResult.userAccount;
73
+ if (!config.account.address) throw new _prosopo_common.ProsopoEnvError("GENERAL.SITE_KEY_MISSING");
74
+ const provider = await (0, _prosopo_procaptcha_common.getProcaptchaRandomActiveProvider)(config.defaultEnvironment, ipMode, retryContext);
75
+ const providerApi = new _prosopo_api.ProviderApi(provider.provider.url, config.account.address);
76
+ const { currentUrl, iframeUrl } = getCurrentPageUrls();
77
+ const captchaPromise = providerApi.getFrictionlessCaptcha(detectionResult.token, detectionResult.encryptHeadHash, config.account.address, userAccount.account.address, config.mode, void 0, currentUrl, iframeUrl);
78
+ if (detectionResult.getSimdReadings) detectionResult.getSimdReadings(6e4).catch(() => void 0);
79
+ const captcha = await withTimeout(captchaPromise, 1e4);
80
+ if (captcha.dns_url) try {
81
+ fetch(captcha.dns_url, {
82
+ method: "GET",
83
+ mode: "no-cors",
84
+ credentials: "omit",
85
+ keepalive: true,
86
+ cache: "no-store"
87
+ }).catch(() => void 0);
88
+ } catch {}
89
+ return {
90
+ captchaType: captcha.captchaType,
91
+ sessionId: captcha.sessionId,
92
+ provider,
93
+ status: captcha.status,
94
+ userAccount,
95
+ error: captcha.error,
96
+ hp: captcha.hp,
97
+ behaviorCollector1: detectionResult.mouseTracker,
98
+ behaviorCollector2: detectionResult.touchTracker,
99
+ behaviorCollector3: detectionResult.clickTracker,
100
+ deviceCapability: detectionResult.hasTouchSupport,
101
+ encryptBehavioralData: detectionResult.encryptBehavioralData,
102
+ packBehavioralData: detectionResult.packBehavioralData,
103
+ getSimdReadings: detectionResult.getSimdReadings
104
+ };
141
105
  };
106
+ //#endregion
142
107
  exports.default = customDetectBot;
143
108
  exports.withTimeout = withTimeout;
@@ -1,26 +1,4 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (let key of __getOwnPropNames(from))
11
- if (!__hasOwnProp.call(to, key) && key !== except)
12
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- }
14
- return to;
15
- };
16
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
- // If the importer is in node compatibility mode or this is not an ESM
18
- // file that has been converted to a CommonJS file using a Babel-
19
- // compatible transform (i.e. "__esModule" has not been set), then set
20
- // "default" to the CommonJS "module.exports" for node compatibility.
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
25
- const DetectorLoader = async () => (await import("@prosopo/detector")).default;
1
+ //#region src/detectorLoader.ts
2
+ var DetectorLoader = async () => (await import("@prosopo/detector")).default;
3
+ //#endregion
26
4
  exports.DetectorLoader = DetectorLoader;
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const ProcaptchaFrictionless = require("./ProcaptchaFrictionless.cjs");
4
- exports.ProcaptchaFrictionless = ProcaptchaFrictionless.ProcaptchaFrictionless;
2
+ const require_ProcaptchaFrictionless = require("./ProcaptchaFrictionless.cjs");
3
+ exports.ProcaptchaFrictionless = require_ProcaptchaFrictionless.ProcaptchaFrictionless;
@@ -1,20 +1,47 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const handleSessionInvalidated = (x, y, firedRef, pendingCoordsRef) => {
4
- if (firedRef.current) return { shouldRestart: false };
5
- firedRef.current = true;
6
- const bothNumeric = typeof x === "number" && typeof y === "number";
7
- const isRealClick = bothNumeric && (x !== 0 || y !== 0);
8
- pendingCoordsRef.current = isRealClick ? { x, y } : null;
9
- return { shouldRestart: true };
1
+ //#region src/sessionInvalidatedRecovery.ts
2
+ /**
3
+ * Semantics of the outer recovery handler. Returns whether the caller
4
+ * should proceed to re-run the frictionless flow (`start()`), and mutates
5
+ * the passed refs to record the one-shot fire + pending coords.
6
+ *
7
+ * - Second calls are ignored (one-shot per outer widget lifetime) so a
8
+ * persistently broken session doesn't loop.
9
+ * - Coords are recorded only for a real trusted checkbox click. A partial
10
+ * pair (only x or only y numeric) is treated as "no coords" so we
11
+ * never accidentally embed `NaN` into the solution salt.
12
+ * - `(0, 0)` is treated as "no coords" too — that's what the widgets
13
+ * emit for an `autoStart` mount (post-PoW escalation) or an untrusted
14
+ * pointer event on the checkbox, neither of which is a real click. The
15
+ * resumed widget re-uses the same default and the outcome on the wire
16
+ * is identical; we discard the pair here so future readers can tell
17
+ * the two apart.
18
+ */
19
+ var handleSessionInvalidated = (x, y, firedRef, pendingCoordsRef) => {
20
+ if (firedRef.current) return { shouldRestart: false };
21
+ firedRef.current = true;
22
+ pendingCoordsRef.current = typeof x === "number" && typeof y === "number" && (x !== 0 || y !== 0) ? {
23
+ x,
24
+ y
25
+ } : null;
26
+ return { shouldRestart: true };
10
27
  };
11
- const consumeRetryMountProps = (pendingCoordsRef, escalationAutoStart) => {
12
- const startCoords = pendingCoordsRef.current ?? void 0;
13
- pendingCoordsRef.current = null;
14
- return {
15
- autoStart: escalationAutoStart || Boolean(startCoords),
16
- startCoords
17
- };
28
+ /**
29
+ * Compute the props a resumed inner widget mounts with. Consumes the
30
+ * pending coords ref (sets it back to `null`) so the next render doesn't
31
+ * accidentally re-inject stale coords into a fresh escalation.
32
+ *
33
+ * `escalationAutoStart` reflects the caller's own `autoStart` argument to
34
+ * `renderForCaptchaType` — post-PoW escalations keep the historic
35
+ * autoStart=true behaviour when no retry coords are pending.
36
+ */
37
+ var consumeRetryMountProps = (pendingCoordsRef, escalationAutoStart) => {
38
+ const startCoords = pendingCoordsRef.current ?? void 0;
39
+ pendingCoordsRef.current = null;
40
+ return {
41
+ autoStart: escalationAutoStart || Boolean(startCoords),
42
+ startCoords
43
+ };
18
44
  };
45
+ //#endregion
19
46
  exports.consumeRetryMountProps = consumeRetryMountProps;
20
47
  exports.handleSessionInvalidated = handleSessionInvalidated;
@@ -1,143 +1,107 @@
1
+ import { DetectorLoader } from "./detectorLoader.js";
2
+ import { ExtensionLoader, getProcaptchaRandomActiveProvider, pickIpMode } from "@prosopo/procaptcha-common";
1
3
  import { ProviderApi } from "@prosopo/api";
2
4
  import { ProsopoEnvError } from "@prosopo/common";
3
- import { pickIpMode, getProcaptchaRandomActiveProvider, ExtensionLoader } from "@prosopo/procaptcha-common";
4
- import { DetectorLoader } from "./detectorLoader.js";
5
- const sanitiseHref = (href) => {
6
- try {
7
- const u = new URL(href);
8
- if (!u.origin || u.origin === "null") return void 0;
9
- return `${u.origin}${u.pathname || ""}`;
10
- } catch {
11
- return void 0;
12
- }
13
- };
14
- const getCurrentPageUrls = () => {
15
- if (typeof window === "undefined" || !window.location) {
16
- return { currentUrl: void 0, iframeUrl: void 0 };
17
- }
18
- const local = (() => {
19
- const { origin, pathname } = window.location;
20
- if (!origin || origin === "null") return void 0;
21
- return `${origin}${pathname || ""}`;
22
- })();
23
- if (window === window.top) {
24
- return { currentUrl: local, iframeUrl: void 0 };
25
- }
26
- try {
27
- const topHref = window.top?.location?.href;
28
- const sanitised = topHref ? sanitiseHref(topHref) : void 0;
29
- if (sanitised) return { currentUrl: sanitised, iframeUrl: local };
30
- } catch {
31
- }
32
- if (typeof document !== "undefined" && document.referrer) {
33
- const fromReferrer = sanitiseHref(document.referrer);
34
- if (fromReferrer) return { currentUrl: fromReferrer, iframeUrl: local };
35
- }
36
- return { currentUrl: local, iframeUrl: local };
5
+ //#region src/customDetectBot.ts
6
+ var sanitiseHref = (href) => {
7
+ try {
8
+ const u = new URL(href);
9
+ if (!u.origin || u.origin === "null") return void 0;
10
+ return `${u.origin}${u.pathname || ""}`;
11
+ } catch {
12
+ return;
13
+ }
37
14
  };
38
- const withTimeout = async (promise, ms) => {
39
- let timeoutId;
40
- const timeoutPromise = new Promise((_, reject) => {
41
- timeoutId = setTimeout(() => {
42
- reject(new ProsopoEnvError("API.UNKNOWN"));
43
- }, ms);
44
- });
45
- try {
46
- const result = await Promise.race([promise, timeoutPromise]);
47
- if (timeoutId) {
48
- clearTimeout(timeoutId);
49
- }
50
- return result;
51
- } catch (error) {
52
- if (timeoutId) {
53
- clearTimeout(timeoutId);
54
- }
55
- throw error;
56
- }
15
+ var getCurrentPageUrls = () => {
16
+ if (typeof window === "undefined" || !window.location) return {
17
+ currentUrl: void 0,
18
+ iframeUrl: void 0
19
+ };
20
+ const local = (() => {
21
+ const { origin, pathname } = window.location;
22
+ if (!origin || origin === "null") return void 0;
23
+ return `${origin}${pathname || ""}`;
24
+ })();
25
+ if (window === window.top) return {
26
+ currentUrl: local,
27
+ iframeUrl: void 0
28
+ };
29
+ try {
30
+ const topHref = window.top?.location?.href;
31
+ const sanitised = topHref ? sanitiseHref(topHref) : void 0;
32
+ if (sanitised) return {
33
+ currentUrl: sanitised,
34
+ iframeUrl: local
35
+ };
36
+ } catch {}
37
+ if (typeof document !== "undefined" && document.referrer) {
38
+ const fromReferrer = sanitiseHref(document.referrer);
39
+ if (fromReferrer) return {
40
+ currentUrl: fromReferrer,
41
+ iframeUrl: local
42
+ };
43
+ }
44
+ return {
45
+ currentUrl: local,
46
+ iframeUrl: local
47
+ };
57
48
  };
58
- const customDetectBot = async (config, container, restartFn, retryContext) => {
59
- const ipMode = pickIpMode(config);
60
- void getProcaptchaRandomActiveProvider(config.defaultEnvironment).catch(
61
- () => void 0
62
- );
63
- if (ipMode !== void 0) {
64
- void getProcaptchaRandomActiveProvider(
65
- config.defaultEnvironment,
66
- ipMode,
67
- retryContext
68
- ).catch(() => void 0);
69
- }
70
- const [ExtClass, detect] = await Promise.all([
71
- ExtensionLoader(config.web2),
72
- DetectorLoader()
73
- ]);
74
- const ext = new ExtClass();
75
- const detectionResult = await detect(
76
- config.defaultEnvironment,
77
- async () => getProcaptchaRandomActiveProvider(config.defaultEnvironment),
78
- container,
79
- restartFn,
80
- () => ext.getAccount(config)
81
- );
82
- const userAccount = detectionResult.userAccount;
83
- if (!config.account.address) {
84
- throw new ProsopoEnvError("GENERAL.SITE_KEY_MISSING");
85
- }
86
- const provider = await getProcaptchaRandomActiveProvider(
87
- config.defaultEnvironment,
88
- ipMode,
89
- retryContext
90
- );
91
- const providerApi = new ProviderApi(
92
- provider.provider.url,
93
- config.account.address
94
- );
95
- const { currentUrl, iframeUrl } = getCurrentPageUrls();
96
- const captchaPromise = providerApi.getFrictionlessCaptcha(
97
- detectionResult.token,
98
- detectionResult.encryptHeadHash,
99
- config.account.address,
100
- userAccount.account.address,
101
- config.mode,
102
- void 0,
103
- currentUrl,
104
- iframeUrl
105
- );
106
- if (detectionResult.getSimdReadings) {
107
- void detectionResult.getSimdReadings(6e4).catch(() => void 0);
108
- }
109
- const captcha = await withTimeout(captchaPromise, 1e4);
110
- if (captcha.dns_url) {
111
- try {
112
- void fetch(captcha.dns_url, {
113
- method: "GET",
114
- mode: "no-cors",
115
- credentials: "omit",
116
- keepalive: true,
117
- cache: "no-store"
118
- }).catch(() => void 0);
119
- } catch {
120
- }
121
- }
122
- return {
123
- captchaType: captcha.captchaType,
124
- sessionId: captcha.sessionId,
125
- provider,
126
- status: captcha.status,
127
- userAccount,
128
- error: captcha.error,
129
- hp: captcha.hp,
130
- // Map specific trackers to generic behavioral collectors
131
- behaviorCollector1: detectionResult.mouseTracker,
132
- behaviorCollector2: detectionResult.touchTracker,
133
- behaviorCollector3: detectionResult.clickTracker,
134
- deviceCapability: detectionResult.hasTouchSupport,
135
- encryptBehavioralData: detectionResult.encryptBehavioralData,
136
- packBehavioralData: detectionResult.packBehavioralData,
137
- getSimdReadings: detectionResult.getSimdReadings
138
- };
49
+ var withTimeout = async (promise, ms) => {
50
+ let timeoutId;
51
+ const timeoutPromise = new Promise((_, reject) => {
52
+ timeoutId = setTimeout(() => {
53
+ reject(new ProsopoEnvError("API.UNKNOWN"));
54
+ }, ms);
55
+ });
56
+ try {
57
+ const result = await Promise.race([promise, timeoutPromise]);
58
+ if (timeoutId) clearTimeout(timeoutId);
59
+ return result;
60
+ } catch (error) {
61
+ if (timeoutId) clearTimeout(timeoutId);
62
+ throw error;
63
+ }
139
64
  };
140
- export {
141
- customDetectBot as default,
142
- withTimeout
65
+ var customDetectBot = async (config, container, restartFn, retryContext) => {
66
+ const ipMode = pickIpMode(config);
67
+ getProcaptchaRandomActiveProvider(config.defaultEnvironment).catch(() => void 0);
68
+ if (ipMode !== void 0) getProcaptchaRandomActiveProvider(config.defaultEnvironment, ipMode, retryContext).catch(() => void 0);
69
+ const [ExtClass, detect] = await Promise.all([ExtensionLoader(config.web2), DetectorLoader()]);
70
+ const ext = new ExtClass();
71
+ const detectionResult = await detect(config.defaultEnvironment, async () => getProcaptchaRandomActiveProvider(config.defaultEnvironment), container, restartFn, () => ext.getAccount(config));
72
+ const userAccount = detectionResult.userAccount;
73
+ if (!config.account.address) throw new ProsopoEnvError("GENERAL.SITE_KEY_MISSING");
74
+ const provider = await getProcaptchaRandomActiveProvider(config.defaultEnvironment, ipMode, retryContext);
75
+ const providerApi = new ProviderApi(provider.provider.url, config.account.address);
76
+ const { currentUrl, iframeUrl } = getCurrentPageUrls();
77
+ const captchaPromise = providerApi.getFrictionlessCaptcha(detectionResult.token, detectionResult.encryptHeadHash, config.account.address, userAccount.account.address, config.mode, void 0, currentUrl, iframeUrl);
78
+ if (detectionResult.getSimdReadings) detectionResult.getSimdReadings(6e4).catch(() => void 0);
79
+ const captcha = await withTimeout(captchaPromise, 1e4);
80
+ if (captcha.dns_url) try {
81
+ fetch(captcha.dns_url, {
82
+ method: "GET",
83
+ mode: "no-cors",
84
+ credentials: "omit",
85
+ keepalive: true,
86
+ cache: "no-store"
87
+ }).catch(() => void 0);
88
+ } catch {}
89
+ return {
90
+ captchaType: captcha.captchaType,
91
+ sessionId: captcha.sessionId,
92
+ provider,
93
+ status: captcha.status,
94
+ userAccount,
95
+ error: captcha.error,
96
+ hp: captcha.hp,
97
+ behaviorCollector1: detectionResult.mouseTracker,
98
+ behaviorCollector2: detectionResult.touchTracker,
99
+ behaviorCollector3: detectionResult.clickTracker,
100
+ deviceCapability: detectionResult.hasTouchSupport,
101
+ encryptBehavioralData: detectionResult.encryptBehavioralData,
102
+ packBehavioralData: detectionResult.packBehavioralData,
103
+ getSimdReadings: detectionResult.getSimdReadings
104
+ };
143
105
  };
106
+ //#endregion
107
+ export { customDetectBot as default, withTimeout };
@@ -1,4 +1,4 @@
1
- const DetectorLoader = async () => (await import("@prosopo/detector")).default;
2
- export {
3
- DetectorLoader
4
- };
1
+ //#region src/detectorLoader.ts
2
+ var DetectorLoader = async () => (await import("@prosopo/detector")).default;
3
+ //#endregion
4
+ export { DetectorLoader };
package/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
+ import "./_virtual/_rolldown/runtime.js";
1
2
  import { ProcaptchaFrictionless } from "./ProcaptchaFrictionless.js";
2
- export {
3
- ProcaptchaFrictionless
4
- };
3
+ export { ProcaptchaFrictionless };