@iflyrpa/actions 3.0.4 → 3.0.5-beta.2

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
@@ -5434,9 +5434,7 @@ function __webpack_require__(moduleId) {
5434
5434
  return module;
5435
5435
  };
5436
5436
  })();
5437
- var package_namespaceObject = {
5438
- i8: "3.0.3"
5439
- };
5437
+ var package_namespaceObject = JSON.parse('{"i8":"3.0.5-beta.2"}');
5440
5438
  var dist = __webpack_require__("../../node_modules/.pnpm/https-proxy-agent@7.0.6/node_modules/https-proxy-agent/dist/index.js");
5441
5439
  async function ProxyAgent(task, ip, adr, accountId, refresh) {
5442
5440
  const http = new Http({
@@ -5526,6 +5524,13 @@ class Http {
5526
5524
  }
5527
5525
  };
5528
5526
  if (foundError) Object.assign(errorResponse, foundError);
5527
+ if (error.response?.status === 403) {
5528
+ this.logger?.warn(`[403 详细信息] URL: ${error.config?.url}`);
5529
+ this.logger?.warn(`[403 响应头] ${JSON.stringify(error.response?.headers || {})}`);
5530
+ this.logger?.warn(`[403 响应体] ${JSON.stringify(error.response?.data || null)}`);
5531
+ const verifyDecision = error.response?.headers?.["x-tt-verify-passport-decision"];
5532
+ if (verifyDecision) this.logger?.warn(`[403 验证决策] x-tt-verify-passport-decision: ${verifyDecision}`);
5533
+ }
5529
5534
  if (error.response?.data) {
5530
5535
  if ("object" == typeof error.response.data) {
5531
5536
  const serverError = error.response.data;
@@ -14483,54 +14488,55 @@ const mock_mockAction = async (task, params)=>{
14483
14488
  })}`);
14484
14489
  task.logger.info(`publishData: ${JSON.stringify(publishData)}`);
14485
14490
  task.logger.info(`url: https://creator.douyin.com/web/api/media/aweme/create_v2/?${publishQueryParams}`);
14486
- let publishResult;
14487
- try {
14488
- publishResult = await proxyHttp.api({
14489
- method: "post",
14490
- url: `https://creator.douyin.com/web/api/media/aweme/create_v2/?${publishQueryParams}`,
14491
- data: publishData,
14492
- defaultErrorMsg: "发布异常,请稍后重试。",
14493
- headers: {
14494
- ...headers,
14495
- Referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
14496
- "Content-Type": "application/json",
14497
- Accept: "application/json, text/plain, */*",
14498
- "bd-ticket-guard-client-data": bdTicketGuardClientData["headers_bd_ticket_guard_client_data"],
14499
- "bd-ticket-guard-ree-public-key": bdTicketGuardClientData["headers_bd_ticket_guard_ree_public_key"],
14500
- "bd-ticket-guard-version": "2",
14501
- "bd-ticket-guard-web-sign-type": "1",
14502
- "bd-ticket-guard-web-version": "2",
14503
- "x-secsdk-csrf-token": csrfToken,
14504
- "x-tt-session-dtrait": sessionDtrait || ""
14505
- }
14506
- }, {
14507
- timeout: 60000,
14508
- retries: 3,
14509
- retryDelay: 2000
14510
- });
14511
- } catch (error) {
14512
- const upstreamMessage = error?.message || String(error);
14513
- const upstreamCode = error?.code;
14514
- task.logger.error(`TaskId:${task.taskId},create_v2 请求异常,上游错误已屏蔽。上游 code=${upstreamCode},message=${upstreamMessage}`, {
14515
- error,
14516
- upstreamData: error?.data,
14517
- extra: error?.extra
14518
- });
14519
- const message = "发布失败,请重试";
14520
- await updateTaskState?.({
14491
+ const publishResult = await proxyHttp.api({
14492
+ method: "post",
14493
+ url: `https://creator.douyin.com/web/api/media/aweme/create_v2/?${publishQueryParams}`,
14494
+ data: publishData,
14495
+ defaultErrorMsg: "发布异常,请稍后重试。",
14496
+ headers: {
14497
+ ...headers,
14498
+ Referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
14499
+ "Content-Type": "application/json",
14500
+ Accept: "application/json, text/plain, */*",
14501
+ "bd-ticket-guard-client-data": bdTicketGuardClientData["headers_bd_ticket_guard_client_data"],
14502
+ "bd-ticket-guard-ree-public-key": bdTicketGuardClientData["headers_bd_ticket_guard_ree_public_key"],
14503
+ "bd-ticket-guard-version": "2",
14504
+ "bd-ticket-guard-web-sign-type": "1",
14505
+ "bd-ticket-guard-web-version": "2",
14506
+ "x-secsdk-csrf-token": csrfToken,
14507
+ "x-tt-session-dtrait": sessionDtrait || ""
14508
+ }
14509
+ }, {
14510
+ timeout: 60000,
14511
+ retries: 3,
14512
+ retryDelay: 2000
14513
+ });
14514
+ task.logger.info("========== api调用完成 ==========");
14515
+ task.logger.info(`decision值: ${JSON.stringify(decision)}, needsVerification(decision): ${needsVerification(decision)}`);
14516
+ if (needsVerification(decision)) {
14517
+ const details = [
14518
+ publishResult.status_msg,
14519
+ decision?.verify_title,
14520
+ decision?.verify_desc
14521
+ ].filter(Boolean).join(" ");
14522
+ const message = `图文发布失败,原因:${details}${task.debug ? ` ${http.proxyInfo}` : ""}`;
14523
+ task.logger.warn(`TaskId:${task.taskId},检测到需要验证,准备返回验证信息`);
14524
+ const mockData = {
14521
14525
  state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
14522
14526
  error: message,
14523
14527
  result: {
14524
14528
  data: decision,
14525
14529
  uploadedImgList: JSON.stringify(publishData.item.common.images)
14526
14530
  }
14527
- });
14531
+ };
14532
+ await updateTaskState?.(mockData);
14528
14533
  return {
14529
- code: 414,
14530
- data: "",
14531
- message
14534
+ code: 0,
14535
+ data: mockData,
14536
+ message: "操作成功"
14532
14537
  };
14533
14538
  }
14539
+ task.logger.info("不需要验证,继续正常流程");
14534
14540
  reportLogger({
14535
14541
  token: params.huiwenToken || "",
14536
14542
  enverionment: task.enverionment || "development",
@@ -16049,26 +16055,26 @@ async function getToutiaoData(_task, params) {
16049
16055
  const http = new Http({
16050
16056
  headers: {
16051
16057
  cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
16052
- referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
16058
+ referer: "https://mp.toutiao.com/profile_v4/graphic/publish",
16059
+ "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36"
16060
+ }
16061
+ });
16062
+ const totalData = await http.api({
16063
+ method: "get",
16064
+ url: "https://mp.toutiao.com/mp/fe_api/home/merge_v2",
16065
+ params: {
16066
+ app_id: 1231
16067
+ }
16068
+ });
16069
+ await new Promise((r)=>setTimeout(r, 1000));
16070
+ const contentDataYesterday = await http.api({
16071
+ method: "get",
16072
+ url: "https://mp.toutiao.com/mp/agw/statistic/v2/content_stat",
16073
+ params: {
16074
+ type: 0,
16075
+ app_id: 1231
16053
16076
  }
16054
16077
  });
16055
- const [totalData, contentDataYesterday] = await Promise.all([
16056
- http.api({
16057
- method: "get",
16058
- url: "https://mp.toutiao.com/mp/fe_api/home/merge_v2",
16059
- params: {
16060
- app_id: 1231
16061
- }
16062
- }),
16063
- http.api({
16064
- method: "get",
16065
- url: "https://mp.toutiao.com/mp/agw/statistic/v2/content_stat",
16066
- params: {
16067
- type: 0,
16068
- app_id: 1231
16069
- }
16070
- })
16071
- ]);
16072
16078
  const isSuccess = !!(totalData?.data?.statistic && contentDataYesterday?.author_stat);
16073
16079
  if (!isSuccess || !totalData?.data || !contentDataYesterday?.author_stat) return types_errorResponse(totalData?.message || contentDataYesterday?.message || "头条号数据获取失败,请检查Cookie是否有效", 414);
16074
16080
  const ttData = {
@@ -21487,8 +21493,8 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
21487
21493
  headers
21488
21494
  });
21489
21495
  const proxyHttp = new Http(...args);
21490
- proxyHttp.addResponseInterceptor((response)=>{
21491
- const responseData = response.data;
21496
+ const baseRespFinder = (response)=>{
21497
+ const responseData = response?.data;
21492
21498
  const msgType = "draft" === params.saveType ? "同步" : "发布";
21493
21499
  if (response && responseData?.base_resp && 0 !== responseData.base_resp.ret && !ignoreErrno.includes(responseData.base_resp.ret)) {
21494
21500
  const errmsg = weixinPublish_mock_errnoMap[responseData.base_resp.ret] || response.config.defaultErrorMsg || responseData.base_resp.err_msg || `文章${msgType}异常,请稍后重试。`;
@@ -21498,7 +21504,9 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
21498
21504
  data: responseData
21499
21505
  };
21500
21506
  }
21501
- });
21507
+ };
21508
+ http.addResponseInterceptor(baseRespFinder);
21509
+ proxyHttp.addResponseInterceptor(baseRespFinder);
21502
21510
  await http.api({
21503
21511
  method: "get",
21504
21512
  url: "https://mp.weixin.qq.com/cgi-bin/appmsgpublish",