@prosopo/procaptcha-frictionless 2.25.3 → 2.26.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/.turbo/turbo-build$colon$cjs.log +4 -3
- package/.turbo/turbo-build$colon$esm.log +4 -3
- package/.turbo/turbo-build$colon$tsc.log +25 -25
- package/CHANGELOG.md +35 -0
- package/dist/cjs/customDetectBot.cjs +5 -2
- package/dist/cjs/webRtcProbe.cjs +50 -0
- package/dist/esm/customDetectBot.js +5 -2
- package/dist/esm/webRtcProbe.js +50 -0
- package/dist/tsc/customDetectBot.d.ts.map +1 -1
- package/dist/tsc/customDetectBot.js +7 -2
- package/dist/tsc/customDetectBot.js.map +1 -1
- package/dist/tsc/tests/webRtcProbe.test.d.ts +2 -0
- package/dist/tsc/tests/webRtcProbe.test.d.ts.map +1 -0
- package/dist/tsc/tests/webRtcProbe.test.js +82 -0
- package/dist/tsc/tests/webRtcProbe.test.js.map +1 -0
- package/dist/tsc/webRtcProbe.d.ts +3 -0
- package/dist/tsc/webRtcProbe.d.ts.map +1 -0
- package/dist/tsc/webRtcProbe.js +56 -0
- package/dist/tsc/webRtcProbe.js.map +1 -0
- package/dist/types/customDetectBot.d.ts.map +1 -1
- package/dist/types/tests/webRtcProbe.test.d.ts +2 -0
- package/dist/types/tests/webRtcProbe.test.d.ts.map +1 -0
- package/dist/types/webRtcProbe.d.ts +3 -0
- package/dist/types/webRtcProbe.d.ts.map +1 -0
- package/package.json +10 -10
|
@@ -54,18 +54,19 @@ ViteCommonJSConfig: .
|
|
|
54
54
|
[36mvite v8.1.6 [32mbuilding ssr environment for production...[36m[39m
|
|
55
55
|
Bundle build started
|
|
56
56
|
[2K
|
|
57
|
-
✓
|
|
57
|
+
✓ 12 modules transformed.
|
|
58
58
|
rendering chunks...
|
|
59
59
|
computing gzip size...
|
|
60
60
|
dist/cjs/index.cjs 0.55 kB │ gzip: 0.21 kB
|
|
61
61
|
dist/cjs/widgetSlot.cjs 0.74 kB │ gzip: 0.33 kB
|
|
62
62
|
dist/cjs/bypassKeyCookie.cjs 0.78 kB │ gzip: 0.39 kB
|
|
63
63
|
dist/cjs/detectorLoader.cjs 1.65 kB │ gzip: 0.90 kB
|
|
64
|
+
dist/cjs/webRtcProbe.cjs 1.93 kB │ gzip: 0.84 kB
|
|
64
65
|
dist/cjs/sessionInvalidatedRecovery.cjs 2.50 kB │ gzip: 1.14 kB
|
|
65
66
|
dist/cjs/frictionlessResultGuard.cjs 2.78 kB │ gzip: 1.42 kB
|
|
66
67
|
dist/cjs/detectorPrefetch.cjs 3.59 kB │ gzip: 1.57 kB
|
|
67
68
|
dist/cjs/authenticatedBadge.cjs 3.81 kB │ gzip: 1.45 kB
|
|
68
|
-
dist/cjs/customDetectBot.cjs 8.
|
|
69
|
+
dist/cjs/customDetectBot.cjs 8.33 kB │ gzip: 2.42 kB
|
|
69
70
|
dist/cjs/procaptchaFrictionless.cjs 15.03 kB │ gzip: 4.06 kB
|
|
70
71
|
|
|
71
|
-
[32m✓ built in
|
|
72
|
+
[32m✓ built in 55ms[39m
|
|
@@ -54,7 +54,7 @@ ViteEsmConfig: .
|
|
|
54
54
|
[36mvite v8.1.6 [32mbuilding ssr environment for production...[36m[39m
|
|
55
55
|
Bundle build started
|
|
56
56
|
[2K
|
|
57
|
-
✓
|
|
57
|
+
✓ 12 modules transformed.
|
|
58
58
|
rendering chunks...
|
|
59
59
|
computing gzip size...
|
|
60
60
|
dist/esm/_virtual/_rolldown/runtime.js 0.02 kB │ gzip: 0.04 kB
|
|
@@ -62,11 +62,12 @@ dist/esm/index.js 0.33 kB │ gzip: 0.15 kB
|
|
|
62
62
|
dist/esm/widgetSlot.js 0.66 kB │ gzip: 0.32 kB
|
|
63
63
|
dist/esm/bypassKeyCookie.js 0.73 kB │ gzip: 0.38 kB
|
|
64
64
|
dist/esm/detectorLoader.js 1.63 kB │ gzip: 0.90 kB
|
|
65
|
+
dist/esm/webRtcProbe.js 1.85 kB │ gzip: 0.83 kB
|
|
65
66
|
dist/esm/sessionInvalidatedRecovery.js 2.41 kB │ gzip: 1.13 kB
|
|
66
67
|
dist/esm/frictionlessResultGuard.js 2.71 kB │ gzip: 1.41 kB
|
|
67
68
|
dist/esm/authenticatedBadge.js 3.30 kB │ gzip: 1.42 kB
|
|
68
69
|
dist/esm/detectorPrefetch.js 3.46 kB │ gzip: 1.54 kB
|
|
69
|
-
dist/esm/customDetectBot.js 7.
|
|
70
|
+
dist/esm/customDetectBot.js 7.88 kB │ gzip: 2.38 kB
|
|
70
71
|
dist/esm/procaptchaFrictionless.js 14.19 kB │ gzip: 4.02 kB
|
|
71
72
|
|
|
72
|
-
[32m✓ built in
|
|
73
|
+
[32m✓ built in 55ms[39m
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
$ tsc --build --verbose
|
|
2
|
-
|
|
2
|
+
2:11:17 PM - Projects in this build:
|
|
3
3
|
* ../../dev/config/tsconfig.json
|
|
4
4
|
* ../util/tsconfig.json
|
|
5
5
|
* ../locale/tsconfig.json
|
|
@@ -24,51 +24,51 @@ $ tsc --build --verbose
|
|
|
24
24
|
* ../procaptcha-react/tsconfig.json
|
|
25
25
|
* tsconfig.json
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
2:11:17 PM - Project '../../dev/config/tsconfig.json' is up to date because newest input '../../dev/config/src/webpack/webpack.config.ts' is older than output '../../dev/config/dist/tsc/tsconfig.tsbuildinfo'
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
2:11:17 PM - Project '../util/tsconfig.json' is up to date because newest input '../util/src/text.ts' is older than output '../util/dist/tsc/tsconfig.tsbuildinfo'
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
2:11:17 PM - Project '../locale/tsconfig.json' is up to date because newest input '../locale/src/process.ts' is older than output '../locale/dist/tsc/tsconfig.tsbuildinfo'
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
2:11:17 PM - Project '../util-crypto/tsconfig.json' is up to date because newest input '../util-crypto/src/types.ts' is older than output '../util-crypto/dist/tsc/tsconfig.tsbuildinfo'
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
2:11:17 PM - Project '../types/tsconfig.json' is up to date because newest input '../types/src/types.test-d.ts' is older than output '../types/dist/tsc/tsconfig.tsbuildinfo'
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
2:11:17 PM - Project '../api/tsconfig.json' is up to date because newest input '../api/src/index.ts' is older than output '../api/dist/tsc/tsconfig.tsbuildinfo'
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
2:11:18 PM - Project '../common/tsconfig.json' is up to date because newest input '../common/src/tests/errorSites.unit.test.ts' is older than output '../common/dist/tsc/tsconfig.tsbuildinfo'
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
2:11:18 PM - Project '../fingerprintjs/tsconfig.json' is up to date because newest input '../fingerprintjs/src/utils/browser.ts' is older than output '../fingerprintjs/dist/tsc/tsconfig.tsbuildinfo'
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
2:11:18 PM - Project '../fingerprint/tsconfig.json' is up to date because newest input '../fingerprint/src/index.test.ts' is older than output '../fingerprint/dist/tsc/tsconfig.tsbuildinfo'
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
2:11:18 PM - Project '../load-balancer/tsconfig.json' is up to date because newest input '../load-balancer/src/developmentProviderUrl.ts' is older than output '../load-balancer/dist/tsc/tsconfig.tsbuildinfo'
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
2:11:18 PM - Project '../widget-skeleton/tsconfig.json' is up to date because newest input '../widget-skeleton/src/constants.ts' is older than output '../widget-skeleton/dist/tsc/tsconfig.tsbuildinfo'
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
2:11:18 PM - Project '../keyring/tsconfig.json' is up to date because newest input '../keyring/src/pair/decode.ts' is older than output '../keyring/dist/tsc/tsconfig.tsbuildinfo'
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
2:11:18 PM - Project '../account/tsconfig.json' is up to date because newest input '../account/src/tests/cryptoWorker.unit.test.ts' is older than output '../account/dist/tsc/tsconfig.tsbuildinfo'
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
2:11:18 PM - Project '../procaptcha-common/tsconfig.json' is up to date because newest input '../procaptcha-common/src/usageBeacon.ts' is older than output '../procaptcha-common/dist/tsc/tsconfig.tsbuildinfo'
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
2:11:18 PM - Project '../procaptcha-audio/tsconfig.json' is up to date because newest input '../procaptcha-audio/src/errorSites.ts' is older than output '../procaptcha-audio/dist/tsc/tsconfig.tsbuildinfo'
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
2:11:18 PM - Project '../procaptcha-icon-order/tsconfig.json' is up to date because newest input '../procaptcha-icon-order/src/errorSites.ts' is older than output '../procaptcha-icon-order/dist/tsc/tsconfig.tsbuildinfo'
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
2:11:18 PM - Project '../procaptcha-pow/tsconfig.json' is up to date because newest input '../procaptcha-pow/src/tests/manager.unit.test.ts' is older than output '../procaptcha-pow/dist/tsc/tsconfig.tsbuildinfo'
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
2:11:18 PM - Project '../procaptcha-puzzle/tsconfig.json' is up to date because newest input '../procaptcha-puzzle/src/services/pieceMask.ts' is older than output '../procaptcha-puzzle/dist/tsc/tsconfig.tsbuildinfo'
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
2:11:18 PM - Project '../logger/tsconfig.json' is up to date because newest input '../logger/src/logger.ts' is older than output '../logger/dist/tsc/tsconfig.tsbuildinfo'
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
2:11:18 PM - Project '../datasets/tsconfig.json' is up to date because newest input '../datasets/src/errorSites.ts' is older than output '../datasets/dist/tsc/tsconfig.tsbuildinfo'
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
2:11:18 PM - Project '../procaptcha/tsconfig.json' is up to date because newest input '../procaptcha/src/errorSites.ts' is older than output '../procaptcha/dist/tsc/tsconfig.tsbuildinfo'
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
2:11:18 PM - Project '../procaptcha-react/tsconfig.json' is up to date because newest input '../procaptcha-react/src/errorSites.ts' is older than output '../procaptcha-react/dist/tsc/tsconfig.tsbuildinfo'
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
2:11:18 PM - Project 'tsconfig.json' is out of date because output file 'dist/tsc/tsconfig.tsbuildinfo' does not exist
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
2:11:18 PM - Building project '/home/runner/work/captcha/captcha/packages/procaptcha-frictionless/tsconfig.json'...
|
|
74
74
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# @prosopo/procaptcha-frictionless
|
|
2
2
|
|
|
3
|
+
## 2.26.0
|
|
4
|
+
### Minor Changes
|
|
5
|
+
|
|
6
|
+
- b877bd4: Check where a browser's WebRTC traffic comes from. When a provider runs the stun-probe sidecar, it gives the widget a STUN address. The widget gathers WebRTC candidates while detection runs and sends them with the frictionless request. The provider asks stun-probe whether the STUN request really arrived and from which address, and stores the result on the session. A mismatch with the HTTP address means the HTTP traffic went through a proxy that the UDP traffic skipped. Only the outcome and the leaked address's network are stored, never the address. Nothing routes on it yet.
|
|
7
|
+
|
|
8
|
+
### Patch Changes
|
|
9
|
+
|
|
10
|
+
- Updated dependencies [a7a60f4]
|
|
11
|
+
- Updated dependencies [b877bd4]
|
|
12
|
+
- @prosopo/types@5.30.0
|
|
13
|
+
- @prosopo/api@4.11.0
|
|
14
|
+
- @prosopo/common@3.3.2
|
|
15
|
+
- @prosopo/fingerprint@2.8.20
|
|
16
|
+
- @prosopo/procaptcha-audio@0.3.9
|
|
17
|
+
- @prosopo/procaptcha-common@2.23.9
|
|
18
|
+
- @prosopo/procaptcha-icon-order@0.3.9
|
|
19
|
+
- @prosopo/procaptcha-pow@2.14.17
|
|
20
|
+
- @prosopo/procaptcha-puzzle@2.18.9
|
|
21
|
+
- @prosopo/procaptcha-react@2.14.28
|
|
22
|
+
|
|
23
|
+
## 2.25.4
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- Updated dependencies [93620d4]
|
|
27
|
+
- @prosopo/types@5.29.1
|
|
28
|
+
- @prosopo/api@4.10.4
|
|
29
|
+
- @prosopo/common@3.3.2
|
|
30
|
+
- @prosopo/fingerprint@2.8.19
|
|
31
|
+
- @prosopo/procaptcha-audio@0.3.8
|
|
32
|
+
- @prosopo/procaptcha-common@2.23.8
|
|
33
|
+
- @prosopo/procaptcha-icon-order@0.3.8
|
|
34
|
+
- @prosopo/procaptcha-pow@2.14.16
|
|
35
|
+
- @prosopo/procaptcha-puzzle@2.18.8
|
|
36
|
+
- @prosopo/procaptcha-react@2.14.27
|
|
37
|
+
|
|
3
38
|
## 2.25.3
|
|
4
39
|
### Patch Changes
|
|
5
40
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const require_bypassKeyCookie = require("./bypassKeyCookie.cjs");
|
|
2
2
|
const require_detectorLoader = require("./detectorLoader.cjs");
|
|
3
3
|
const require_detectorPrefetch = require("./detectorPrefetch.cjs");
|
|
4
|
+
const require_webRtcProbe = require("./webRtcProbe.cjs");
|
|
4
5
|
let _prosopo_common = require("@prosopo/common");
|
|
5
6
|
let _prosopo_procaptcha_common = require("@prosopo/procaptcha-common");
|
|
6
7
|
let _prosopo_api = require("@prosopo/api");
|
|
@@ -114,8 +115,10 @@ var customDetectBot = async (config, container, restartFn, retryContext, refresh
|
|
|
114
115
|
let detectorSessionId;
|
|
115
116
|
let providerDetect;
|
|
116
117
|
let detectorOptions;
|
|
118
|
+
let webrtcReport;
|
|
117
119
|
try {
|
|
118
120
|
const assigned = prefetchedResult?.assigned ?? await withTimeout(providerApi.assignDetectorBundle(config.account.address), ASSIGN_TIMEOUT_MS);
|
|
121
|
+
if (assigned.stunUrl) webrtcReport = require_webRtcProbe.gatherWebRtcCandidates(assigned.stunUrl);
|
|
119
122
|
if (assigned.useProviderBundle && assigned.detectorScript) {
|
|
120
123
|
providerDetect = await require_detectorLoader.DetectorLoaderFromScript(assigned.detectorScript);
|
|
121
124
|
detectorSessionId = assigned.detectorSessionId;
|
|
@@ -133,7 +136,7 @@ var customDetectBot = async (config, container, restartFn, retryContext, refresh
|
|
|
133
136
|
const userAccount = await ext.getAccount(config);
|
|
134
137
|
const { currentUrl: fallbackUrl, iframeUrl: fallbackIframeUrl } = getCurrentPageUrls();
|
|
135
138
|
const fallbackFingerprintProof = await fingerprintProofIfReady();
|
|
136
|
-
const captcha = await withTimeout(providerApi.getFrictionlessCaptcha(void 0, void 0, config.account.address, userAccount.account.address, config.mode, void 0, void 0, fallbackUrl, fallbackIframeUrl, clientSessionId, refreshOf, switchTo, fallbackFingerprintProof, widgetSlot, retryOf, require_bypassKeyCookie.readBypassKeyCookie()), 1e4);
|
|
139
|
+
const captcha = await withTimeout(providerApi.getFrictionlessCaptcha(void 0, void 0, config.account.address, userAccount.account.address, config.mode, void 0, void 0, fallbackUrl, fallbackIframeUrl, clientSessionId, refreshOf, switchTo, fallbackFingerprintProof, widgetSlot, retryOf, require_bypassKeyCookie.readBypassKeyCookie(), void 0, await webrtcReport), 1e4);
|
|
137
140
|
sendDnsBeacons(captcha);
|
|
138
141
|
return {
|
|
139
142
|
captchaType: captcha.captchaType,
|
|
@@ -164,7 +167,7 @@ var customDetectBot = async (config, container, restartFn, retryContext, refresh
|
|
|
164
167
|
const behavioralData = await (0, _prosopo_procaptcha_common.encryptBehavioralDataForSubmit)(behaviour);
|
|
165
168
|
const { currentUrl, iframeUrl } = getCurrentPageUrls();
|
|
166
169
|
const fingerprintProof = await fingerprintProofIfReady();
|
|
167
|
-
const captchaPromise = providerApi.getFrictionlessCaptcha(detectionResult.token, detectionResult.encryptHeadHash, config.account.address, userAccount.account.address, config.mode, void 0, detectorSessionId, currentUrl, iframeUrl, clientSessionId, refreshOf, switchTo, fingerprintProof, widgetSlot, retryOf, require_bypassKeyCookie.readBypassKeyCookie(), behavioralData);
|
|
170
|
+
const captchaPromise = providerApi.getFrictionlessCaptcha(detectionResult.token, detectionResult.encryptHeadHash, config.account.address, userAccount.account.address, config.mode, void 0, detectorSessionId, currentUrl, iframeUrl, clientSessionId, refreshOf, switchTo, fingerprintProof, widgetSlot, retryOf, require_bypassKeyCookie.readBypassKeyCookie(), behavioralData, await webrtcReport);
|
|
168
171
|
if (detectionResult.getSimdReadings) detectionResult.getSimdReadings(6e4).catch(() => void 0);
|
|
169
172
|
const captcha = await withTimeout(captchaPromise, 1e4);
|
|
170
173
|
sendDnsBeacons(captcha);
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
let _prosopo_types = require("@prosopo/types");
|
|
2
|
+
//#region src/webRtcProbe.ts
|
|
3
|
+
var GATHER_DEADLINE_MS = 1500;
|
|
4
|
+
var AFTER_FIRST_SRFLX_MS = 150;
|
|
5
|
+
/**
|
|
6
|
+
* Gathers ICE candidates against the provider's STUN server. Never rejects; the
|
|
7
|
+
* provider compares the srflx candidates with what its stun-probe saw.
|
|
8
|
+
*/
|
|
9
|
+
var gatherWebRtcCandidates = (stunUrl) => {
|
|
10
|
+
const startedAt = Date.now();
|
|
11
|
+
const report = (status, candidates = []) => ({
|
|
12
|
+
status,
|
|
13
|
+
gatherMs: Math.min(Date.now() - startedAt, 6e4),
|
|
14
|
+
candidates
|
|
15
|
+
});
|
|
16
|
+
if (typeof RTCPeerConnection !== "function") return Promise.resolve(report(_prosopo_types.WebRtcClientStatus.unsupported));
|
|
17
|
+
return new Promise((resolve) => {
|
|
18
|
+
const candidates = [];
|
|
19
|
+
let pc;
|
|
20
|
+
let settled = false;
|
|
21
|
+
let afterSrflx;
|
|
22
|
+
const finish = (status) => {
|
|
23
|
+
if (settled) return;
|
|
24
|
+
settled = true;
|
|
25
|
+
clearTimeout(deadline);
|
|
26
|
+
clearTimeout(afterSrflx);
|
|
27
|
+
try {
|
|
28
|
+
pc?.close();
|
|
29
|
+
} catch {}
|
|
30
|
+
resolve(report(status, candidates));
|
|
31
|
+
};
|
|
32
|
+
const deadline = setTimeout(() => finish(_prosopo_types.WebRtcClientStatus.timeout), GATHER_DEADLINE_MS);
|
|
33
|
+
try {
|
|
34
|
+
pc = new RTCPeerConnection({ iceServers: [{ urls: stunUrl }] });
|
|
35
|
+
pc.onicecandidate = (event) => {
|
|
36
|
+
if (!event.candidate) return finish(_prosopo_types.WebRtcClientStatus.gathered);
|
|
37
|
+
const line = event.candidate.candidate;
|
|
38
|
+
if (!line || candidates.length >= _prosopo_types.WEBRTC_MAX_CANDIDATES) return;
|
|
39
|
+
candidates.push(line.slice(0, _prosopo_types.WEBRTC_MAX_CANDIDATE_LENGTH));
|
|
40
|
+
if (event.candidate.type === "srflx" && !afterSrflx) afterSrflx = setTimeout(() => finish(_prosopo_types.WebRtcClientStatus.gathered), AFTER_FIRST_SRFLX_MS);
|
|
41
|
+
};
|
|
42
|
+
pc.createDataChannel("p");
|
|
43
|
+
pc.createOffer().then((offer) => pc?.setLocalDescription(offer)).catch(() => finish(_prosopo_types.WebRtcClientStatus.error));
|
|
44
|
+
} catch {
|
|
45
|
+
finish(_prosopo_types.WebRtcClientStatus.error);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
//#endregion
|
|
50
|
+
exports.gatherWebRtcCandidates = gatherWebRtcCandidates;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readBypassKeyCookie } from "./bypassKeyCookie.js";
|
|
2
2
|
import { DetectorLoaderFromScript } from "./detectorLoader.js";
|
|
3
3
|
import { takePrefetchedDetector } from "./detectorPrefetch.js";
|
|
4
|
+
import { gatherWebRtcCandidates } from "./webRtcProbe.js";
|
|
4
5
|
import { ProsopoError } from "@prosopo/common";
|
|
5
6
|
import { ExtensionLoader, PAGE_BEHAVIOUR_LIMITS, encryptBehavioralDataForSubmit, getPageBehaviour, getProcaptchaRandomActiveProvider, mergeBehaviourPoints, pickIpMode, resolveClientSessionId, stopPageBehaviourCapture, widgetRequestHeaders } from "@prosopo/procaptcha-common";
|
|
6
7
|
import { ProviderApi } from "@prosopo/api";
|
|
@@ -113,8 +114,10 @@ var customDetectBot = async (config, container, restartFn, retryContext, refresh
|
|
|
113
114
|
let detectorSessionId;
|
|
114
115
|
let providerDetect;
|
|
115
116
|
let detectorOptions;
|
|
117
|
+
let webrtcReport;
|
|
116
118
|
try {
|
|
117
119
|
const assigned = prefetchedResult?.assigned ?? await withTimeout(providerApi.assignDetectorBundle(config.account.address), ASSIGN_TIMEOUT_MS);
|
|
120
|
+
if (assigned.stunUrl) webrtcReport = gatherWebRtcCandidates(assigned.stunUrl);
|
|
118
121
|
if (assigned.useProviderBundle && assigned.detectorScript) {
|
|
119
122
|
providerDetect = await DetectorLoaderFromScript(assigned.detectorScript);
|
|
120
123
|
detectorSessionId = assigned.detectorSessionId;
|
|
@@ -132,7 +135,7 @@ var customDetectBot = async (config, container, restartFn, retryContext, refresh
|
|
|
132
135
|
const userAccount = await ext.getAccount(config);
|
|
133
136
|
const { currentUrl: fallbackUrl, iframeUrl: fallbackIframeUrl } = getCurrentPageUrls();
|
|
134
137
|
const fallbackFingerprintProof = await fingerprintProofIfReady();
|
|
135
|
-
const captcha = await withTimeout(providerApi.getFrictionlessCaptcha(void 0, void 0, config.account.address, userAccount.account.address, config.mode, void 0, void 0, fallbackUrl, fallbackIframeUrl, clientSessionId, refreshOf, switchTo, fallbackFingerprintProof, widgetSlot, retryOf, readBypassKeyCookie()), 1e4);
|
|
138
|
+
const captcha = await withTimeout(providerApi.getFrictionlessCaptcha(void 0, void 0, config.account.address, userAccount.account.address, config.mode, void 0, void 0, fallbackUrl, fallbackIframeUrl, clientSessionId, refreshOf, switchTo, fallbackFingerprintProof, widgetSlot, retryOf, readBypassKeyCookie(), void 0, await webrtcReport), 1e4);
|
|
136
139
|
sendDnsBeacons(captcha);
|
|
137
140
|
return {
|
|
138
141
|
captchaType: captcha.captchaType,
|
|
@@ -163,7 +166,7 @@ var customDetectBot = async (config, container, restartFn, retryContext, refresh
|
|
|
163
166
|
const behavioralData = await encryptBehavioralDataForSubmit(behaviour);
|
|
164
167
|
const { currentUrl, iframeUrl } = getCurrentPageUrls();
|
|
165
168
|
const fingerprintProof = await fingerprintProofIfReady();
|
|
166
|
-
const captchaPromise = providerApi.getFrictionlessCaptcha(detectionResult.token, detectionResult.encryptHeadHash, config.account.address, userAccount.account.address, config.mode, void 0, detectorSessionId, currentUrl, iframeUrl, clientSessionId, refreshOf, switchTo, fingerprintProof, widgetSlot, retryOf, readBypassKeyCookie(), behavioralData);
|
|
169
|
+
const captchaPromise = providerApi.getFrictionlessCaptcha(detectionResult.token, detectionResult.encryptHeadHash, config.account.address, userAccount.account.address, config.mode, void 0, detectorSessionId, currentUrl, iframeUrl, clientSessionId, refreshOf, switchTo, fingerprintProof, widgetSlot, retryOf, readBypassKeyCookie(), behavioralData, await webrtcReport);
|
|
167
170
|
if (detectionResult.getSimdReadings) detectionResult.getSimdReadings(6e4).catch(() => void 0);
|
|
168
171
|
const captcha = await withTimeout(captchaPromise, 1e4);
|
|
169
172
|
sendDnsBeacons(captcha);
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { WEBRTC_MAX_CANDIDATES, WEBRTC_MAX_CANDIDATE_LENGTH, WebRtcClientStatus } from "@prosopo/types";
|
|
2
|
+
//#region src/webRtcProbe.ts
|
|
3
|
+
var GATHER_DEADLINE_MS = 1500;
|
|
4
|
+
var AFTER_FIRST_SRFLX_MS = 150;
|
|
5
|
+
/**
|
|
6
|
+
* Gathers ICE candidates against the provider's STUN server. Never rejects; the
|
|
7
|
+
* provider compares the srflx candidates with what its stun-probe saw.
|
|
8
|
+
*/
|
|
9
|
+
var gatherWebRtcCandidates = (stunUrl) => {
|
|
10
|
+
const startedAt = Date.now();
|
|
11
|
+
const report = (status, candidates = []) => ({
|
|
12
|
+
status,
|
|
13
|
+
gatherMs: Math.min(Date.now() - startedAt, 6e4),
|
|
14
|
+
candidates
|
|
15
|
+
});
|
|
16
|
+
if (typeof RTCPeerConnection !== "function") return Promise.resolve(report(WebRtcClientStatus.unsupported));
|
|
17
|
+
return new Promise((resolve) => {
|
|
18
|
+
const candidates = [];
|
|
19
|
+
let pc;
|
|
20
|
+
let settled = false;
|
|
21
|
+
let afterSrflx;
|
|
22
|
+
const finish = (status) => {
|
|
23
|
+
if (settled) return;
|
|
24
|
+
settled = true;
|
|
25
|
+
clearTimeout(deadline);
|
|
26
|
+
clearTimeout(afterSrflx);
|
|
27
|
+
try {
|
|
28
|
+
pc?.close();
|
|
29
|
+
} catch {}
|
|
30
|
+
resolve(report(status, candidates));
|
|
31
|
+
};
|
|
32
|
+
const deadline = setTimeout(() => finish(WebRtcClientStatus.timeout), GATHER_DEADLINE_MS);
|
|
33
|
+
try {
|
|
34
|
+
pc = new RTCPeerConnection({ iceServers: [{ urls: stunUrl }] });
|
|
35
|
+
pc.onicecandidate = (event) => {
|
|
36
|
+
if (!event.candidate) return finish(WebRtcClientStatus.gathered);
|
|
37
|
+
const line = event.candidate.candidate;
|
|
38
|
+
if (!line || candidates.length >= WEBRTC_MAX_CANDIDATES) return;
|
|
39
|
+
candidates.push(line.slice(0, WEBRTC_MAX_CANDIDATE_LENGTH));
|
|
40
|
+
if (event.candidate.type === "srflx" && !afterSrflx) afterSrflx = setTimeout(() => finish(WebRtcClientStatus.gathered), AFTER_FIRST_SRFLX_MS);
|
|
41
|
+
};
|
|
42
|
+
pc.createDataChannel("p");
|
|
43
|
+
pc.createOffer().then((offer) => pc?.setLocalDescription(offer)).catch(() => finish(WebRtcClientStatus.error));
|
|
44
|
+
} catch {
|
|
45
|
+
finish(WebRtcClientStatus.error);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
//#endregion
|
|
50
|
+
export { gatherWebRtcCandidates };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customDetectBot.d.ts","sourceRoot":"","sources":["../../src/customDetectBot.ts"],"names":[],"mappings":"AAiCA,OAAO,KAAK,EACX,oBAAoB,EACpB,8BAA8B,
|
|
1
|
+
{"version":3,"file":"customDetectBot.d.ts","sourceRoot":"","sources":["../../src/customDetectBot.ts"],"names":[],"mappings":"AAiCA,OAAO,KAAK,EACX,oBAAoB,EACpB,8BAA8B,EAK9B,MAAM,gBAAgB,CAAC;AA8FxB,eAAO,MAAM,cAAc,gCAGxB,IAAI,CAAC,8BAA8B,EAAE,SAAS,GAAG,eAAe,CAAC,KAAG,IAiBtE,CAAC;AAEF,eAAO,MAAM,WAAW,GAAU,CAAC,WACzB,OAAO,CAAC,CAAC,CAAC,MACf,MAAM,KACR,OAAO,CAAC,CAAC,CA0BX,CAAC;AAuCF,QAAA,MAAM,eAAe,EAAE,oBAwRtB,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -5,6 +5,7 @@ import { ExtensionLoader, PAGE_BEHAVIOUR_LIMITS, encryptBehavioralDataForSubmit,
|
|
|
5
5
|
import { readBypassKeyCookie } from "./bypassKeyCookie.js";
|
|
6
6
|
import { DetectorLoaderFromScript, } from "./detectorLoader.js";
|
|
7
7
|
import { takePrefetchedDetector, } from "./detectorPrefetch.js";
|
|
8
|
+
import { gatherWebRtcCandidates } from "./webRtcProbe.js";
|
|
8
9
|
const ASSIGN_TIMEOUT_MS = 10_000;
|
|
9
10
|
const sanitiseHref = (href) => {
|
|
10
11
|
try {
|
|
@@ -127,9 +128,13 @@ const customDetectBot = async (config, container, restartFn, retryContext, refre
|
|
|
127
128
|
let detectorSessionId;
|
|
128
129
|
let providerDetect;
|
|
129
130
|
let detectorOptions;
|
|
131
|
+
let webrtcReport;
|
|
130
132
|
try {
|
|
131
133
|
const assigned = prefetchedResult?.assigned ??
|
|
132
134
|
(await withTimeout(providerApi.assignDetectorBundle(config.account.address), ASSIGN_TIMEOUT_MS));
|
|
135
|
+
if (assigned.stunUrl) {
|
|
136
|
+
webrtcReport = gatherWebRtcCandidates(assigned.stunUrl);
|
|
137
|
+
}
|
|
133
138
|
if (assigned.useProviderBundle && assigned.detectorScript) {
|
|
134
139
|
providerDetect = await DetectorLoaderFromScript(assigned.detectorScript);
|
|
135
140
|
detectorSessionId = assigned.detectorSessionId;
|
|
@@ -149,7 +154,7 @@ const customDetectBot = async (config, container, restartFn, retryContext, refre
|
|
|
149
154
|
const userAccount = await ext.getAccount(config);
|
|
150
155
|
const { currentUrl: fallbackUrl, iframeUrl: fallbackIframeUrl } = getCurrentPageUrls();
|
|
151
156
|
const fallbackFingerprintProof = await fingerprintProofIfReady();
|
|
152
|
-
const captcha = await withTimeout(providerApi.getFrictionlessCaptcha(undefined, undefined, config.account.address, userAccount.account.address, config.mode, undefined, undefined, fallbackUrl, fallbackIframeUrl, clientSessionId, refreshOf, switchTo, fallbackFingerprintProof, widgetSlot, retryOf, readBypassKeyCookie()), 10000);
|
|
157
|
+
const captcha = await withTimeout(providerApi.getFrictionlessCaptcha(undefined, undefined, config.account.address, userAccount.account.address, config.mode, undefined, undefined, fallbackUrl, fallbackIframeUrl, clientSessionId, refreshOf, switchTo, fallbackFingerprintProof, widgetSlot, retryOf, readBypassKeyCookie(), undefined, await webrtcReport), 10000);
|
|
153
158
|
sendDnsBeacons(captcha);
|
|
154
159
|
return {
|
|
155
160
|
captchaType: captcha.captchaType,
|
|
@@ -181,7 +186,7 @@ const customDetectBot = async (config, container, restartFn, retryContext, refre
|
|
|
181
186
|
const behavioralData = await encryptBehavioralDataForSubmit(behaviour);
|
|
182
187
|
const { currentUrl, iframeUrl } = getCurrentPageUrls();
|
|
183
188
|
const fingerprintProof = await fingerprintProofIfReady();
|
|
184
|
-
const captchaPromise = providerApi.getFrictionlessCaptcha(detectionResult.token, detectionResult.encryptHeadHash, config.account.address, userAccount.account.address, config.mode, undefined, detectorSessionId, currentUrl, iframeUrl, clientSessionId, refreshOf, switchTo, fingerprintProof, widgetSlot, retryOf, readBypassKeyCookie(), behavioralData);
|
|
189
|
+
const captchaPromise = providerApi.getFrictionlessCaptcha(detectionResult.token, detectionResult.encryptHeadHash, config.account.address, userAccount.account.address, config.mode, undefined, detectorSessionId, currentUrl, iframeUrl, clientSessionId, refreshOf, switchTo, fingerprintProof, widgetSlot, retryOf, readBypassKeyCookie(), behavioralData, await webrtcReport);
|
|
185
190
|
if (detectionResult.getSimdReadings) {
|
|
186
191
|
void detectionResult.getSimdReadings(60_000).catch(() => undefined);
|
|
187
192
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customDetectBot.js","sourceRoot":"","sources":["../../src/customDetectBot.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EACN,2BAA2B,EAC3B,sBAAsB,EACtB,mBAAmB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACN,eAAe,EACf,qBAAqB,EACrB,8BAA8B,EAC9B,gBAAgB,EAChB,iCAAiC,EACjC,oBAAoB,EACpB,UAAU,EACV,sBAAsB,EACtB,wBAAwB,EACxB,oBAAoB,GACpB,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"customDetectBot.js","sourceRoot":"","sources":["../../src/customDetectBot.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EACN,2BAA2B,EAC3B,sBAAsB,EACtB,mBAAmB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACN,eAAe,EACf,qBAAqB,EACrB,8BAA8B,EAC9B,gBAAgB,EAChB,iCAAiC,EACjC,oBAAoB,EACpB,UAAU,EACV,sBAAsB,EACtB,wBAAwB,EACxB,oBAAoB,GACpB,MAAM,4BAA4B,CAAC;AAUpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EACN,wBAAwB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eAAe,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IACrE,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,WAAW,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IAEzD,cAAc,CAAC,OAAO,CAAC,CAAC;IAExB,OAAO;QACN,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,QAAQ,EAAE,QAAQ;QAClB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,WAAW,EAAE,WAAW;QACxB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,EAAE,EAAE,OAAO,CAAC,EAAE;QACd,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,yBAAyB,EAAE,OAAO,CAAC,yBAAyB;QAC5D,GAAG,SAAS;QACZ,eAAe,EAAE,eAAe,CAAC,eAAe;KAChD,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webRtcProbe.test.d.ts","sourceRoot":"","sources":["../../../src/tests/webRtcProbe.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { WebRtcClientStatus } from "@prosopo/types";
|
|
2
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
3
|
+
import { gatherWebRtcCandidates } from "../webRtcProbe.js";
|
|
4
|
+
const HOST = "candidate:2 1 udp 2122260223 abc.local 49637 typ host generation 0";
|
|
5
|
+
const SRFLX = "candidate:1 1 udp 1677729535 82.45.237.60 49637 typ srflx raddr 0.0.0.0 rport 0";
|
|
6
|
+
const fakePeerConnection = (script) => {
|
|
7
|
+
const configs = [];
|
|
8
|
+
let closed = 0;
|
|
9
|
+
class FakePeerConnection {
|
|
10
|
+
constructor(config) {
|
|
11
|
+
this.onicecandidate = null;
|
|
12
|
+
configs.push(config);
|
|
13
|
+
}
|
|
14
|
+
createDataChannel(_label) { }
|
|
15
|
+
async createOffer() {
|
|
16
|
+
return { type: "offer", sdp: "" };
|
|
17
|
+
}
|
|
18
|
+
async setLocalDescription(_d) {
|
|
19
|
+
for (const { at, candidate } of script) {
|
|
20
|
+
setTimeout(() => this.onicecandidate?.({ candidate }), at);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
close() {
|
|
24
|
+
closed += 1;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
vi.stubGlobal("RTCPeerConnection", FakePeerConnection);
|
|
28
|
+
return { configs, closed: () => closed };
|
|
29
|
+
};
|
|
30
|
+
describe("gatherWebRtcCandidates", () => {
|
|
31
|
+
beforeEach(() => {
|
|
32
|
+
vi.useFakeTimers();
|
|
33
|
+
});
|
|
34
|
+
afterEach(() => {
|
|
35
|
+
vi.useRealTimers();
|
|
36
|
+
vi.unstubAllGlobals();
|
|
37
|
+
});
|
|
38
|
+
it("reports unsupported when the browser has no RTCPeerConnection", async () => {
|
|
39
|
+
vi.stubGlobal("RTCPeerConnection", undefined);
|
|
40
|
+
const report = await gatherWebRtcCandidates("stun:pronode1.prosopo.io:3478");
|
|
41
|
+
expect(report.status).toBe(WebRtcClientStatus.unsupported);
|
|
42
|
+
expect(report.candidates).toEqual([]);
|
|
43
|
+
});
|
|
44
|
+
it("uses only the provider's STUN server and stops shortly after the first srflx", async () => {
|
|
45
|
+
const pc = fakePeerConnection([
|
|
46
|
+
{ at: 5, candidate: { candidate: HOST, type: "host" } },
|
|
47
|
+
{ at: 40, candidate: { candidate: SRFLX, type: "srflx" } },
|
|
48
|
+
{ at: 5000, candidate: null },
|
|
49
|
+
]);
|
|
50
|
+
const pending = gatherWebRtcCandidates("stun:pronode1.prosopo.io:3478");
|
|
51
|
+
await vi.advanceTimersByTimeAsync(200);
|
|
52
|
+
const report = await pending;
|
|
53
|
+
expect(pc.configs).toEqual([
|
|
54
|
+
{ iceServers: [{ urls: "stun:pronode1.prosopo.io:3478" }] },
|
|
55
|
+
]);
|
|
56
|
+
expect(report.status).toBe(WebRtcClientStatus.gathered);
|
|
57
|
+
expect(report.candidates).toEqual([HOST, SRFLX]);
|
|
58
|
+
expect(pc.closed()).toBe(1);
|
|
59
|
+
});
|
|
60
|
+
it("finishes when gathering completes without a srflx", async () => {
|
|
61
|
+
fakePeerConnection([
|
|
62
|
+
{ at: 5, candidate: { candidate: HOST, type: "host" } },
|
|
63
|
+
{ at: 10, candidate: null },
|
|
64
|
+
]);
|
|
65
|
+
const pending = gatherWebRtcCandidates("stun:pronode1.prosopo.io:3478");
|
|
66
|
+
await vi.advanceTimersByTimeAsync(20);
|
|
67
|
+
const report = await pending;
|
|
68
|
+
expect(report.status).toBe(WebRtcClientStatus.gathered);
|
|
69
|
+
expect(report.candidates).toEqual([HOST]);
|
|
70
|
+
});
|
|
71
|
+
it("times out when the STUN server never answers", async () => {
|
|
72
|
+
fakePeerConnection([
|
|
73
|
+
{ at: 5, candidate: { candidate: HOST, type: "host" } },
|
|
74
|
+
]);
|
|
75
|
+
const pending = gatherWebRtcCandidates("stun:pronode1.prosopo.io:3478");
|
|
76
|
+
await vi.advanceTimersByTimeAsync(1600);
|
|
77
|
+
const report = await pending;
|
|
78
|
+
expect(report.status).toBe(WebRtcClientStatus.timeout);
|
|
79
|
+
expect(report.gatherMs).toBeGreaterThanOrEqual(1500);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
//# sourceMappingURL=webRtcProbe.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webRtcProbe.test.js","sourceRoot":"","sources":["../../../src/tests/webRtcProbe.test.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAA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C,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;QACvD,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webRtcProbe.d.ts","sourceRoot":"","sources":["../../src/webRtcProbe.ts"],"names":[],"mappings":"AAcA,OAAO,EAIN,KAAK,iBAAiB,EACtB,MAAM,gBAAgB,CAAC;AAaxB,eAAO,MAAM,sBAAsB,YACzB,MAAM,KACb,OAAO,CAAC,iBAAiB,CAqD3B,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { WEBRTC_MAX_CANDIDATES, WEBRTC_MAX_CANDIDATE_LENGTH, WebRtcClientStatus, } from "@prosopo/types";
|
|
2
|
+
const GATHER_DEADLINE_MS = 1500;
|
|
3
|
+
const AFTER_FIRST_SRFLX_MS = 150;
|
|
4
|
+
export const gatherWebRtcCandidates = (stunUrl) => {
|
|
5
|
+
const startedAt = Date.now();
|
|
6
|
+
const report = (status, candidates = []) => ({
|
|
7
|
+
status,
|
|
8
|
+
gatherMs: Math.min(Date.now() - startedAt, 60_000),
|
|
9
|
+
candidates,
|
|
10
|
+
});
|
|
11
|
+
if (typeof RTCPeerConnection !== "function") {
|
|
12
|
+
return Promise.resolve(report(WebRtcClientStatus.unsupported));
|
|
13
|
+
}
|
|
14
|
+
return new Promise((resolve) => {
|
|
15
|
+
const candidates = [];
|
|
16
|
+
let pc;
|
|
17
|
+
let settled = false;
|
|
18
|
+
let afterSrflx;
|
|
19
|
+
const finish = (status) => {
|
|
20
|
+
if (settled)
|
|
21
|
+
return;
|
|
22
|
+
settled = true;
|
|
23
|
+
clearTimeout(deadline);
|
|
24
|
+
clearTimeout(afterSrflx);
|
|
25
|
+
try {
|
|
26
|
+
pc?.close();
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
}
|
|
30
|
+
resolve(report(status, candidates));
|
|
31
|
+
};
|
|
32
|
+
const deadline = setTimeout(() => finish(WebRtcClientStatus.timeout), GATHER_DEADLINE_MS);
|
|
33
|
+
try {
|
|
34
|
+
pc = new RTCPeerConnection({ iceServers: [{ urls: stunUrl }] });
|
|
35
|
+
pc.onicecandidate = (event) => {
|
|
36
|
+
if (!event.candidate)
|
|
37
|
+
return finish(WebRtcClientStatus.gathered);
|
|
38
|
+
const line = event.candidate.candidate;
|
|
39
|
+
if (!line || candidates.length >= WEBRTC_MAX_CANDIDATES)
|
|
40
|
+
return;
|
|
41
|
+
candidates.push(line.slice(0, WEBRTC_MAX_CANDIDATE_LENGTH));
|
|
42
|
+
if (event.candidate.type === "srflx" && !afterSrflx) {
|
|
43
|
+
afterSrflx = setTimeout(() => finish(WebRtcClientStatus.gathered), AFTER_FIRST_SRFLX_MS);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
pc.createDataChannel("p");
|
|
47
|
+
pc.createOffer()
|
|
48
|
+
.then((offer) => pc?.setLocalDescription(offer))
|
|
49
|
+
.catch(() => finish(WebRtcClientStatus.error));
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
finish(WebRtcClientStatus.error);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=webRtcProbe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webRtcProbe.js","sourceRoot":"","sources":["../../src/webRtcProbe.ts"],"names":[],"mappings":"AAcA,OAAO,EACN,qBAAqB,EACrB,2BAA2B,EAC3B,kBAAkB,GAElB,MAAM,gBAAgB,CAAC;AAIxB,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAGhC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAMjC,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACrC,OAAe,EACc,EAAE;IAC/B,MAAM,SAAS,GAAG,IAAI,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AE,EAAE;gBAC7B,IAAI,CAAC,KAAK,CAAC,SAAS;oBAAE,OAAO,MAAM,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;gBACjE,MAAM,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC;gBACvC,IAAI,CAAC,IAAI,IAAI,UAAU,CAAC,MAAM,IAAI,qBAAqB;oBAAE,OAAO;gBAChE,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,2BAA2B,CAAC,CAAC,CAAC;gBAC5D,IAAI,KAAK,CAAC,SAAS,CAAC,IAAI,KAAK,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;oBACrD,UAAU,GAAG,UAAU,CACtB,GAAG,EAAE,CAAC,MAAM,CAAC,kBAAkB,CAAC,QAAQ,CAAC,EACzC,oBAAoB,CACpB,CAAC;gBACH,CAAC;YACF,CAAC,CAAC;YACF,EAAE,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;YAC1B,EAAE,CAAC,WAAW,EAAE;iBACd,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE,mBAAmB,CAAC,KAAK,CAAC,CAAC;iBAC/C,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC;QACjD,CAAC;QAAC,MAAM,CAAC;YACR,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAClC,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customDetectBot.d.ts","sourceRoot":"","sources":["../../src/customDetectBot.ts"],"names":[],"mappings":"AAiCA,OAAO,KAAK,EACX,oBAAoB,EACpB,8BAA8B,
|
|
1
|
+
{"version":3,"file":"customDetectBot.d.ts","sourceRoot":"","sources":["../../src/customDetectBot.ts"],"names":[],"mappings":"AAiCA,OAAO,KAAK,EACX,oBAAoB,EACpB,8BAA8B,EAK9B,MAAM,gBAAgB,CAAC;AA8FxB,eAAO,MAAM,cAAc,gCAGxB,IAAI,CAAC,8BAA8B,EAAE,SAAS,GAAG,eAAe,CAAC,KAAG,IAiBtE,CAAC;AAEF,eAAO,MAAM,WAAW,GAAU,CAAC,WACzB,OAAO,CAAC,CAAC,CAAC,MACf,MAAM,KACR,OAAO,CAAC,CAAC,CA0BX,CAAC;AAuCF,QAAA,MAAM,eAAe,EAAE,oBAwRtB,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webRtcProbe.test.d.ts","sourceRoot":"","sources":["../../../src/tests/webRtcProbe.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webRtcProbe.d.ts","sourceRoot":"","sources":["../../src/webRtcProbe.ts"],"names":[],"mappings":"AAcA,OAAO,EAIN,KAAK,iBAAiB,EACtB,MAAM,gBAAgB,CAAC;AAaxB,eAAO,MAAM,sBAAsB,YACzB,MAAM,KACb,OAAO,CAAC,iBAAiB,CAqD3B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosopo/procaptcha-frictionless",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.26.0",
|
|
4
4
|
"author": "PROSOPO LIMITED <info@prosopo.io>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
@@ -22,17 +22,17 @@
|
|
|
22
22
|
"> 0.5%, last 2 versions, not dead"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@prosopo/api": "4.
|
|
25
|
+
"@prosopo/api": "4.11.0",
|
|
26
26
|
"@prosopo/common": "3.3.2",
|
|
27
|
-
"@prosopo/fingerprint": "2.8.
|
|
27
|
+
"@prosopo/fingerprint": "2.8.20",
|
|
28
28
|
"@prosopo/locale": "3.14.4",
|
|
29
|
-
"@prosopo/procaptcha-audio": "0.3.
|
|
30
|
-
"@prosopo/procaptcha-common": "2.23.
|
|
31
|
-
"@prosopo/procaptcha-icon-order": "0.3.
|
|
32
|
-
"@prosopo/procaptcha-pow": "2.14.
|
|
33
|
-
"@prosopo/procaptcha-puzzle": "2.18.
|
|
34
|
-
"@prosopo/procaptcha-react": "2.14.
|
|
35
|
-
"@prosopo/types": "5.
|
|
29
|
+
"@prosopo/procaptcha-audio": "0.3.9",
|
|
30
|
+
"@prosopo/procaptcha-common": "2.23.9",
|
|
31
|
+
"@prosopo/procaptcha-icon-order": "0.3.9",
|
|
32
|
+
"@prosopo/procaptcha-pow": "2.14.17",
|
|
33
|
+
"@prosopo/procaptcha-puzzle": "2.18.9",
|
|
34
|
+
"@prosopo/procaptcha-react": "2.14.28",
|
|
35
|
+
"@prosopo/types": "5.30.0",
|
|
36
36
|
"@prosopo/widget-skeleton": "2.10.5",
|
|
37
37
|
"dotenv": "18.0.8"
|
|
38
38
|
},
|