@iflyrpa/actions 2.0.0-beta.2 → 2.0.0-beta.3
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/actions/douyinGetHot/index.d.ts +1 -0
- package/dist/actions/douyinGetMusicByCategory/schema.d.ts +2 -2
- package/dist/actions/douyinGetMusicCategory/schema.d.ts +1 -1
- package/dist/actions/douyinLogin/rpa.d.ts +2 -0
- package/dist/actions/douyinPublish/index.d.ts +9 -2
- package/dist/bundle.js +327 -56
- package/dist/bundle.js.map +1 -1
- package/dist/index.js +327 -56
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +327 -56
- package/dist/index.mjs.map +1 -1
- package/dist/utils/proxy.d.ts +1 -1
- package/package.json +1 -1
|
@@ -27,8 +27,8 @@ export declare const DouyinGetMusicByCategoryParamsSchema: z.ZodObject<{
|
|
|
27
27
|
huiwenToken: z.ZodOptional<z.ZodString>;
|
|
28
28
|
articleId: z.ZodOptional<z.ZodString>;
|
|
29
29
|
saveType: z.ZodOptional<z.ZodString>;
|
|
30
|
-
category_id: z.
|
|
31
|
-
type: z.
|
|
30
|
+
category_id: z.ZodString;
|
|
31
|
+
type: z.ZodString;
|
|
32
32
|
count: z.ZodOptional<z.ZodNumber>;
|
|
33
33
|
}, z.core.$strip>;
|
|
34
34
|
export type DouyinGetMusicByCategoryParams = z.infer<typeof DouyinGetMusicByCategoryParamsSchema>;
|
|
@@ -27,7 +27,7 @@ export declare const DouyinGetMusicParamsSchema: z.ZodObject<{
|
|
|
27
27
|
huiwenToken: z.ZodOptional<z.ZodString>;
|
|
28
28
|
articleId: z.ZodOptional<z.ZodString>;
|
|
29
29
|
saveType: z.ZodOptional<z.ZodString>;
|
|
30
|
-
keyword: z.
|
|
30
|
+
keyword: z.ZodString;
|
|
31
31
|
count: z.ZodOptional<z.ZodNumber>;
|
|
32
32
|
}, z.core.$strip>;
|
|
33
33
|
export type DouyinGetMusicParams = z.infer<typeof DouyinGetMusicParamsSchema>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CommonAction } from "@iflyrpa/share";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
+
import { Collection } from "../douyinGetCollection/index";
|
|
3
4
|
export declare const DouyinPublishParamsSchema: z.ZodObject<{
|
|
4
5
|
id: z.ZodOptional<z.ZodString>;
|
|
5
6
|
userAgent: z.ZodOptional<z.ZodString>;
|
|
@@ -31,6 +32,13 @@ export declare const DouyinPublishParamsSchema: z.ZodObject<{
|
|
|
31
32
|
content: z.ZodString;
|
|
32
33
|
coverImage: z.ZodOptional<z.ZodString>;
|
|
33
34
|
videoFile: z.ZodOptional<z.ZodString>;
|
|
35
|
+
musicId: z.ZodString;
|
|
36
|
+
musicDuration: z.ZodOptional<z.ZodNumber>;
|
|
37
|
+
textExtra: z.ZodString;
|
|
38
|
+
challengeIds: z.ZodString;
|
|
39
|
+
hashtagSource: z.ZodString;
|
|
40
|
+
hotSentence: z.ZodString;
|
|
41
|
+
mix: z.ZodOptional<z.ZodCustom<Collection, Collection>>;
|
|
34
42
|
address: z.ZodOptional<z.ZodObject<{
|
|
35
43
|
id: z.ZodString;
|
|
36
44
|
name: z.ZodString;
|
|
@@ -82,8 +90,7 @@ export declare const DouyinPublishParamsSchema: z.ZodObject<{
|
|
|
82
90
|
isImmediatelyPublish: z.ZodOptional<z.ZodBoolean>;
|
|
83
91
|
scheduledPublish: z.ZodOptional<z.ZodString>;
|
|
84
92
|
isOriginal: z.ZodOptional<z.ZodBoolean>;
|
|
85
|
-
|
|
86
|
-
allowCopy: z.ZodOptional<z.ZodBoolean>;
|
|
93
|
+
allowSave: z.ZodOptional<z.ZodBoolean>;
|
|
87
94
|
publishType: z.ZodOptional<z.ZodEnum<{
|
|
88
95
|
1: "1";
|
|
89
96
|
2: "2";
|
package/dist/bundle.js
CHANGED
|
@@ -8238,7 +8238,7 @@ var __webpack_exports__ = {};
|
|
|
8238
8238
|
origin: ()=>utils_origin
|
|
8239
8239
|
});
|
|
8240
8240
|
var package_namespaceObject = JSON.parse('{"i8":"0.0.18-beta.0"}');
|
|
8241
|
-
var package_namespaceObject_0 = JSON.parse('{"i8":"2.0.0-beta.
|
|
8241
|
+
var package_namespaceObject_0 = JSON.parse('{"i8":"2.0.0-beta.2"}');
|
|
8242
8242
|
const external_node_fs_namespaceObject = require("node:fs");
|
|
8243
8243
|
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
8244
8244
|
const external_node_https_namespaceObject = require("node:https");
|
|
@@ -22738,7 +22738,7 @@ var __webpack_exports__ = {};
|
|
|
22738
22738
|
axios.default = axios;
|
|
22739
22739
|
const lib_axios = axios;
|
|
22740
22740
|
var dist = __webpack_require__("../../node_modules/.pnpm/https-proxy-agent@7.0.6/node_modules/https-proxy-agent/dist/index.js");
|
|
22741
|
-
async function ProxyAgent(ip, adr, accountId, refresh) {
|
|
22741
|
+
async function ProxyAgent(task, ip, adr, accountId, refresh) {
|
|
22742
22742
|
const http = new Http({
|
|
22743
22743
|
headers: {
|
|
22744
22744
|
"content-type": "application/json"
|
|
@@ -22764,7 +22764,7 @@ var __webpack_exports__ = {};
|
|
|
22764
22764
|
data: ProxyInfo.data
|
|
22765
22765
|
}
|
|
22766
22766
|
};
|
|
22767
|
-
|
|
22767
|
+
task.logger?.info(`请求代理:区域:${params.addr}, IP:${params.ip}, AccountId:${params.accountId}, 返回代理信息: ${ProxyInfo.data ? `${ProxyInfo.data.proxyIp}:${ProxyInfo.data.proxyPort}` : "无可用代理"}`, loggerInfo);
|
|
22768
22768
|
return "000000" === ProxyInfo.code && ProxyInfo.data ? {
|
|
22769
22769
|
ip: ProxyInfo.data.proxyIp,
|
|
22770
22770
|
port: ProxyInfo.data.proxyPort,
|
|
@@ -22786,7 +22786,7 @@ var __webpack_exports__ = {};
|
|
|
22786
22786
|
...config
|
|
22787
22787
|
});
|
|
22788
22788
|
this.logger = logger;
|
|
22789
|
-
if (ip) this.agentPromise = ProxyAgent
|
|
22789
|
+
if (ip) this.agentPromise = ProxyAgent({
|
|
22790
22790
|
logger
|
|
22791
22791
|
}, ip, adr, accountId);
|
|
22792
22792
|
this.addResponseInterceptor(()=>void 0);
|
|
@@ -27832,10 +27832,9 @@ var __webpack_exports__ = {};
|
|
|
27832
27832
|
params.accountId
|
|
27833
27833
|
];
|
|
27834
27834
|
task.logger?.info(`==> 开始获取代理信息:${args}`);
|
|
27835
|
-
const
|
|
27835
|
+
const ProxyAgentResult = await ProxyAgent({
|
|
27836
27836
|
logger: task.logger
|
|
27837
|
-
});
|
|
27838
|
-
const ProxyAgentResult = await ProxyAgentWithLogger(...args);
|
|
27837
|
+
}, ...args);
|
|
27839
27838
|
task.logger?.info("==> 代理信息获取成功!");
|
|
27840
27839
|
proxyUrl = ProxyAgentResult ? `http://${ProxyAgentResult.ip}:${ProxyAgentResult.port}` : void 0;
|
|
27841
27840
|
}
|
|
@@ -29989,7 +29988,7 @@ var __webpack_exports__ = {};
|
|
|
29989
29988
|
const http = new Http(...args);
|
|
29990
29989
|
const hotParams = {
|
|
29991
29990
|
query: params.query || "",
|
|
29992
|
-
count: "
|
|
29991
|
+
count: params.count?.toString() || "20",
|
|
29993
29992
|
aid: "1128",
|
|
29994
29993
|
cookie_enabled: "0",
|
|
29995
29994
|
screen_width: "1920",
|
|
@@ -30006,11 +30005,17 @@ var __webpack_exports__ = {};
|
|
|
30006
30005
|
};
|
|
30007
30006
|
const aBogus = douyinGetHot_sign_reply(hotParams, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36");
|
|
30008
30007
|
hotParams.a_bogus = aBogus;
|
|
30008
|
+
if (!params.query) {
|
|
30009
|
+
delete hotParams.query;
|
|
30010
|
+
delete hotParams.count;
|
|
30011
|
+
}
|
|
30009
30012
|
const queryString = new URLSearchParams(hotParams).toString();
|
|
30010
30013
|
console.log("抖音获取热点参数:", queryString);
|
|
30014
|
+
const url = `https://creator.douyin.com/aweme/v1/hotspot/${params.query ? "search" : "recommend"}/?${queryString}`;
|
|
30015
|
+
console.log("抖音获取热点URL:", url);
|
|
30011
30016
|
const res = await http.api({
|
|
30012
30017
|
method: "get",
|
|
30013
|
-
url
|
|
30018
|
+
url,
|
|
30014
30019
|
headers: {
|
|
30015
30020
|
...headers,
|
|
30016
30021
|
"Content-Type": "application/json"
|
|
@@ -30023,8 +30028,8 @@ var __webpack_exports__ = {};
|
|
|
30023
30028
|
const isSuccess = 0 === res.status_code;
|
|
30024
30029
|
const message = `抖音获取热点${isSuccess ? "成功" : `失败,原因:${res.status_msg}`}${_task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
30025
30030
|
const data = isSuccess ? {
|
|
30026
|
-
hot: res?.sentences || [],
|
|
30027
|
-
total: res?.sentences?.length || 0
|
|
30031
|
+
hot: res?.sentences || res?.all_sentences || [],
|
|
30032
|
+
total: (res?.sentences || res?.all_sentences)?.length || 0
|
|
30028
30033
|
} : {
|
|
30029
30034
|
hot: [],
|
|
30030
30035
|
total: 0
|
|
@@ -30209,8 +30214,8 @@ var __webpack_exports__ = {};
|
|
|
30209
30214
|
return utils_response(isSuccess ? 0 : 414, message, data);
|
|
30210
30215
|
};
|
|
30211
30216
|
const DouyinGetMusicByCategoryParamsSchema = ActionCommonParamsSchema.extend({
|
|
30212
|
-
category_id: classic_schemas_string()
|
|
30213
|
-
type: classic_schemas_string()
|
|
30217
|
+
category_id: classic_schemas_string(),
|
|
30218
|
+
type: classic_schemas_string(),
|
|
30214
30219
|
count: classic_schemas_number().optional()
|
|
30215
30220
|
});
|
|
30216
30221
|
const { sign_datail: douyinGetMusicByCategory_sign_datail, sign_reply: douyinGetMusicByCategory_sign_reply } = __webpack_require__("./src/utils/douyin/douyin.js");
|
|
@@ -30357,7 +30362,7 @@ var __webpack_exports__ = {};
|
|
|
30357
30362
|
params.accountId
|
|
30358
30363
|
];
|
|
30359
30364
|
const http = new Http(...args);
|
|
30360
|
-
const keyword = params.keyword || "";
|
|
30365
|
+
const keyword = params.keyword || "热点";
|
|
30361
30366
|
const topicParams = {
|
|
30362
30367
|
keyword: keyword,
|
|
30363
30368
|
source: "challenge_create",
|
|
@@ -30403,6 +30408,272 @@ var __webpack_exports__ = {};
|
|
|
30403
30408
|
};
|
|
30404
30409
|
return utils_response(isSuccess ? 0 : 414, message, data);
|
|
30405
30410
|
};
|
|
30411
|
+
const rpa_scanRetryMaxCount = 60;
|
|
30412
|
+
const rpa_waitQrcodeResultMaxTime = 2000 * rpa_scanRetryMaxCount;
|
|
30413
|
+
const douyinLogin_rpa_rpaAction = async (task, params)=>{
|
|
30414
|
+
const reporter = task.reportService?.reportLoginStatus ?? (()=>Promise.resolve());
|
|
30415
|
+
let page;
|
|
30416
|
+
let statusMachine = "new";
|
|
30417
|
+
let isSelfClosing = false;
|
|
30418
|
+
try {
|
|
30419
|
+
page = await task.createPage({
|
|
30420
|
+
url: "https://creator.douyin.com/"
|
|
30421
|
+
});
|
|
30422
|
+
if (!task._session?.id) throw new Error("Session ID 不存在");
|
|
30423
|
+
task._steelBrowser?.on("disconnected", ()=>{
|
|
30424
|
+
if (task.debug && isSelfClosing) task.logger.info("执行结束,关闭浏览器!");
|
|
30425
|
+
else task.logger.info("浏览器被手动释放或意外关闭!");
|
|
30426
|
+
});
|
|
30427
|
+
} catch (e) {
|
|
30428
|
+
task.logger.error("浏览器启动失败", e);
|
|
30429
|
+
return {
|
|
30430
|
+
code: 500,
|
|
30431
|
+
message: `浏览器启动失败: ${e}`,
|
|
30432
|
+
data: {}
|
|
30433
|
+
};
|
|
30434
|
+
}
|
|
30435
|
+
await page.route("**/*.mp4", (route)=>route.abort());
|
|
30436
|
+
await page.route("**/*.png", (route)=>route.abort());
|
|
30437
|
+
await page.route("**/*.ttf", (route)=>route.abort());
|
|
30438
|
+
await page.addInitScript(()=>{
|
|
30439
|
+
window.requestAnimationFrame = ()=>0;
|
|
30440
|
+
});
|
|
30441
|
+
await page.addInitScript(()=>{
|
|
30442
|
+
const removeEventBlockers = ()=>{
|
|
30443
|
+
try {
|
|
30444
|
+
const blockers = document.querySelectorAll('[style*="pointer-events: none"]');
|
|
30445
|
+
blockers.forEach((el)=>{
|
|
30446
|
+
el.style.pointerEvents = "auto";
|
|
30447
|
+
});
|
|
30448
|
+
document.body.style.pointerEvents = "auto";
|
|
30449
|
+
if (window.__DOUYIN_ANTI_DEBUG__) delete window.__DOUYIN_ANTI_DEBUG__;
|
|
30450
|
+
} catch (e) {}
|
|
30451
|
+
};
|
|
30452
|
+
removeEventBlockers();
|
|
30453
|
+
setInterval(removeEventBlockers, 1000);
|
|
30454
|
+
if ("undefined" != typeof MutationObserver) {
|
|
30455
|
+
const observer = new MutationObserver(removeEventBlockers);
|
|
30456
|
+
observer.observe(document.documentElement, {
|
|
30457
|
+
childList: true,
|
|
30458
|
+
subtree: true,
|
|
30459
|
+
attributes: true,
|
|
30460
|
+
attributeFilter: [
|
|
30461
|
+
"style"
|
|
30462
|
+
]
|
|
30463
|
+
});
|
|
30464
|
+
}
|
|
30465
|
+
});
|
|
30466
|
+
task.logger.info("页面创建成功,开始Bypass页面事件屏蔽...");
|
|
30467
|
+
try {
|
|
30468
|
+
await page.waitForResponse((response)=>response.url().includes("/272.6591d0af.js") && 200 === response.status(), {
|
|
30469
|
+
timeout: 15000
|
|
30470
|
+
});
|
|
30471
|
+
await page.waitForLoadState("networkidle");
|
|
30472
|
+
await page.goto("about:blank");
|
|
30473
|
+
await page.goBack({
|
|
30474
|
+
waitUntil: "domcontentloaded"
|
|
30475
|
+
});
|
|
30476
|
+
task.logger.info("已返回登录页面,页面事件屏蔽Bypass完成...");
|
|
30477
|
+
} catch (e) {
|
|
30478
|
+
task.logger.warn("Bypass 超时,继续执行...", {
|
|
30479
|
+
error: e
|
|
30480
|
+
});
|
|
30481
|
+
}
|
|
30482
|
+
await page.waitForTimeout(2000);
|
|
30483
|
+
try {
|
|
30484
|
+
const loginButtonSelector = ".douyin-creator-master-icon-default.douyin-creator-master-icon-user_circle";
|
|
30485
|
+
await page.waitForSelector(loginButtonSelector, {
|
|
30486
|
+
state: "visible",
|
|
30487
|
+
timeout: 10000
|
|
30488
|
+
});
|
|
30489
|
+
const clicked = await page.evaluate((selector)=>{
|
|
30490
|
+
const btn = document.querySelector(selector);
|
|
30491
|
+
if (btn) {
|
|
30492
|
+
btn.click();
|
|
30493
|
+
return true;
|
|
30494
|
+
}
|
|
30495
|
+
return false;
|
|
30496
|
+
}, loginButtonSelector);
|
|
30497
|
+
if (clicked) task.logger.info("✅ 登录按钮点击成功(使用 JavaScript)");
|
|
30498
|
+
else {
|
|
30499
|
+
await page.locator(loginButtonSelector).click({
|
|
30500
|
+
force: true,
|
|
30501
|
+
timeout: 5000
|
|
30502
|
+
});
|
|
30503
|
+
task.logger.info("✅ 登录按钮点击成功(使用 Playwright force)");
|
|
30504
|
+
}
|
|
30505
|
+
} catch (e) {
|
|
30506
|
+
task.logger.error("❌ 点击登录按钮失败", e);
|
|
30507
|
+
return {
|
|
30508
|
+
code: 500,
|
|
30509
|
+
message: "无法点击登录按钮,页面可能已被屏蔽",
|
|
30510
|
+
data: {}
|
|
30511
|
+
};
|
|
30512
|
+
}
|
|
30513
|
+
await page.waitForTimeout(3000);
|
|
30514
|
+
const pageInfo = await task._client?.sessions.liveDetails(task._session.id);
|
|
30515
|
+
const pageId = pageInfo?.pages[0].id ?? "";
|
|
30516
|
+
const baseHost = task._session.websocketUrl?.replace(/^wss?:\/\//, "") ?? "";
|
|
30517
|
+
const debugParams = new URLSearchParams({
|
|
30518
|
+
baseHost,
|
|
30519
|
+
pageId
|
|
30520
|
+
});
|
|
30521
|
+
const connectAddress = debugParams.toString();
|
|
30522
|
+
task.reportService?.settingSessionID?.(task._session?.id || "");
|
|
30523
|
+
task.logger.info("🔗 远程调试地址已生成,现在可以安全访问远程页面");
|
|
30524
|
+
await reporter(0, "浏览器启动成功,请使用抖音App扫码登录......", {
|
|
30525
|
+
connectAddress
|
|
30526
|
+
});
|
|
30527
|
+
const userInfo = {
|
|
30528
|
+
uniqueId: "",
|
|
30529
|
+
avatar: "",
|
|
30530
|
+
name: ""
|
|
30531
|
+
};
|
|
30532
|
+
try {
|
|
30533
|
+
await new Promise((resolve, reject)=>{
|
|
30534
|
+
let finished = false;
|
|
30535
|
+
const timer = setTimeout(()=>{
|
|
30536
|
+
cleanup(statusMachine);
|
|
30537
|
+
}, rpa_waitQrcodeResultMaxTime);
|
|
30538
|
+
const cleanup = (status)=>{
|
|
30539
|
+
if (finished) return;
|
|
30540
|
+
finished = true;
|
|
30541
|
+
clearTimeout(timer);
|
|
30542
|
+
page.off("response", handleWebCommon);
|
|
30543
|
+
page.off("response", handleCheckQR);
|
|
30544
|
+
if (void 0 !== status) reject(status);
|
|
30545
|
+
};
|
|
30546
|
+
const handleWebCommon = async (resp)=>{
|
|
30547
|
+
try {
|
|
30548
|
+
const url = resp.url();
|
|
30549
|
+
if (url.includes("/web/common")) {
|
|
30550
|
+
cleanup();
|
|
30551
|
+
const headers = resp.headers();
|
|
30552
|
+
const xmst = headers["x-ms-token"];
|
|
30553
|
+
const date = headers["x-tt-timestamp"];
|
|
30554
|
+
if (xmst && date) {
|
|
30555
|
+
const mstExpirDate = new Date(1000 * Number(date) + 604800000);
|
|
30556
|
+
const msToken = {
|
|
30557
|
+
name: "msToken",
|
|
30558
|
+
value: xmst,
|
|
30559
|
+
domain: ".bytedance.com",
|
|
30560
|
+
expires: mstExpirDate.getTime() / 1000,
|
|
30561
|
+
httpOnly: true,
|
|
30562
|
+
path: "/",
|
|
30563
|
+
sameSite: "None",
|
|
30564
|
+
secure: true
|
|
30565
|
+
};
|
|
30566
|
+
await page.context().addCookies([
|
|
30567
|
+
msToken
|
|
30568
|
+
]);
|
|
30569
|
+
task.debug && task.logger.info("msToken 添加成功");
|
|
30570
|
+
task.debug && task.logger.info("msToken 检测成功:", {
|
|
30571
|
+
token: xmst.substring(0, 20) + "...",
|
|
30572
|
+
timestamp: date
|
|
30573
|
+
});
|
|
30574
|
+
}
|
|
30575
|
+
await reporter(0, "扫码成功!", {
|
|
30576
|
+
stage: "scanQrcode",
|
|
30577
|
+
connectAddress
|
|
30578
|
+
});
|
|
30579
|
+
resolve();
|
|
30580
|
+
} else if (url.includes("aweme/v1/creator/user/info")) try {
|
|
30581
|
+
const jsonUserInfo = await resp.json();
|
|
30582
|
+
userInfo.name = jsonUserInfo.user_profile.nick_name ?? "";
|
|
30583
|
+
userInfo.avatar = jsonUserInfo.user_profile.avatar_url ?? "";
|
|
30584
|
+
task.debug && task.logger.info("用户信息获取成功", userInfo);
|
|
30585
|
+
} catch (e) {
|
|
30586
|
+
task.logger.warn("无法解析用户信息:", {
|
|
30587
|
+
url,
|
|
30588
|
+
error: e
|
|
30589
|
+
});
|
|
30590
|
+
}
|
|
30591
|
+
} catch (err) {
|
|
30592
|
+
task.logger.error("监听登录结果出现异常", err);
|
|
30593
|
+
cleanup(err);
|
|
30594
|
+
}
|
|
30595
|
+
};
|
|
30596
|
+
const handleCheckQR = async (response)=>{
|
|
30597
|
+
try {
|
|
30598
|
+
const url = response.url();
|
|
30599
|
+
if (!url.includes("/check_qrconnect")) return;
|
|
30600
|
+
let jsonResponse;
|
|
30601
|
+
try {
|
|
30602
|
+
jsonResponse = await response.json();
|
|
30603
|
+
} catch (e) {
|
|
30604
|
+
task.logger.warn("Response body unavailable (likely navigation happened)", {
|
|
30605
|
+
url
|
|
30606
|
+
});
|
|
30607
|
+
return;
|
|
30608
|
+
}
|
|
30609
|
+
const status = jsonResponse?.data?.status;
|
|
30610
|
+
task.logger.info("check_qrconnect 状态:", {
|
|
30611
|
+
status
|
|
30612
|
+
});
|
|
30613
|
+
if ("scanned" === status) {
|
|
30614
|
+
task.logger.info("用户已扫码,等待确认...");
|
|
30615
|
+
page.on("response", handleWebCommon);
|
|
30616
|
+
}
|
|
30617
|
+
if ("confirmed" === status) {
|
|
30618
|
+
userInfo.uniqueId = jsonResponse.data?.user_data?.user_id_str || "";
|
|
30619
|
+
task.logger.info("扫码确认,开始监听登录完成...");
|
|
30620
|
+
page.off("response", handleCheckQR);
|
|
30621
|
+
}
|
|
30622
|
+
statusMachine = status || "new";
|
|
30623
|
+
if ("expired" === status) {
|
|
30624
|
+
task.logger.warn("二维码已过期");
|
|
30625
|
+
cleanup("expired");
|
|
30626
|
+
}
|
|
30627
|
+
} catch (err) {
|
|
30628
|
+
task.logger.error("handleCheckQR 异常:", err);
|
|
30629
|
+
}
|
|
30630
|
+
};
|
|
30631
|
+
page.on("response", handleCheckQR);
|
|
30632
|
+
});
|
|
30633
|
+
} catch (e) {
|
|
30634
|
+
const errMap = {
|
|
30635
|
+
new: "用户扫码已超时,请重试!",
|
|
30636
|
+
scanned: "用户扫码后未点击确认,请重试!",
|
|
30637
|
+
expired: "二维码已过期,请重试!"
|
|
30638
|
+
};
|
|
30639
|
+
isSelfClosing = true;
|
|
30640
|
+
const errorMessage = "string" == typeof e && errMap[e] ? errMap[e] : e instanceof Error ? e.message : String(e);
|
|
30641
|
+
return {
|
|
30642
|
+
code: 500,
|
|
30643
|
+
message: errorMessage,
|
|
30644
|
+
data: {
|
|
30645
|
+
stage: "scanQrcode",
|
|
30646
|
+
connectAddress
|
|
30647
|
+
}
|
|
30648
|
+
};
|
|
30649
|
+
}
|
|
30650
|
+
let securityData = {};
|
|
30651
|
+
try {
|
|
30652
|
+
securityData = await page.evaluate(()=>({
|
|
30653
|
+
"security-sdk/s_sdk_pri_key": localStorage.getItem("security-sdk/s_sdk_pri_key") || "",
|
|
30654
|
+
"security-sdk/s_sdk_pub_key": localStorage.getItem("security-sdk/s_sdk_pub_key") || "",
|
|
30655
|
+
"security-sdk/s_sdk_sign_data_key": localStorage.getItem("security-sdk/s_sdk_sign_data_key/web_protect") || ""
|
|
30656
|
+
}));
|
|
30657
|
+
task.debug && task.logger.info("Security SDK 数据提取成功:", {
|
|
30658
|
+
"security-sdk/s_sdk_pri_key": !!securityData["security-sdk/s_sdk_pri_key"],
|
|
30659
|
+
"security-sdk/s_sdk_pub_key": !!securityData["security-sdk/s_sdk_pub_key"],
|
|
30660
|
+
"security-sdk/s_sdk_sign_data_key": !!securityData["security-sdk/s_sdk_sign_data_key"]
|
|
30661
|
+
});
|
|
30662
|
+
} catch (error) {
|
|
30663
|
+
task.logger.warn("提取 Security SDK 数据失败:", {
|
|
30664
|
+
error: error instanceof Error ? error.message : String(error)
|
|
30665
|
+
});
|
|
30666
|
+
}
|
|
30667
|
+
const cookie = JSON.stringify(await task._steelBrowserContext?.cookies());
|
|
30668
|
+
isSelfClosing = true;
|
|
30669
|
+
await page.close();
|
|
30670
|
+
return success({
|
|
30671
|
+
connectAddress,
|
|
30672
|
+
cookie,
|
|
30673
|
+
userInfo,
|
|
30674
|
+
...securityData
|
|
30675
|
+
}, "登陆成功!");
|
|
30676
|
+
};
|
|
30406
30677
|
const douyinLogin_rpa_server_scanRetryMaxCount = 60;
|
|
30407
30678
|
const douyinLogin_rpa_server_waitQrcodeResultMaxTime = 2000 * douyinLogin_rpa_server_scanRetryMaxCount;
|
|
30408
30679
|
const rpa_server_rpaServer = async (task, params)=>{
|
|
@@ -30416,10 +30687,9 @@ var __webpack_exports__ = {};
|
|
|
30416
30687
|
params.accountId
|
|
30417
30688
|
];
|
|
30418
30689
|
task.logger?.info(`==> 开始获取代理信息:${args}`);
|
|
30419
|
-
const
|
|
30690
|
+
const ProxyAgentResult = await ProxyAgent({
|
|
30420
30691
|
logger: task.logger
|
|
30421
|
-
});
|
|
30422
|
-
const ProxyAgentResult = await ProxyAgentWithLogger(...args);
|
|
30692
|
+
}, ...args);
|
|
30423
30693
|
task.logger?.info("==> 代理信息获取成功!");
|
|
30424
30694
|
proxyUrl = ProxyAgentResult ? `http://${ProxyAgentResult.ip}:${ProxyAgentResult.port}` : void 0;
|
|
30425
30695
|
}
|
|
@@ -30549,13 +30819,15 @@ var __webpack_exports__ = {};
|
|
|
30549
30819
|
return;
|
|
30550
30820
|
}
|
|
30551
30821
|
const status = jsonResponse?.data?.status;
|
|
30552
|
-
if ("scanned" === status)
|
|
30553
|
-
|
|
30554
|
-
|
|
30822
|
+
if ("scanned" === status) {
|
|
30823
|
+
await updateTaskState?.({
|
|
30824
|
+
state: types_TaskState.SCANNED
|
|
30825
|
+
});
|
|
30826
|
+
page.on("response", handleWebCommon);
|
|
30827
|
+
}
|
|
30555
30828
|
if ("confirmed" === status) {
|
|
30556
30829
|
userInfo.uniqueId = jsonResponse.data?.user_data?.user_id_str || "";
|
|
30557
30830
|
page.off("response", handleCheckQR);
|
|
30558
|
-
page.on("response", handleWebCommon);
|
|
30559
30831
|
}
|
|
30560
30832
|
} catch (err) {
|
|
30561
30833
|
cleanup();
|
|
@@ -30647,6 +30919,7 @@ var __webpack_exports__ = {};
|
|
|
30647
30919
|
}
|
|
30648
30920
|
};
|
|
30649
30921
|
const douyinLogin = async (task, params)=>{
|
|
30922
|
+
if ("rpa" === params.actionType) return douyinLogin_rpa_rpaAction(task, params);
|
|
30650
30923
|
if ("mockApi" === params.actionType) return success({}, "暂不支持mockApi");
|
|
30651
30924
|
if ("server" === params.actionType) return rpa_server_rpaServer(task, params);
|
|
30652
30925
|
return executeAction(rpa_server_rpaServer)(task, params);
|
|
@@ -30720,32 +30993,28 @@ var __webpack_exports__ = {};
|
|
|
30720
30993
|
const publishData = {
|
|
30721
30994
|
item: {
|
|
30722
30995
|
common: {
|
|
30723
|
-
text: params.title
|
|
30724
|
-
text_extra:
|
|
30996
|
+
text: `${params.title}。${params.content}`,
|
|
30997
|
+
text_extra: params.textExtra,
|
|
30725
30998
|
activity: "[]",
|
|
30726
|
-
challenges:
|
|
30727
|
-
hashtag_source: "",
|
|
30999
|
+
challenges: params.challengeIds,
|
|
31000
|
+
hashtag_source: params.hashtagSource || "",
|
|
30728
31001
|
mentions: "[]",
|
|
30729
|
-
music_id:
|
|
30730
|
-
music_end_time: 0,
|
|
30731
|
-
hot_sentence: "",
|
|
30732
|
-
visibility_type: 0,
|
|
30733
|
-
download: 0,
|
|
30734
|
-
timing: -1,
|
|
30735
|
-
media_type: 2,
|
|
31002
|
+
music_id: params.musicId,
|
|
31003
|
+
music_end_time: 1000 * (params.musicDuration || 0),
|
|
31004
|
+
hot_sentence: params.hotSentence || "",
|
|
31005
|
+
visibility_type: params.visibleRange || 0,
|
|
31006
|
+
download: params.allowSave ? 1 : 0,
|
|
31007
|
+
timing: params.isImmediatelyPublish ? -1 : params.scheduledPublish,
|
|
31008
|
+
media_type: params.publishType || 2,
|
|
30736
31009
|
images: []
|
|
30737
31010
|
},
|
|
30738
31011
|
cover: {
|
|
30739
31012
|
poster: ""
|
|
30740
31013
|
},
|
|
30741
|
-
mix: {},
|
|
30742
|
-
anchor: {
|
|
30743
|
-
poi_name: "",
|
|
30744
|
-
poi_id: "",
|
|
30745
|
-
anchor_content: "{}"
|
|
30746
|
-
},
|
|
31014
|
+
mix: params.mix || {},
|
|
31015
|
+
anchor: {},
|
|
30747
31016
|
declare: {
|
|
30748
|
-
user_declare_info: "{}"
|
|
31017
|
+
user_declare_info: params.selfDeclaration || "{}"
|
|
30749
31018
|
}
|
|
30750
31019
|
}
|
|
30751
31020
|
};
|
|
@@ -31076,6 +31345,13 @@ var __webpack_exports__ = {};
|
|
|
31076
31345
|
content: classic_schemas_string(),
|
|
31077
31346
|
coverImage: classic_schemas_string().optional(),
|
|
31078
31347
|
videoFile: classic_schemas_string().optional(),
|
|
31348
|
+
musicId: classic_schemas_string(),
|
|
31349
|
+
musicDuration: classic_schemas_number().optional(),
|
|
31350
|
+
textExtra: classic_schemas_string(),
|
|
31351
|
+
challengeIds: classic_schemas_string(),
|
|
31352
|
+
hashtagSource: classic_schemas_string(),
|
|
31353
|
+
hotSentence: classic_schemas_string(),
|
|
31354
|
+
mix: custom().optional(),
|
|
31079
31355
|
address: classic_schemas_object({
|
|
31080
31356
|
id: classic_schemas_string(),
|
|
31081
31357
|
name: classic_schemas_string(),
|
|
@@ -31097,8 +31373,7 @@ var __webpack_exports__ = {};
|
|
|
31097
31373
|
isImmediatelyPublish: classic_schemas_boolean().optional(),
|
|
31098
31374
|
scheduledPublish: classic_schemas_string().optional(),
|
|
31099
31375
|
isOriginal: classic_schemas_boolean().optional(),
|
|
31100
|
-
|
|
31101
|
-
allowCopy: classic_schemas_boolean().optional(),
|
|
31376
|
+
allowSave: classic_schemas_boolean().optional(),
|
|
31102
31377
|
publishType: classic_schemas_enum([
|
|
31103
31378
|
"1",
|
|
31104
31379
|
"2",
|
|
@@ -32885,8 +33160,8 @@ var __webpack_exports__ = {};
|
|
|
32885
33160
|
const message = `用户文章信息获取${isSuccess ? "成功!" : "失败,请检查!"}${_task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
32886
33161
|
return utils_response(isSuccess ? 0 : 414, message, INITIAL_STATE);
|
|
32887
33162
|
};
|
|
32888
|
-
const
|
|
32889
|
-
const
|
|
33163
|
+
const toutiaoLogin_rpa_scanRetryMaxCount = 60;
|
|
33164
|
+
const toutiaoLogin_rpa_waitQrcodeResultMaxTime = 2000 * toutiaoLogin_rpa_scanRetryMaxCount;
|
|
32890
33165
|
const toutiaoLogin_rpa_rpaAction = async (task, _params)=>{
|
|
32891
33166
|
const reporter = task.reportService?.reportLoginStatus ?? (()=>Promise.resolve());
|
|
32892
33167
|
let page;
|
|
@@ -32931,7 +33206,7 @@ var __webpack_exports__ = {};
|
|
|
32931
33206
|
let finished = false;
|
|
32932
33207
|
const timer = setTimeout(()=>{
|
|
32933
33208
|
cleanup(statusMachine);
|
|
32934
|
-
},
|
|
33209
|
+
}, toutiaoLogin_rpa_waitQrcodeResultMaxTime);
|
|
32935
33210
|
const cleanup = (status)=>{
|
|
32936
33211
|
if (finished) return;
|
|
32937
33212
|
finished = true;
|
|
@@ -33030,10 +33305,9 @@ var __webpack_exports__ = {};
|
|
|
33030
33305
|
params.accountId
|
|
33031
33306
|
];
|
|
33032
33307
|
task.logger?.info(`==> 开始获取代理信息:${args}`);
|
|
33033
|
-
const
|
|
33308
|
+
const ProxyAgentResult = await ProxyAgent({
|
|
33034
33309
|
logger: task.logger
|
|
33035
|
-
});
|
|
33036
|
-
const ProxyAgentResult = await ProxyAgentWithLogger(...args);
|
|
33310
|
+
}, ...args);
|
|
33037
33311
|
task.logger?.info("==> 代理信息获取成功!");
|
|
33038
33312
|
proxyUrl = ProxyAgentResult ? `http://${ProxyAgentResult.ip}:${ProxyAgentResult.port}` : void 0;
|
|
33039
33313
|
}
|
|
@@ -34073,10 +34347,9 @@ var __webpack_exports__ = {};
|
|
|
34073
34347
|
params.accountId
|
|
34074
34348
|
];
|
|
34075
34349
|
task.logger?.info(`==> 开始获取代理信息:${args}`);
|
|
34076
|
-
const
|
|
34350
|
+
const ProxyAgentResult = await ProxyAgent({
|
|
34077
34351
|
logger: task.logger
|
|
34078
|
-
});
|
|
34079
|
-
const ProxyAgentResult = await ProxyAgentWithLogger(...args);
|
|
34352
|
+
}, ...args);
|
|
34080
34353
|
task.logger?.info("==> 代理信息获取成功!");
|
|
34081
34354
|
proxyUrl = ProxyAgentResult ? `http://${ProxyAgentResult.ip}:${ProxyAgentResult.port}` : void 0;
|
|
34082
34355
|
}
|
|
@@ -35989,10 +36262,9 @@ var __webpack_exports__ = {};
|
|
|
35989
36262
|
params.accountId
|
|
35990
36263
|
];
|
|
35991
36264
|
task.logger?.info(`==> 开始获取代理信息:${args}`);
|
|
35992
|
-
const
|
|
36265
|
+
const ProxyAgentResult = await ProxyAgent({
|
|
35993
36266
|
logger: task.logger
|
|
35994
|
-
});
|
|
35995
|
-
const ProxyAgentResult = await ProxyAgentWithLogger(...args);
|
|
36267
|
+
}, ...args);
|
|
35996
36268
|
task.logger?.info("==> 代理信息获取成功!");
|
|
35997
36269
|
proxyUrl = ProxyAgentResult ? `http://${ProxyAgentResult.ip}:${ProxyAgentResult.port}` : void 0;
|
|
35998
36270
|
}
|
|
@@ -36825,10 +37097,9 @@ var __webpack_exports__ = {};
|
|
|
36825
37097
|
params.accountId
|
|
36826
37098
|
];
|
|
36827
37099
|
task.logger?.info(`==> 开始获取代理信息:${args}`);
|
|
36828
|
-
const
|
|
37100
|
+
const ProxyAgentResult = await ProxyAgent({
|
|
36829
37101
|
logger: task.logger
|
|
36830
|
-
});
|
|
36831
|
-
const ProxyAgentResult = await ProxyAgentWithLogger(...args);
|
|
37102
|
+
}, ...args);
|
|
36832
37103
|
task.logger?.info("==> 代理信息获取成功!");
|
|
36833
37104
|
proxyUrl = ProxyAgentResult ? `http://${ProxyAgentResult.ip}:${ProxyAgentResult.port}` : void 0;
|
|
36834
37105
|
}
|