@iflyrpa/actions 2.0.0-beta.2 → 2.0.0-beta.4

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.mjs CHANGED
@@ -4946,9 +4946,9 @@ function __webpack_require__(moduleId) {
4946
4946
  return module;
4947
4947
  };
4948
4948
  })();
4949
- var package_namespaceObject = JSON.parse('{"i8":"2.0.0-beta.1"}');
4949
+ var package_namespaceObject = JSON.parse('{"i8":"2.0.0-beta.3"}');
4950
4950
  var dist = __webpack_require__("../../node_modules/.pnpm/https-proxy-agent@7.0.6/node_modules/https-proxy-agent/dist/index.js");
4951
- async function ProxyAgent(ip, adr, accountId, refresh) {
4951
+ async function ProxyAgent(task, ip, adr, accountId, refresh) {
4952
4952
  const http = new Http({
4953
4953
  headers: {
4954
4954
  "content-type": "application/json"
@@ -4974,7 +4974,7 @@ async function ProxyAgent(ip, adr, accountId, refresh) {
4974
4974
  data: ProxyInfo.data
4975
4975
  }
4976
4976
  };
4977
- this.logger?.info(`请求代理:区域:${params.addr}, IP:${params.ip}, AccountId:${params.accountId}, 返回代理信息: ${ProxyInfo.data ? `${ProxyInfo.data.proxyIp}:${ProxyInfo.data.proxyPort}` : "无可用代理"}`, loggerInfo);
4977
+ task.logger?.info(`请求代理:区域:${params.addr}, IP:${params.ip}, AccountId:${params.accountId}, 返回代理信息: ${ProxyInfo.data ? `${ProxyInfo.data.proxyIp}:${ProxyInfo.data.proxyPort}` : "无可用代理"}`, loggerInfo);
4978
4978
  return "000000" === ProxyInfo.code && ProxyInfo.data ? {
4979
4979
  ip: ProxyInfo.data.proxyIp,
4980
4980
  port: ProxyInfo.data.proxyPort,
@@ -4996,7 +4996,7 @@ class Http {
4996
4996
  ...config
4997
4997
  });
4998
4998
  this.logger = logger;
4999
- if (ip) this.agentPromise = ProxyAgent.call({
4999
+ if (ip) this.agentPromise = ProxyAgent({
5000
5000
  logger
5001
5001
  }, ip, adr, accountId);
5002
5002
  this.addResponseInterceptor(()=>void 0);
@@ -9072,10 +9072,9 @@ const rpaServer = async (task, params)=>{
9072
9072
  params.accountId
9073
9073
  ];
9074
9074
  task.logger?.info(`==> 开始获取代理信息:${args}`);
9075
- const ProxyAgentWithLogger = ProxyAgent.bind({
9075
+ const ProxyAgentResult = await ProxyAgent({
9076
9076
  logger: task.logger
9077
- });
9078
- const ProxyAgentResult = await ProxyAgentWithLogger(...args);
9077
+ }, ...args);
9079
9078
  task.logger?.info("==> 代理信息获取成功!");
9080
9079
  proxyUrl = ProxyAgentResult ? `http://${ProxyAgentResult.ip}:${ProxyAgentResult.port}` : void 0;
9081
9080
  }
@@ -11229,7 +11228,7 @@ const douyinGetHot = async (_task, params)=>{
11229
11228
  const http = new Http(...args);
11230
11229
  const hotParams = {
11231
11230
  query: params.query || "",
11232
- count: "50",
11231
+ count: params.count?.toString() || "20",
11233
11232
  aid: "1128",
11234
11233
  cookie_enabled: "0",
11235
11234
  screen_width: "1920",
@@ -11246,11 +11245,17 @@ const douyinGetHot = async (_task, params)=>{
11246
11245
  };
11247
11246
  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");
11248
11247
  hotParams.a_bogus = aBogus;
11248
+ if (!params.query) {
11249
+ delete hotParams.query;
11250
+ delete hotParams.count;
11251
+ }
11249
11252
  const queryString = new URLSearchParams(hotParams).toString();
11250
11253
  console.log("抖音获取热点参数:", queryString);
11254
+ const url = `https://creator.douyin.com/aweme/v1/hotspot/${params.query ? "search" : "recommend"}/?${queryString}`;
11255
+ console.log("抖音获取热点URL:", url);
11251
11256
  const res = await http.api({
11252
11257
  method: "get",
11253
- url: `https://creator.douyin.com/aweme/v1/hotspot/search/?${queryString}`,
11258
+ url,
11254
11259
  headers: {
11255
11260
  ...headers,
11256
11261
  "Content-Type": "application/json"
@@ -11263,8 +11268,8 @@ const douyinGetHot = async (_task, params)=>{
11263
11268
  const isSuccess = 0 === res.status_code;
11264
11269
  const message = `抖音获取热点${isSuccess ? "成功" : `失败,原因:${res.status_msg}`}${_task.debug ? ` ${http.proxyInfo}` : ""}`;
11265
11270
  const data = isSuccess ? {
11266
- hot: res?.sentences || [],
11267
- total: res?.sentences?.length || 0
11271
+ hot: res?.sentences || res?.all_sentences || [],
11272
+ total: (res?.sentences || res?.all_sentences)?.length || 0
11268
11273
  } : {
11269
11274
  hot: [],
11270
11275
  total: 0
@@ -11449,8 +11454,8 @@ const douyinGetMusic = async (_task, params)=>{
11449
11454
  return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(isSuccess ? 0 : 414, message, data);
11450
11455
  };
11451
11456
  const DouyinGetMusicByCategoryParamsSchema = ActionCommonParamsSchema.extend({
11452
- category_id: schemas_string().optional(),
11453
- type: schemas_string().optional(),
11457
+ category_id: schemas_string(),
11458
+ type: schemas_string(),
11454
11459
  count: schemas_number().optional()
11455
11460
  });
11456
11461
  const { sign_datail: douyinGetMusicByCategory_sign_datail, sign_reply: douyinGetMusicByCategory_sign_reply } = __webpack_require__("./src/utils/douyin/douyin.js");
@@ -11597,7 +11602,7 @@ const douyinGetTopics = async (_task, params)=>{
11597
11602
  params.accountId
11598
11603
  ];
11599
11604
  const http = new Http(...args);
11600
- const keyword = params.keyword || "";
11605
+ const keyword = params.keyword || "热点";
11601
11606
  const topicParams = {
11602
11607
  keyword: keyword,
11603
11608
  source: "challenge_create",
@@ -11643,6 +11648,282 @@ const douyinGetTopics = async (_task, params)=>{
11643
11648
  };
11644
11649
  return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(isSuccess ? 0 : 414, message, data);
11645
11650
  };
11651
+ const rpa_scanRetryMaxCount = 60;
11652
+ const rpa_waitQrcodeResultMaxTime = 2000 * rpa_scanRetryMaxCount;
11653
+ const douyinLogin_rpa_rpaAction = async (task, params)=>{
11654
+ const reporter = task.reportService?.reportLoginStatus ?? (()=>Promise.resolve());
11655
+ let page;
11656
+ let statusMachine = "new";
11657
+ let isSelfClosing = false;
11658
+ try {
11659
+ page = await task.createPage({
11660
+ url: "https://creator.douyin.com/"
11661
+ });
11662
+ if (!task._session?.id) throw new Error("Session ID 不存在");
11663
+ task._steelBrowser?.on("disconnected", ()=>{
11664
+ if (task.debug && isSelfClosing) task.logger.info("执行结束,关闭浏览器!");
11665
+ else task.logger.info("浏览器被手动释放或意外关闭!");
11666
+ });
11667
+ } catch (e) {
11668
+ task.logger.error("浏览器启动失败", e);
11669
+ return {
11670
+ code: 500,
11671
+ message: `浏览器启动失败: ${e}`,
11672
+ data: {}
11673
+ };
11674
+ }
11675
+ await page.route("**/*.mp4", (route)=>route.abort());
11676
+ await page.route("**/*.png", (route)=>route.abort());
11677
+ await page.route("**/*.ttf", (route)=>route.abort());
11678
+ await page.addInitScript(()=>{
11679
+ window.requestAnimationFrame = ()=>0;
11680
+ });
11681
+ await page.addInitScript(()=>{
11682
+ const removeEventBlockers = ()=>{
11683
+ try {
11684
+ const blockers = document.querySelectorAll('[style*="pointer-events: none"]');
11685
+ blockers.forEach((el)=>{
11686
+ el.style.pointerEvents = "auto";
11687
+ });
11688
+ document.body.style.pointerEvents = "auto";
11689
+ if (window.__DOUYIN_ANTI_DEBUG__) delete window.__DOUYIN_ANTI_DEBUG__;
11690
+ } catch (e) {}
11691
+ };
11692
+ removeEventBlockers();
11693
+ setInterval(removeEventBlockers, 1000);
11694
+ if ("undefined" != typeof MutationObserver) {
11695
+ const observer = new MutationObserver(removeEventBlockers);
11696
+ observer.observe(document.documentElement, {
11697
+ childList: true,
11698
+ subtree: true,
11699
+ attributes: true,
11700
+ attributeFilter: [
11701
+ "style"
11702
+ ]
11703
+ });
11704
+ }
11705
+ });
11706
+ task.logger.info("页面创建成功,开始Bypass页面事件屏蔽...");
11707
+ try {
11708
+ await page.waitForResponse((response)=>response.url().includes("/272.6591d0af.js") && 200 === response.status(), {
11709
+ timeout: 15000
11710
+ });
11711
+ await page.waitForLoadState("networkidle");
11712
+ await page.goto("about:blank");
11713
+ await page.goBack({
11714
+ waitUntil: "domcontentloaded"
11715
+ });
11716
+ task.logger.info("已返回登录页面,页面事件屏蔽Bypass完成...");
11717
+ } catch (e) {
11718
+ task.logger.warn("Bypass 超时,继续执行...", {
11719
+ error: e
11720
+ });
11721
+ }
11722
+ await page.waitForTimeout(2000);
11723
+ try {
11724
+ const loginButtonSelector = ".douyin-creator-master-icon-default.douyin-creator-master-icon-user_circle";
11725
+ await page.waitForSelector(loginButtonSelector, {
11726
+ state: "visible",
11727
+ timeout: 10000
11728
+ });
11729
+ const clicked = await page.evaluate((selector)=>{
11730
+ const btn = document.querySelector(selector);
11731
+ if (btn) {
11732
+ btn.click();
11733
+ return true;
11734
+ }
11735
+ return false;
11736
+ }, loginButtonSelector);
11737
+ if (clicked) task.logger.info("✅ 登录按钮点击成功(使用 JavaScript)");
11738
+ else {
11739
+ await page.locator(loginButtonSelector).click({
11740
+ force: true,
11741
+ timeout: 5000
11742
+ });
11743
+ task.logger.info("✅ 登录按钮点击成功(使用 Playwright force)");
11744
+ }
11745
+ } catch (e) {
11746
+ task.logger.error("❌ 点击登录按钮失败", e);
11747
+ return {
11748
+ code: 500,
11749
+ message: "无法点击登录按钮,页面可能已被屏蔽",
11750
+ data: {}
11751
+ };
11752
+ }
11753
+ await page.waitForTimeout(3000);
11754
+ const pageInfo = await task._client?.sessions.liveDetails(task._session.id);
11755
+ const pageId = pageInfo?.pages[0].id ?? "";
11756
+ const baseHost = task._session.websocketUrl?.replace(/^wss?:\/\//, "") ?? "";
11757
+ const debugParams = new URLSearchParams({
11758
+ baseHost,
11759
+ pageId
11760
+ });
11761
+ const connectAddress = debugParams.toString();
11762
+ task.reportService?.settingSessionID?.(task._session?.id || "");
11763
+ task.logger.info("🔗 远程调试地址已生成,现在可以安全访问远程页面");
11764
+ await reporter(0, "浏览器启动成功,请使用抖音App扫码登录......", {
11765
+ connectAddress
11766
+ });
11767
+ const userInfo = {
11768
+ uniqueId: "",
11769
+ avatar: "",
11770
+ name: ""
11771
+ };
11772
+ try {
11773
+ await new Promise((resolve, reject)=>{
11774
+ let finished = false;
11775
+ const timer = setTimeout(()=>{
11776
+ cleanup(statusMachine);
11777
+ }, rpa_waitQrcodeResultMaxTime);
11778
+ const cleanup = (status)=>{
11779
+ if (finished) return;
11780
+ finished = true;
11781
+ clearTimeout(timer);
11782
+ page.off("response", handleWebCommon);
11783
+ page.off("response", handleCheckQR);
11784
+ if (void 0 !== status) reject(status);
11785
+ };
11786
+ const handleWebCommon = async (resp)=>{
11787
+ try {
11788
+ const url = resp.url();
11789
+ if (url.includes("/web/common")) {
11790
+ cleanup();
11791
+ const headers = resp.headers();
11792
+ const xmst = headers["x-ms-token"];
11793
+ const date = headers["x-tt-timestamp"];
11794
+ if (xmst && date) {
11795
+ const mstExpirDate = new Date(1000 * Number(date) + 604800000);
11796
+ const msToken = {
11797
+ name: "msToken",
11798
+ value: xmst,
11799
+ domain: ".bytedance.com",
11800
+ expires: mstExpirDate.getTime() / 1000,
11801
+ httpOnly: true,
11802
+ path: "/",
11803
+ sameSite: "None",
11804
+ secure: true
11805
+ };
11806
+ await page.context().addCookies([
11807
+ msToken
11808
+ ]);
11809
+ task.debug && task.logger.info("msToken 添加成功");
11810
+ task.debug && task.logger.info("msToken 检测成功:", {
11811
+ token: xmst.substring(0, 20) + "...",
11812
+ timestamp: date
11813
+ });
11814
+ }
11815
+ await reporter(0, "扫码成功!", {
11816
+ stage: "scanQrcode",
11817
+ connectAddress
11818
+ });
11819
+ resolve();
11820
+ } else if (url.includes("aweme/v1/creator/user/info")) try {
11821
+ const jsonUserInfo = await resp.json();
11822
+ userInfo.name = jsonUserInfo.user_profile.nick_name ?? "";
11823
+ userInfo.avatar = jsonUserInfo.user_profile.avatar_url ?? "";
11824
+ task.debug && task.logger.info("用户信息获取成功", userInfo);
11825
+ } catch (e) {
11826
+ task.logger.warn("无法解析用户信息:", {
11827
+ url,
11828
+ error: e
11829
+ });
11830
+ }
11831
+ else if (url.includes("/aweme/v1/creator/pc/user/info/")) try {
11832
+ const jsonUserInfo = await resp.json();
11833
+ userInfo.uniqueId = jsonUserInfo.uid ?? "";
11834
+ task.debug && task.logger.info("用户uniqueId 获取成功", userInfo);
11835
+ } catch (e) {
11836
+ task.logger.warn("无法解析用户信息:", {
11837
+ url,
11838
+ error: e
11839
+ });
11840
+ }
11841
+ } catch (err) {
11842
+ task.logger.error("监听登录结果出现异常", err);
11843
+ cleanup(err);
11844
+ }
11845
+ };
11846
+ const handleCheckQR = async (response)=>{
11847
+ try {
11848
+ const url = response.url();
11849
+ if (!url.includes("/check_qrconnect")) return;
11850
+ let jsonResponse;
11851
+ try {
11852
+ jsonResponse = await response.json();
11853
+ } catch (e) {
11854
+ task.logger.warn("Response body unavailable (likely navigation happened)", {
11855
+ url
11856
+ });
11857
+ return;
11858
+ }
11859
+ const status = jsonResponse?.data?.status;
11860
+ task.logger.info("check_qrconnect 状态:", {
11861
+ status
11862
+ });
11863
+ if ("scanned" === status) {
11864
+ task.logger.info("用户已扫码,等待确认...");
11865
+ page.on("response", handleWebCommon);
11866
+ }
11867
+ if ("confirmed" === status) {
11868
+ userInfo.uniqueId = jsonResponse.data?.user_data?.user_id_str || "";
11869
+ task.logger.info("扫码确认,开始监听登录完成...");
11870
+ page.off("response", handleCheckQR);
11871
+ }
11872
+ statusMachine = status || "new";
11873
+ if ("expired" === status) {
11874
+ task.logger.warn("二维码已过期");
11875
+ cleanup("expired");
11876
+ }
11877
+ } catch (err) {
11878
+ task.logger.error("handleCheckQR 异常:", err);
11879
+ }
11880
+ };
11881
+ page.on("response", handleCheckQR);
11882
+ });
11883
+ } catch (e) {
11884
+ const errMap = {
11885
+ new: "用户扫码已超时,请重试!",
11886
+ scanned: "用户扫码后未点击确认,请重试!",
11887
+ expired: "二维码已过期,请重试!"
11888
+ };
11889
+ isSelfClosing = true;
11890
+ const errorMessage = "string" == typeof e && errMap[e] ? errMap[e] : e instanceof Error ? e.message : String(e);
11891
+ return {
11892
+ code: 500,
11893
+ message: errorMessage,
11894
+ data: {
11895
+ stage: "scanQrcode",
11896
+ connectAddress
11897
+ }
11898
+ };
11899
+ }
11900
+ let securityData = {};
11901
+ let retryCount = 0;
11902
+ const maxRetries = 10;
11903
+ while(retryCount < maxRetries){
11904
+ securityData = await page.evaluate(()=>({
11905
+ "security-sdk/s_sdk_pri_key": localStorage.getItem("security-sdk/s_sdk_pri_key") || "",
11906
+ "security-sdk/s_sdk_pub_key": localStorage.getItem("security-sdk/s_sdk_pub_key") || "",
11907
+ "security-sdk/s_sdk_sign_data_key/web_protect": localStorage.getItem("security-sdk/s_sdk_sign_data_key/web_protect") || ""
11908
+ }));
11909
+ if (securityData["security-sdk/s_sdk_pri_key"] && securityData["security-sdk/s_sdk_pub_key"] && securityData["security-sdk/s_sdk_sign_data_key/web_protect"]) {
11910
+ task.logger.info("Security SDK 数据已获取");
11911
+ break;
11912
+ }
11913
+ retryCount++;
11914
+ task.logger.info(`等待 Security SDK 数据... (${retryCount}/${maxRetries})`);
11915
+ await page.waitForTimeout(1000);
11916
+ }
11917
+ const cookie = JSON.stringify(await task._steelBrowserContext?.cookies());
11918
+ isSelfClosing = true;
11919
+ await page.close();
11920
+ return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)({
11921
+ connectAddress,
11922
+ cookie,
11923
+ userInfo,
11924
+ extraParam: securityData
11925
+ }, "登陆成功!");
11926
+ };
11646
11927
  const douyinLogin_rpa_server_scanRetryMaxCount = 60;
11647
11928
  const douyinLogin_rpa_server_waitQrcodeResultMaxTime = 2000 * douyinLogin_rpa_server_scanRetryMaxCount;
11648
11929
  const rpa_server_rpaServer = async (task, params)=>{
@@ -11656,10 +11937,9 @@ const rpa_server_rpaServer = async (task, params)=>{
11656
11937
  params.accountId
11657
11938
  ];
11658
11939
  task.logger?.info(`==> 开始获取代理信息:${args}`);
11659
- const ProxyAgentWithLogger = ProxyAgent.bind({
11940
+ const ProxyAgentResult = await ProxyAgent({
11660
11941
  logger: task.logger
11661
- });
11662
- const ProxyAgentResult = await ProxyAgentWithLogger(...args);
11942
+ }, ...args);
11663
11943
  task.logger?.info("==> 代理信息获取成功!");
11664
11944
  proxyUrl = ProxyAgentResult ? `http://${ProxyAgentResult.ip}:${ProxyAgentResult.port}` : void 0;
11665
11945
  }
@@ -11770,6 +12050,16 @@ const rpa_server_rpaServer = async (task, params)=>{
11770
12050
  error: e
11771
12051
  });
11772
12052
  }
12053
+ else if (url.includes("/aweme/v1/creator/pc/user/info/")) try {
12054
+ const jsonUserInfo = await resp.json();
12055
+ userInfo.uniqueId = jsonUserInfo.uid ?? "";
12056
+ task.debug && task.logger.info("用户uniqueId 获取成功", userInfo);
12057
+ } catch (e) {
12058
+ task.logger.warn("无法解析用户信息:", {
12059
+ url,
12060
+ error: e
12061
+ });
12062
+ }
11773
12063
  } catch (err) {
11774
12064
  cleanup();
11775
12065
  reject(err);
@@ -11789,13 +12079,15 @@ const rpa_server_rpaServer = async (task, params)=>{
11789
12079
  return;
11790
12080
  }
11791
12081
  const status = jsonResponse?.data?.status;
11792
- if ("scanned" === status) await updateTaskState?.({
11793
- state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.SCANNED
11794
- });
12082
+ if ("scanned" === status) {
12083
+ await updateTaskState?.({
12084
+ state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.SCANNED
12085
+ });
12086
+ page.on("response", handleWebCommon);
12087
+ }
11795
12088
  if ("confirmed" === status) {
11796
12089
  userInfo.uniqueId = jsonResponse.data?.user_data?.user_id_str || "";
11797
12090
  page.off("response", handleCheckQR);
11798
- page.on("response", handleWebCommon);
11799
12091
  }
11800
12092
  } catch (err) {
11801
12093
  cleanup();
@@ -11844,27 +12136,27 @@ const rpa_server_rpaServer = async (task, params)=>{
11844
12136
  case types_ExecutionState.SUCCESS:
11845
12137
  {
11846
12138
  let securityData = {};
11847
- try {
12139
+ let retryCount = 0;
12140
+ const maxRetries = 10;
12141
+ while(retryCount < maxRetries){
11848
12142
  securityData = await page.evaluate(()=>({
11849
12143
  "security-sdk/s_sdk_pri_key": localStorage.getItem("security-sdk/s_sdk_pri_key") || "",
11850
12144
  "security-sdk/s_sdk_pub_key": localStorage.getItem("security-sdk/s_sdk_pub_key") || "",
11851
- "security-sdk/s_sdk_sign_data_key": localStorage.getItem("security-sdk/s_sdk_sign_data_key/web_protect") || ""
12145
+ "security-sdk/s_sdk_sign_data_key/web_protect": localStorage.getItem("security-sdk/s_sdk_sign_data_key/web_protect") || ""
11852
12146
  }));
11853
- task.logger.info("Security SDK 数据提取成功:", {
11854
- "security-sdk/s_sdk_pri_key": !!securityData["security-sdk/s_sdk_pri_key"],
11855
- "security-sdk/s_sdk_pub_key": !!securityData["security-sdk/s_sdk_pub_key"],
11856
- "security-sdk/s_sdk_sign_data_key": !!securityData["security-sdk/s_sdk_sign_data_key"]
11857
- });
11858
- } catch (error) {
11859
- task.logger.warn("提取 Security SDK 数据失败:", {
11860
- error: error instanceof Error ? error.message : String(error)
11861
- });
12147
+ if (securityData["security-sdk/s_sdk_pri_key"] && securityData["security-sdk/s_sdk_pub_key"] && securityData["security-sdk/s_sdk_sign_data_key/web_protect"]) {
12148
+ task.logger.info("Security SDK 数据已获取");
12149
+ break;
12150
+ }
12151
+ retryCount++;
12152
+ task.logger.info(`等待 Security SDK 数据... (${retryCount}/${maxRetries})`);
12153
+ await page.waitForTimeout(1000);
11862
12154
  }
11863
12155
  await updateTaskState?.({
11864
12156
  state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.SUCCESS,
11865
12157
  result: {
11866
12158
  cookie: JSON.stringify(await task.steelBrowserContext?.cookies()),
11867
- ...securityData,
12159
+ extraParam: securityData,
11868
12160
  userInfo: userInfo
11869
12161
  }
11870
12162
  });
@@ -11873,7 +12165,7 @@ const rpa_server_rpaServer = async (task, params)=>{
11873
12165
  message: "成功",
11874
12166
  data: {
11875
12167
  cookie: JSON.stringify(await task.steelBrowserContext?.cookies()),
11876
- ...securityData,
12168
+ extraParam: securityData,
11877
12169
  userInfo
11878
12170
  }
11879
12171
  };
@@ -11887,6 +12179,7 @@ const rpa_server_rpaServer = async (task, params)=>{
11887
12179
  }
11888
12180
  };
11889
12181
  const douyinLogin = async (task, params)=>{
12182
+ if ("rpa" === params.actionType) return douyinLogin_rpa_rpaAction(task, params);
11890
12183
  if ("mockApi" === params.actionType) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)({}, "暂不支持mockApi");
11891
12184
  if ("server" === params.actionType) return rpa_server_rpaServer(task, params);
11892
12185
  return executeAction(rpa_server_rpaServer)(task, params);
@@ -11896,6 +12189,7 @@ const { generateReqSignFromTicket } = __webpack_require__("./src/utils/douyin/re
11896
12189
  const { generateCsrfTokenAdvanced } = __webpack_require__("./src/utils/douyin/csrfToken.js");
11897
12190
  const { generateAuthorization, randomS, canonicalQueryString, calculateFileCrc32 } = __webpack_require__("./src/utils/douyin/douyinSign.js");
11898
12191
  const mock_mockAction = async (task, params)=>{
12192
+ if (!params.extraParam || !params.extraParam["security-sdk/s_sdk_pri_key"] || !params.extraParam["security-sdk/s_sdk_pub_key"] || !params.extraParam["security-sdk/s_sdk_sign_data_key/web_protect"]) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(400, "extraParam 参数缺失或不完整", "");
11899
12193
  const tmpCachePath = task.getTmpPath();
11900
12194
  let bdTicketGuardClientDataV2 = params.cookies.find((e)=>"bd_ticket_guard_client_data" === e.name)?.value || "";
11901
12195
  if (!bdTicketGuardClientDataV2) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(400, "bdTicketGuardClientDataV2 不能为空", "");
@@ -11915,9 +12209,9 @@ const mock_mockAction = async (task, params)=>{
11915
12209
  ree_public_key = parsed.ree_public_key || "";
11916
12210
  ts_sign = parsed.ts_sign || "";
11917
12211
  } catch {}
11918
- const privateKey = params["security-sdk/s_sdk_pri_key"]?.data || "";
11919
- const publicKey = params["security-sdk/s_sdk_pub_key"]?.data || "";
11920
- const signData = JSON.parse(params["security-sdk/s_sdk_sign_data_key/web_protect"]?.data || "{}");
12212
+ const privateKey = params.extraParam["security-sdk/s_sdk_pri_key"]?.data || "";
12213
+ const publicKey = params.extraParam["security-sdk/s_sdk_pub_key"]?.data || "";
12214
+ const signData = JSON.parse(params.extraParam["security-sdk/s_sdk_sign_data_key/web_protect"]?.data || "{}");
11921
12215
  console.log("privateKey:", privateKey);
11922
12216
  console.log("publicKey:", publicKey);
11923
12217
  console.log("signData:", signData);
@@ -11960,30 +12254,26 @@ const mock_mockAction = async (task, params)=>{
11960
12254
  const publishData = {
11961
12255
  item: {
11962
12256
  common: {
11963
- text: params.title || "32234。sdsadadasda",
11964
- text_extra: '[{"start":0,"end":5,"hashtag_id":0,"hashtag_name":"","type":7},{"start":5,"end":6,"hashtag_id":0,"hashtag_name":"","type":8}]',
12257
+ text: params.content,
12258
+ text_extra: params.textExtra,
11965
12259
  activity: "[]",
11966
- challenges: "[]",
12260
+ challenges: params.challengeIds,
11967
12261
  hashtag_source: "",
11968
12262
  mentions: "[]",
11969
- music_id: "",
11970
- music_end_time: 0,
11971
- hot_sentence: "",
11972
- visibility_type: 0,
11973
- download: 0,
11974
- timing: -1,
11975
- media_type: 2,
12263
+ music_id: params.musicId,
12264
+ music_end_time: 1000 * (params.musicDuration || 0),
12265
+ hot_sentence: params.hotSentence || "",
12266
+ visibility_type: params.visibleRange || 0,
12267
+ download: params.allowSave ? 1 : 0,
12268
+ timing: params.isImmediatelyPublish ? -1 : params.scheduledPublish,
12269
+ media_type: params.publishType || 2,
11976
12270
  images: []
11977
12271
  },
11978
12272
  cover: {
11979
12273
  poster: ""
11980
12274
  },
11981
- mix: {},
11982
- anchor: {
11983
- poi_name: "",
11984
- poi_id: "",
11985
- anchor_content: "{}"
11986
- },
12275
+ mix: params.mix || {},
12276
+ anchor: {},
11987
12277
  declare: {
11988
12278
  user_declare_info: "{}"
11989
12279
  }
@@ -12247,8 +12537,8 @@ const douyinPublish_rpa_rpaAction = async (task, params)=>{
12247
12537
  const descInstance = page.locator("div[data-placeholder='添加作品描述...']");
12248
12538
  await descInstance.click();
12249
12539
  await descInstance.pressSequentially(params.content.replace(/#.*?\[.*?]#/g, "") || "22222");
12250
- if ("2" === params.visibleRange) await page.locator("label:has-text('好友可见')").first().click();
12251
- else if ("3" === params.visibleRange) await page.locator("label:has-text('仅自己可见')").first().click();
12540
+ if ("1" === params.visibleRange) await page.locator("label:has-text('好友可见')").first().click();
12541
+ else if ("2" === params.visibleRange) await page.locator("label:has-text('仅自己可见')").first().click();
12252
12542
  if (!params.isImmediatelyPublish) {
12253
12543
  await await page.locator('label:has-text("定时发布")').first().click();
12254
12544
  await page.waitForTimeout(500);
@@ -12283,74 +12573,51 @@ const douyinPublish_rpa_rpaAction = async (task, params)=>{
12283
12573
  await page.close();
12284
12574
  return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(response);
12285
12575
  };
12286
- const FictionalRendition = schemas_object({
12287
- type: literal("fictional-rendition")
12288
- });
12289
- const AIGenerated = schemas_object({
12290
- type: literal("ai-generated")
12291
- });
12292
- const SourceStatement = schemas_object({
12293
- type: literal("source-statement"),
12294
- childType: schemas_enum([
12295
- "self-labeling",
12296
- "self-shooting",
12297
- "transshipment"
12298
- ]),
12299
- shootingLocation: schemas_object({
12300
- id: schemas_string(),
12301
- name: schemas_string(),
12302
- latitude: schemas_number().optional(),
12303
- longitude: schemas_number().optional()
12304
- }).optional(),
12305
- shootingDate: schemas_string().optional(),
12306
- sourceMedia: schemas_string().optional()
12307
- });
12308
- union([
12309
- FictionalRendition,
12310
- AIGenerated,
12311
- SourceStatement
12312
- ]);
12313
12576
  const DouyinPublishParamsSchema = ActionCommonParamsSchema.extend({
12314
- banners: schemas_array(schemas_string()),
12315
12577
  title: schemas_string(),
12316
12578
  content: schemas_string(),
12317
- coverImage: schemas_string().optional(),
12318
- videoFile: schemas_string().optional(),
12319
- address: schemas_object({
12320
- id: schemas_string(),
12321
- name: schemas_string(),
12322
- latitude: schemas_number().optional(),
12323
- longitude: schemas_number().optional()
12324
- }).optional(),
12325
- selfDeclaration: custom().optional(),
12579
+ textExtra: schemas_string(),
12326
12580
  topic: schemas_array(schemas_object({
12327
12581
  id: schemas_string(),
12328
12582
  word: schemas_string()
12329
12583
  })).optional(),
12584
+ coverImage: schemas_string().optional(),
12585
+ banners: schemas_array(schemas_string()),
12586
+ mix: schemas_object({
12587
+ mix_id: schemas_string(),
12588
+ mix_order: schemas_number()
12589
+ }),
12590
+ musicId: schemas_string(),
12591
+ musicDuration: schemas_number().optional(),
12592
+ challengeIds: schemas_string(),
12593
+ hotSentence: schemas_string(),
12330
12594
  proxyLoc: schemas_string().optional(),
12331
12595
  localIP: schemas_string().optional(),
12332
12596
  visibleRange: schemas_enum([
12597
+ "0",
12333
12598
  "1",
12334
- "2",
12335
- "3"
12599
+ "2"
12336
12600
  ]).optional(),
12337
12601
  isImmediatelyPublish: schemas_boolean().optional(),
12338
12602
  scheduledPublish: schemas_string().optional(),
12339
- isOriginal: schemas_boolean().optional(),
12340
- allowCoProduce: schemas_boolean().optional(),
12341
- allowCopy: schemas_boolean().optional(),
12603
+ allowSave: schemas_boolean().optional(),
12342
12604
  publishType: schemas_enum([
12343
12605
  "1",
12344
12606
  "2",
12345
12607
  "3",
12346
12608
  "4"
12347
12609
  ]).optional(),
12348
- publishAction: schemas_enum([
12349
- "publish",
12350
- "draft"
12351
- ]).optional(),
12352
- isAiCoverImage: schemas_boolean().optional(),
12353
- summary: schemas_string().optional()
12610
+ extraParam: schemas_object({
12611
+ "security-sdk/s_sdk_pri_key": schemas_object({
12612
+ data: schemas_string()
12613
+ }),
12614
+ "security-sdk/s_sdk_pub_key": schemas_object({
12615
+ data: schemas_string()
12616
+ }),
12617
+ "security-sdk/s_sdk_sign_data_key/web_protect": schemas_object({
12618
+ data: schemas_string()
12619
+ })
12620
+ })
12354
12621
  });
12355
12622
  const douyinPublish = async (task, params)=>{
12356
12623
  if ("rpa" === params.actionType) return douyinPublish_rpa_rpaAction(task, params);
@@ -14121,8 +14388,8 @@ const searchXiaohongshuUserArticle = async (_task, params)=>{
14121
14388
  const message = `用户文章信息获取${isSuccess ? "成功!" : "失败,请检查!"}${_task.debug ? ` ${http.proxyInfo}` : ""}`;
14122
14389
  return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(isSuccess ? 0 : 414, message, INITIAL_STATE);
14123
14390
  };
14124
- const rpa_scanRetryMaxCount = 60;
14125
- const rpa_waitQrcodeResultMaxTime = 2000 * rpa_scanRetryMaxCount;
14391
+ const toutiaoLogin_rpa_scanRetryMaxCount = 60;
14392
+ const toutiaoLogin_rpa_waitQrcodeResultMaxTime = 2000 * toutiaoLogin_rpa_scanRetryMaxCount;
14126
14393
  const toutiaoLogin_rpa_rpaAction = async (task, _params)=>{
14127
14394
  const reporter = task.reportService?.reportLoginStatus ?? (()=>Promise.resolve());
14128
14395
  let page;
@@ -14167,7 +14434,7 @@ const toutiaoLogin_rpa_rpaAction = async (task, _params)=>{
14167
14434
  let finished = false;
14168
14435
  const timer = setTimeout(()=>{
14169
14436
  cleanup(statusMachine);
14170
- }, rpa_waitQrcodeResultMaxTime);
14437
+ }, toutiaoLogin_rpa_waitQrcodeResultMaxTime);
14171
14438
  const cleanup = (status)=>{
14172
14439
  if (finished) return;
14173
14440
  finished = true;
@@ -14266,10 +14533,9 @@ const toutiaoLogin_rpa_server_rpaServer = async (task, params)=>{
14266
14533
  params.accountId
14267
14534
  ];
14268
14535
  task.logger?.info(`==> 开始获取代理信息:${args}`);
14269
- const ProxyAgentWithLogger = ProxyAgent.bind({
14536
+ const ProxyAgentResult = await ProxyAgent({
14270
14537
  logger: task.logger
14271
- });
14272
- const ProxyAgentResult = await ProxyAgentWithLogger(...args);
14538
+ }, ...args);
14273
14539
  task.logger?.info("==> 代理信息获取成功!");
14274
14540
  proxyUrl = ProxyAgentResult ? `http://${ProxyAgentResult.ip}:${ProxyAgentResult.port}` : void 0;
14275
14541
  }
@@ -15309,10 +15575,9 @@ const weixinLogin_rpa_server_rpaServer = async (task, params)=>{
15309
15575
  params.accountId
15310
15576
  ];
15311
15577
  task.logger?.info(`==> 开始获取代理信息:${args}`);
15312
- const ProxyAgentWithLogger = ProxyAgent.bind({
15578
+ const ProxyAgentResult = await ProxyAgent({
15313
15579
  logger: task.logger
15314
- });
15315
- const ProxyAgentResult = await ProxyAgentWithLogger(...args);
15580
+ }, ...args);
15316
15581
  task.logger?.info("==> 代理信息获取成功!");
15317
15582
  proxyUrl = ProxyAgentResult ? `http://${ProxyAgentResult.ip}:${ProxyAgentResult.port}` : void 0;
15318
15583
  }
@@ -17225,10 +17490,9 @@ const xiaohongshuLogin_rpa_server_rpaServer = async (task, params)=>{
17225
17490
  params.accountId
17226
17491
  ];
17227
17492
  task.logger?.info(`==> 开始获取代理信息:${args}`);
17228
- const ProxyAgentWithLogger = ProxyAgent.bind({
17493
+ const ProxyAgentResult = await ProxyAgent({
17229
17494
  logger: task.logger
17230
- });
17231
- const ProxyAgentResult = await ProxyAgentWithLogger(...args);
17495
+ }, ...args);
17232
17496
  task.logger?.info("==> 代理信息获取成功!");
17233
17497
  proxyUrl = ProxyAgentResult ? `http://${ProxyAgentResult.ip}:${ProxyAgentResult.port}` : void 0;
17234
17498
  }
@@ -18061,10 +18325,9 @@ const rpaAction_Server = async (task, params)=>{
18061
18325
  params.accountId
18062
18326
  ];
18063
18327
  task.logger?.info(`==> 开始获取代理信息:${args}`);
18064
- const ProxyAgentWithLogger = ProxyAgent.bind({
18328
+ const ProxyAgentResult = await ProxyAgent({
18065
18329
  logger: task.logger
18066
- });
18067
- const ProxyAgentResult = await ProxyAgentWithLogger(...args);
18330
+ }, ...args);
18068
18331
  task.logger?.info("==> 代理信息获取成功!");
18069
18332
  proxyUrl = ProxyAgentResult ? `http://${ProxyAgentResult.ip}:${ProxyAgentResult.port}` : void 0;
18070
18333
  }
@@ -18811,13 +19074,13 @@ const rpaAction_Server_Mock = async (task, params)=>{
18811
19074
  });
18812
19075
  return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(data, message);
18813
19076
  };
18814
- const xiaohongshuPublish_FictionalRendition = schemas_object({
19077
+ const FictionalRendition = schemas_object({
18815
19078
  type: literal("fictional-rendition")
18816
19079
  });
18817
- const xiaohongshuPublish_AIGenerated = schemas_object({
19080
+ const AIGenerated = schemas_object({
18818
19081
  type: literal("ai-generated")
18819
19082
  });
18820
- const xiaohongshuPublish_SourceStatement = schemas_object({
19083
+ const SourceStatement = schemas_object({
18821
19084
  type: literal("source-statement"),
18822
19085
  childType: schemas_enum([
18823
19086
  "self-labeling",
@@ -18829,9 +19092,9 @@ const xiaohongshuPublish_SourceStatement = schemas_object({
18829
19092
  sourceMedia: schemas_string().optional()
18830
19093
  });
18831
19094
  union([
18832
- xiaohongshuPublish_FictionalRendition,
18833
- xiaohongshuPublish_AIGenerated,
18834
- xiaohongshuPublish_SourceStatement
19095
+ FictionalRendition,
19096
+ AIGenerated,
19097
+ SourceStatement
18835
19098
  ]);
18836
19099
  const XiaohongshuPublishParamsSchema = ActionCommonParamsSchema.extend({
18837
19100
  banners: schemas_array(schemas_string()),