@skrillex1224/playwright-toolkit 2.0.75 → 2.0.76
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/dist/index.cjs +86 -75
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +86 -75
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1109,82 +1109,86 @@ var Sse = {
|
|
|
1109
1109
|
overallTimer = null;
|
|
1110
1110
|
};
|
|
1111
1111
|
const workPromise = new Promise(async (resolve, reject) => {
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1112
|
+
try {
|
|
1113
|
+
await page.route(urlPattern, async (route) => {
|
|
1114
|
+
const request = route.request();
|
|
1115
|
+
logger8.info(`[MITM] \u5DF2\u62E6\u622A\u8BF7\u6C42: ${request.url()}`);
|
|
1116
|
+
try {
|
|
1117
|
+
const headers = await request.allHeaders();
|
|
1118
|
+
const postData = request.postData();
|
|
1119
|
+
const urlObj = new import_url.URL(request.url());
|
|
1120
|
+
delete headers["accept-encoding"];
|
|
1121
|
+
delete headers["content-length"];
|
|
1122
|
+
const req = import_https.default.request({
|
|
1123
|
+
hostname: urlObj.hostname,
|
|
1124
|
+
port: 443,
|
|
1125
|
+
path: urlObj.pathname + urlObj.search,
|
|
1126
|
+
method: request.method(),
|
|
1127
|
+
headers,
|
|
1128
|
+
timeout
|
|
1129
|
+
}, (res) => {
|
|
1130
|
+
const chunks = [];
|
|
1131
|
+
let accumulatedText = "";
|
|
1132
|
+
res.on("data", (chunk) => {
|
|
1133
|
+
if (!hasReceivedInitialData) {
|
|
1134
|
+
hasReceivedInitialData = true;
|
|
1135
|
+
if (initialTimer) {
|
|
1136
|
+
clearTimeout(initialTimer);
|
|
1137
|
+
initialTimer = null;
|
|
1138
|
+
}
|
|
1139
|
+
logger8.debug("[Intercept] \u5DF2\u63A5\u6536\u521D\u59CB\u6570\u636E");
|
|
1140
|
+
}
|
|
1141
|
+
chunks.push(chunk);
|
|
1142
|
+
const textChunk = chunk.toString("utf-8");
|
|
1143
|
+
accumulatedText += textChunk;
|
|
1144
|
+
if (onData) {
|
|
1145
|
+
try {
|
|
1146
|
+
onData(textChunk, resolve, accumulatedText);
|
|
1147
|
+
} catch (e) {
|
|
1148
|
+
logger8.fail(`onData \u9519\u8BEF`, e);
|
|
1149
|
+
}
|
|
1139
1150
|
}
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
+
});
|
|
1152
|
+
res.on("end", () => {
|
|
1153
|
+
logger8.info("[MITM] \u4E0A\u6E38\u54CD\u5E94\u7ED3\u675F");
|
|
1154
|
+
clearAllTimers();
|
|
1155
|
+
if (onEnd) {
|
|
1156
|
+
try {
|
|
1157
|
+
onEnd(accumulatedText, resolve);
|
|
1158
|
+
} catch (e) {
|
|
1159
|
+
logger8.fail(`onEnd \u9519\u8BEF`, e);
|
|
1160
|
+
}
|
|
1161
|
+
} else if (!onData) {
|
|
1162
|
+
resolve(accumulatedText);
|
|
1151
1163
|
}
|
|
1152
|
-
|
|
1164
|
+
route.fulfill({
|
|
1165
|
+
status: res.statusCode,
|
|
1166
|
+
headers: res.headers,
|
|
1167
|
+
body: Buffer.concat(chunks)
|
|
1168
|
+
}).catch(() => {
|
|
1169
|
+
});
|
|
1170
|
+
});
|
|
1153
1171
|
});
|
|
1154
|
-
|
|
1155
|
-
logger8.info("[MITM] \u4E0A\u6E38\u54CD\u5E94\u7ED3\u675F (Stream End)");
|
|
1172
|
+
req.on("error", (e) => {
|
|
1156
1173
|
clearAllTimers();
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
onEnd(accumulatedText, resolve);
|
|
1161
|
-
} catch (e) {
|
|
1162
|
-
logger8.fail(`onEnd callback error: ${e.message}`, e);
|
|
1163
|
-
}
|
|
1164
|
-
} else if (!onData) {
|
|
1165
|
-
resolve(accumulatedText);
|
|
1166
|
-
}
|
|
1167
|
-
route.fulfill({
|
|
1168
|
-
status: res.statusCode,
|
|
1169
|
-
headers: res.headers,
|
|
1170
|
-
body: fullBody
|
|
1171
|
-
}).catch((e) => logger8.warn(`Route fulfill failed: ${e.message}`));
|
|
1174
|
+
route.abort().catch(() => {
|
|
1175
|
+
});
|
|
1176
|
+
reject(e);
|
|
1172
1177
|
});
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1178
|
+
if (postData) req.write(postData);
|
|
1179
|
+
req.end();
|
|
1180
|
+
} catch (e) {
|
|
1176
1181
|
clearAllTimers();
|
|
1177
|
-
route.
|
|
1182
|
+
route.continue().catch(() => {
|
|
1183
|
+
});
|
|
1178
1184
|
reject(e);
|
|
1179
|
-
}
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
}
|
|
1187
|
-
});
|
|
1185
|
+
}
|
|
1186
|
+
});
|
|
1187
|
+
} catch (e) {
|
|
1188
|
+
reject(e);
|
|
1189
|
+
}
|
|
1190
|
+
});
|
|
1191
|
+
workPromise.catch(() => {
|
|
1188
1192
|
});
|
|
1189
1193
|
const timeoutPromise = new Promise((_, reject) => {
|
|
1190
1194
|
initialTimer = setTimeout(() => {
|
|
@@ -1192,9 +1196,12 @@ var Sse = {
|
|
|
1192
1196
|
const error = new InitialTimeoutError(initialTimeout);
|
|
1193
1197
|
clearAllTimers();
|
|
1194
1198
|
if (onTimeout) {
|
|
1195
|
-
|
|
1199
|
+
try {
|
|
1200
|
+
onTimeout(error, reject);
|
|
1201
|
+
} catch (e) {
|
|
1202
|
+
reject(e);
|
|
1203
|
+
}
|
|
1196
1204
|
} else {
|
|
1197
|
-
logger8.fail(`[Intercept] \u521D\u59CB\u6570\u636E\u63A5\u6536\u8D85\u65F6`, error);
|
|
1198
1205
|
reject(error);
|
|
1199
1206
|
}
|
|
1200
1207
|
}
|
|
@@ -1203,15 +1210,19 @@ var Sse = {
|
|
|
1203
1210
|
const error = new OverallTimeoutError(timeout);
|
|
1204
1211
|
clearAllTimers();
|
|
1205
1212
|
if (onTimeout) {
|
|
1206
|
-
|
|
1213
|
+
try {
|
|
1214
|
+
onTimeout(error, reject);
|
|
1215
|
+
} catch (e) {
|
|
1216
|
+
reject(e);
|
|
1217
|
+
}
|
|
1207
1218
|
} else {
|
|
1208
|
-
logger8.fail(`[Intercept] \u6574\u4F53\u8BF7\u6C42\u8D85\u65F6`, error);
|
|
1209
1219
|
reject(error);
|
|
1210
1220
|
}
|
|
1211
1221
|
}, timeout);
|
|
1212
1222
|
});
|
|
1213
|
-
|
|
1214
|
-
|
|
1223
|
+
timeoutPromise.catch(() => {
|
|
1224
|
+
});
|
|
1225
|
+
return Promise.race([workPromise, timeoutPromise]);
|
|
1215
1226
|
}
|
|
1216
1227
|
};
|
|
1217
1228
|
|