@prosopo/procaptcha-frictionless 2.12.21 → 2.12.22
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/.turbo/turbo-build$colon$cjs.log +13 -12
- package/.turbo/turbo-build$colon$tsc.log +25 -25
- package/.turbo/turbo-build.log +15 -12
- package/CHANGELOG.md +19 -0
- package/dist/ProcaptchaFrictionless.js +165 -236
- package/dist/_virtual/_rolldown/runtime.js +3 -0
- package/dist/cjs/ProcaptchaFrictionless.cjs +166 -259
- package/dist/cjs/customDetectBot.cjs +102 -137
- package/dist/cjs/detectorLoader.cjs +3 -25
- package/dist/cjs/index.cjs +2 -3
- package/dist/cjs/sessionInvalidatedRecovery.cjs +43 -16
- package/dist/customDetectBot.js +101 -137
- package/dist/detectorLoader.js +4 -4
- package/dist/index.js +2 -3
- package/dist/sessionInvalidatedRecovery.js +44 -18
- package/dist/tests/customDetectBotSimd.test.js +5 -3
- package/dist/tests/customDetectBotSimd.test.js.map +1 -1
- package/package.json +14 -14
- package/src/tests/customDetectBotSimd.test.ts +8 -3
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,143 +1,108 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
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;
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
4
|
-
exports.ProcaptchaFrictionless =
|
|
2
|
+
const require_ProcaptchaFrictionless = require("./ProcaptchaFrictionless.cjs");
|
|
3
|
+
exports.ProcaptchaFrictionless = require_ProcaptchaFrictionless.ProcaptchaFrictionless;
|
|
@@ -1,20 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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;
|
package/dist/customDetectBot.js
CHANGED
|
@@ -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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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 };
|
package/dist/detectorLoader.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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