@xbrowser/cli 1.28.0 → 1.30.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/README.md +2 -2
- package/dist/{browser-4IYIHZ6R.js → browser-6PFTHZI3.js} +8 -6
- package/dist/{browser-NYYCR4O7.js → browser-I2NLJN2A.js} +5 -3
- package/dist/{browser-ZD53IMUJ.js → browser-KOUA4ZDA.js} +6 -4
- package/dist/{cdp-driver-EFEW4ZEN.js → cdp-driver-3ETNFQA4.js} +4 -4
- package/dist/{cdp-driver-HB744QB4.js → cdp-driver-U7HDQMQ5.js} +1578 -896
- package/dist/{cdp-driver-4X6Q62WI.js → cdp-driver-WBFJNOLD.js} +3 -3
- package/dist/{chunk-SEEWE5SJ.js → chunk-2KPI5GKP.js} +3 -0
- package/dist/{chunk-OEC7ZSFW.js → chunk-3K57RYVC.js} +1942 -1580
- package/dist/{chunk-75DNUI6M.js → chunk-6UJU2FJK.js} +146 -0
- package/dist/{chunk-FNXA6FDM.js → chunk-BND5O5KC.js} +2 -1
- package/dist/{chunk-KECYFWJO.js → chunk-BOZTIIBT.js} +441 -427
- package/dist/{chunk-WK3INZLA.js → chunk-KPTD3SNJ.js} +1121 -759
- package/dist/{chunk-OSZNJT4U.js → chunk-LM32MNBB.js} +79 -8
- package/dist/{chunk-T2AI24A5.js → chunk-NAIHOVDZ.js} +3 -0
- package/dist/{chunk-WYETQ5C7.js → chunk-NEE6EMYA.js} +14 -1
- package/dist/{chunk-3PUOISKE.js → chunk-NINETOM4.js} +524 -495
- package/dist/{chunk-SOPN4XDK.js → chunk-O5PASNI7.js} +2 -1
- package/dist/{chunk-ME5FO5YV.js → chunk-OCECE22C.js} +1578 -896
- package/dist/{chunk-HSYRAV3H.js → chunk-OSIDUT4H.js} +2151 -1440
- package/dist/{chunk-HBMEFSTB.js → chunk-QCV2PI7U.js} +2 -1
- package/dist/{chunk-IR6C24P7.js → chunk-RMYKVZIZ.js} +1103 -1043
- package/dist/{chunk-R3F4K2SB.js → chunk-SMYSNO4M.js} +10 -0
- package/dist/{chunk-J3HXZVSN.js → chunk-SPNWUUHA.js} +1452 -916
- package/dist/{chunk-PGKV24QN.js → chunk-TBJUSUKF.js} +1 -1
- package/dist/{chunk-V6KGBU5J.js → chunk-VYTQLZAX.js} +1091 -1040
- package/dist/cli.js +3447 -3377
- package/dist/daemon-main.js +1240 -786
- package/dist/{human-interaction-CTZ4IWXJ.js → human-interaction-ISMMOJOK.js} +2 -2
- package/dist/{human-interaction-HJCK45SL.js → human-interaction-STTZZZ5N.js} +1 -1
- package/dist/{human-interaction-V3VDGHHI.js → human-interaction-UXFYV7DU.js} +1 -1
- package/dist/index.d.ts +458 -476
- package/dist/index.js +3766 -3576
- package/dist/{launcher-SJ44X25U.js → launcher-TOLF23ET.js} +1 -1
- package/dist/{launcher-XHKIC4GP.js → launcher-ZYB32LSZ.js} +1 -1
- package/dist/{plugin-singleton-GGSBI3EG.js → plugin-singleton-A6RNITJW.js} +1 -1
- package/dist/{proxy-NKCYE76M.js → proxy-H3RIUOCN.js} +2 -2
- package/dist/{recovery-EBKORYEU.js → recovery-JFGV3DBX.js} +1 -1
- package/dist/{recovery-5C4FBA5O.js → recovery-ORHJSBDN.js} +2 -2
- package/dist/{recovery-IMZUGWSS.js → recovery-XDKN63O5.js} +1 -1
- package/dist/{server-26SE6YZR.js → server-TG47W7MV.js} +7 -7
- package/dist/{server-JXF3JOAM.js → server-U3YAX5MJ.js} +4 -4
- package/dist/{session-recorder-GEZVQBKW.js → session-recorder-N7VEKJVW.js} +1 -1
- package/dist/{session-recorder-563ISSJK.js → session-recorder-RUNQOJ7T.js} +1 -1
- package/dist/{session-replayer-TXTNTG33.js → session-replayer-XLWQ47BB.js} +1 -1
- package/dist/{stealth-QNSMIHQK.js → stealth-FMPZO2OB.js} +1 -1
- package/dist/{stealth-MHJNBJY7.js → stealth-MCKFKPZ6.js} +1 -1
- package/package.json +9 -3
|
@@ -897,6 +897,149 @@ var pageLifecycleRule = {
|
|
|
897
897
|
}
|
|
898
898
|
};
|
|
899
899
|
|
|
900
|
+
// src/cdp-interceptor/rules/humanize-transform.ts
|
|
901
|
+
var CURSOR_KEY = "humanize-cursor";
|
|
902
|
+
var KEYS_KEY = "humanize-keys";
|
|
903
|
+
var MOUSE_STEP_DELAYS = [16, 19, 23, 28];
|
|
904
|
+
var TYPE_DELAYS = [42, 58, 74, 96, 118, 155, 210];
|
|
905
|
+
function rand(min, max) {
|
|
906
|
+
return min + Math.random() * (max - min);
|
|
907
|
+
}
|
|
908
|
+
function roundCoordinate(value) {
|
|
909
|
+
return Math.round(value * 100) / 100;
|
|
910
|
+
}
|
|
911
|
+
function humanMousePath(fromX, fromY, toX, toY) {
|
|
912
|
+
const dist = Math.hypot(toX - fromX, toY - fromY);
|
|
913
|
+
const n = Math.max(8, Math.min(28, Math.round(dist / 15)));
|
|
914
|
+
const shortMove = dist < 120;
|
|
915
|
+
const curvature = shortMove ? rand(2, 6) : Math.max(dist * rand(0.12, 0.22), rand(18, 35));
|
|
916
|
+
const dir = Math.random() < 0.5 ? 1 : -1;
|
|
917
|
+
const dx = toX - fromX;
|
|
918
|
+
const dy = toY - fromY;
|
|
919
|
+
const d = dist || 1;
|
|
920
|
+
const c1x = fromX + dx * 0.3 - dy / d * curvature * 0.5 * dir;
|
|
921
|
+
const c1y = fromY + dy * 0.3 + dx / d * curvature * 0.5 * dir;
|
|
922
|
+
const c2x = fromX + dx * 0.7 - dy / d * curvature * 0.8 * dir;
|
|
923
|
+
const c2y = fromY + dy * 0.7 + dx / d * curvature * 0.8 * dir;
|
|
924
|
+
const amp = shortMove ? Math.min(2, 3.2) : 3.2;
|
|
925
|
+
const points = [];
|
|
926
|
+
for (let i = 1; i <= n; i++) {
|
|
927
|
+
const t = i / n;
|
|
928
|
+
const eased = t < 0.5 ? 2 * t * t : 1 - Math.pow(-2 * t + 2, 2) / 2;
|
|
929
|
+
const mt = 1 - eased;
|
|
930
|
+
const px = mt ** 3 * fromX + 3 * mt ** 2 * eased * c1x + 3 * mt * eased ** 2 * c2x + eased ** 3 * toX;
|
|
931
|
+
const py = mt ** 3 * fromY + 3 * mt ** 2 * eased * c1y + 3 * mt * eased ** 2 * c2y + eased ** 3 * toY;
|
|
932
|
+
points.push({
|
|
933
|
+
x: roundCoordinate(px + rand(-amp, amp)),
|
|
934
|
+
y: roundCoordinate(py + rand(-amp, amp)),
|
|
935
|
+
delay: MOUSE_STEP_DELAYS[Math.floor(Math.random() * MOUSE_STEP_DELAYS.length)]
|
|
936
|
+
});
|
|
937
|
+
}
|
|
938
|
+
if (!shortMove) {
|
|
939
|
+
const over = rand(6, 14);
|
|
940
|
+
points.push({
|
|
941
|
+
x: roundCoordinate(toX + dx / d * over + rand(-2, 2)),
|
|
942
|
+
y: roundCoordinate(toY + dy / d * over + rand(-2, 2)),
|
|
943
|
+
delay: Math.round(rand(14, 30))
|
|
944
|
+
});
|
|
945
|
+
points.push({
|
|
946
|
+
x: roundCoordinate(toX + dx / d * over * 0.4),
|
|
947
|
+
y: roundCoordinate(toY + dy / d * over * 0.4),
|
|
948
|
+
delay: Math.round(rand(14, 30))
|
|
949
|
+
});
|
|
950
|
+
}
|
|
951
|
+
points.push({
|
|
952
|
+
x: roundCoordinate(toX + rand(-1, 1)),
|
|
953
|
+
y: roundCoordinate(toY + rand(-1, 1)),
|
|
954
|
+
delay: Math.round(rand(14, 30))
|
|
955
|
+
});
|
|
956
|
+
return points;
|
|
957
|
+
}
|
|
958
|
+
function characterKeyEvents(text) {
|
|
959
|
+
const events = [];
|
|
960
|
+
for (const char of text) {
|
|
961
|
+
if (char === "\n") {
|
|
962
|
+
events.push(
|
|
963
|
+
{ type: "rawKeyDown", key: "Enter", code: "Enter", windowsVirtualKeyCode: 13 },
|
|
964
|
+
{ type: "char", text: "\r" },
|
|
965
|
+
{ type: "keyUp", key: "Enter", code: "Enter", windowsVirtualKeyCode: 13 }
|
|
966
|
+
);
|
|
967
|
+
continue;
|
|
968
|
+
}
|
|
969
|
+
events.push(
|
|
970
|
+
{ type: "rawKeyDown", key: char, text: char, unmodifiedText: char },
|
|
971
|
+
{ type: "char", text: char },
|
|
972
|
+
{ type: "keyUp", key: char }
|
|
973
|
+
);
|
|
974
|
+
}
|
|
975
|
+
return events;
|
|
976
|
+
}
|
|
977
|
+
function isMouseEvent(method) {
|
|
978
|
+
return method === "Input.dispatchMouseEvent";
|
|
979
|
+
}
|
|
980
|
+
var humanizeTransformRule = {
|
|
981
|
+
id: "humanize-transform",
|
|
982
|
+
name: "Humanize Trusted Input Transform",
|
|
983
|
+
priority: 45,
|
|
984
|
+
canHandle(ctx) {
|
|
985
|
+
return isMouseEvent(ctx.method) || ctx.method === "Input.insertText";
|
|
986
|
+
},
|
|
987
|
+
evaluate(ctx) {
|
|
988
|
+
if (ctx.method === "Input.insertText") return this.transformInsertText(ctx);
|
|
989
|
+
return this.transformMouseEvent(ctx);
|
|
990
|
+
},
|
|
991
|
+
transformMouseEvent(ctx) {
|
|
992
|
+
const params = ctx.params;
|
|
993
|
+
if (params.type !== "mouseMoved" || typeof params.x !== "number" || typeof params.y !== "number") {
|
|
994
|
+
const x = params.x;
|
|
995
|
+
const y = params.y;
|
|
996
|
+
if (typeof x === "number" && typeof y === "number") {
|
|
997
|
+
ctx.sessionState.set(CURSOR_KEY, { x, y });
|
|
998
|
+
}
|
|
999
|
+
return null;
|
|
1000
|
+
}
|
|
1001
|
+
const cursor = ctx.sessionState.get(CURSOR_KEY) ?? { x: 0, y: 0 };
|
|
1002
|
+
const jump = Math.hypot(params.x - cursor.x, params.y - cursor.y);
|
|
1003
|
+
ctx.sessionState.set(CURSOR_KEY, { x: params.x, y: params.y });
|
|
1004
|
+
if (jump < 32) return null;
|
|
1005
|
+
const path = humanMousePath(cursor.x, cursor.y, params.x, params.y);
|
|
1006
|
+
return {
|
|
1007
|
+
ruleId: this.id,
|
|
1008
|
+
action: "transform",
|
|
1009
|
+
severity: "info",
|
|
1010
|
+
reason: `Expanded instant mouse jump of ${jump.toFixed(0)}px into ${path.length} trusted bezier moves.`,
|
|
1011
|
+
suggestion: "Use page.mouse.move with steps for explicit control; this transform preserves isTrusted=true.",
|
|
1012
|
+
transformedParams: { __sequence: path.map((point) => ({
|
|
1013
|
+
method: "Input.dispatchMouseEvent",
|
|
1014
|
+
params: { type: "mouseMoved", x: point.x, y: point.y, button: params.button ?? "none" },
|
|
1015
|
+
delayMs: point.delay
|
|
1016
|
+
})) }
|
|
1017
|
+
};
|
|
1018
|
+
},
|
|
1019
|
+
transformInsertText(ctx) {
|
|
1020
|
+
const params = ctx.params;
|
|
1021
|
+
const text = params.text ?? "";
|
|
1022
|
+
if (!text) return null;
|
|
1023
|
+
const timing = ctx.sessionState.get(KEYS_KEY) ?? { lastDelay: TYPE_DELAYS[1] };
|
|
1024
|
+
const bucket = TYPE_DELAYS[Math.floor(Math.random() * TYPE_DELAYS.length)];
|
|
1025
|
+
const events = characterKeyEvents(text).map((event, index) => ({
|
|
1026
|
+
method: "Input.dispatchKeyEvent",
|
|
1027
|
+
params: event,
|
|
1028
|
+
delayMs: index === 0 ? 0 : Math.max(24, Math.round(bucket + rand(-bucket * 0.45, bucket * 0.55)))
|
|
1029
|
+
}));
|
|
1030
|
+
timing.lastDelay = bucket;
|
|
1031
|
+
ctx.sessionState.set(KEYS_KEY, timing);
|
|
1032
|
+
return {
|
|
1033
|
+
ruleId: this.id,
|
|
1034
|
+
action: "transform",
|
|
1035
|
+
severity: "info",
|
|
1036
|
+
reason: `Expanded Input.insertText (${text.length} chars) into ${events.length} trusted key events with variable rhythm.`,
|
|
1037
|
+
suggestion: "Use page.type for explicit control; this transform preserves the native keyboard command stream.",
|
|
1038
|
+
transformedParams: { __sequence: events }
|
|
1039
|
+
};
|
|
1040
|
+
}
|
|
1041
|
+
};
|
|
1042
|
+
|
|
900
1043
|
// src/cdp-interceptor/rules-engine.ts
|
|
901
1044
|
var BUILTIN_RULES = [
|
|
902
1045
|
domMutationRule,
|
|
@@ -905,6 +1048,7 @@ var BUILTIN_RULES = [
|
|
|
905
1048
|
eventSimulationRule,
|
|
906
1049
|
mouseTrajectoryRule,
|
|
907
1050
|
inputKeystrokeRule,
|
|
1051
|
+
humanizeTransformRule,
|
|
908
1052
|
emulationOverrideRule,
|
|
909
1053
|
networkAnomalyRule,
|
|
910
1054
|
pageLifecycleRule
|
|
@@ -937,8 +1081,10 @@ function createRuleEngine(customRules) {
|
|
|
937
1081
|
if (isProbeMarked(code)) return null;
|
|
938
1082
|
} catch {
|
|
939
1083
|
}
|
|
1084
|
+
const humanizeEnabled = process.env.XBROWSER_HUMANIZE_CDP === "on";
|
|
940
1085
|
for (const rule of rules) {
|
|
941
1086
|
if (rule.canHandle && !rule.canHandle(fullCtx)) continue;
|
|
1087
|
+
if (rule.id === "humanize-transform" && !humanizeEnabled) continue;
|
|
942
1088
|
const decision = rule.evaluate(fullCtx);
|
|
943
1089
|
if (!decision) continue;
|
|
944
1090
|
if (decision.action !== "pass") return decision;
|
|
@@ -47,7 +47,8 @@ var ScreencastCapturer = class {
|
|
|
47
47
|
if (!cb) return;
|
|
48
48
|
cdp.send("Page.screencastFrameAck", { sessionId: params.sessionId }).catch(() => {
|
|
49
49
|
});
|
|
50
|
-
const
|
|
50
|
+
const logicalViewport = page.viewportSize();
|
|
51
|
+
const viewport = logicalViewport ?? {
|
|
51
52
|
width: params.metadata?.deviceWidth || this.maxWidth,
|
|
52
53
|
height: params.metadata?.deviceHeight || this.maxHeight
|
|
53
54
|
};
|