@iflyrpa/actions 4.0.0-beta.10 → 4.0.0-beta.13

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.js CHANGED
@@ -5489,7 +5489,7 @@ var __webpack_exports__ = {};
5489
5489
  });
5490
5490
  const package_json_namespaceObject = require("@iflyrpa/share/package.json");
5491
5491
  var package_json_default = /*#__PURE__*/ __webpack_require__.n(package_json_namespaceObject);
5492
- var package_namespaceObject = JSON.parse('{"i8":"4.0.0-beta.9"}');
5492
+ var package_namespaceObject = JSON.parse('{"i8":"4.0.0-beta.13"}');
5493
5493
  const share_namespaceObject = require("@iflyrpa/share");
5494
5494
  const external_node_fs_namespaceObject = require("node:fs");
5495
5495
  var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
@@ -11896,35 +11896,16 @@ var __webpack_exports__ = {};
11896
11896
  }, "微信账号有效性检测完成!");
11897
11897
  };
11898
11898
  const XhsSessionCheck = async (_task, params)=>{
11899
- const logger = _task.logger;
11900
- const startedAt = Date.now();
11901
11899
  const check = {
11902
11900
  isValidSession: false,
11903
11901
  isValidWebSession: false
11904
11902
  };
11905
- const cookieNames = params.cookies.map((it)=>it.name);
11906
- logger?.info("[XhsSessionCheck] 开始执行小红书账号有效性检测", {
11907
- accountId: params.accountId,
11908
- proxyLoc: params.proxyLoc,
11909
- localIP: params.localIP,
11910
- willUseProxyAgent: !!params.localIP,
11911
- cookieCount: params.cookies.length,
11912
- cookieNames,
11913
- hasA1: cookieNames.includes("a1"),
11914
- hasWebSession: cookieNames.includes("web_session")
11915
- });
11916
11903
  const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
11917
- if (!a1Cookie) {
11918
- logger?.warn("[XhsSessionCheck] 缺失关键 cookie a1,提前返回", {
11919
- accountId: params.accountId,
11920
- cookieNames
11921
- });
11922
- return {
11923
- code: 414,
11924
- message: "账号数据异常,请重新绑定账号后重试。",
11925
- data: check
11926
- };
11927
- }
11904
+ if (!a1Cookie) return {
11905
+ code: 414,
11906
+ message: "账号数据异常,请重新绑定账号后重试。",
11907
+ data: check
11908
+ };
11928
11909
  const headers = {
11929
11910
  cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
11930
11911
  referer: "https://creator.xiaohongshu.com/new/home?source=official"
@@ -11952,7 +11933,6 @@ var __webpack_exports__ = {};
11952
11933
  return acc;
11953
11934
  }, {});
11954
11935
  const loginBaseXsHeader = sessionCheck_xsEncrypt.signHeadersGet(loginBasePath, recordCookie, "xhs-pc-web", null);
11955
- const baseInfoStart = Date.now();
11956
11936
  const _baseInfo = http.api({
11957
11937
  method: "get",
11958
11938
  baseURL: "https://creator.xiaohongshu.com",
@@ -11962,28 +11942,7 @@ var __webpack_exports__ = {};
11962
11942
  retries: 3,
11963
11943
  retryDelay: 20,
11964
11944
  timeout: 3000
11965
- }).then((res)=>{
11966
- logger?.info("[XhsSessionCheck] creator base 接口请求成功", {
11967
- accountId: params.accountId,
11968
- duration: Date.now() - baseInfoStart,
11969
- code: res?.code,
11970
- msg: res?.msg,
11971
- proxyInfo: http.proxyInfo
11972
- });
11973
- return res;
11974
- }).catch((e)=>{
11975
- logger?.warn("[XhsSessionCheck] creator base 接口请求失败", {
11976
- accountId: params.accountId,
11977
- duration: Date.now() - baseInfoStart,
11978
- code: e?.code,
11979
- message: e?.message,
11980
- data: e?.data,
11981
- extra: e?.extra,
11982
- proxyInfo: http.proxyInfo
11983
- });
11984
- return e.data;
11985
- });
11986
- const webSessionStart = Date.now();
11945
+ }).catch((e)=>e.data);
11987
11946
  const _web_session = http.api({
11988
11947
  method: "get",
11989
11948
  url: "https://edith.xiaohongshu.com/api/sns/web/unread_count"
@@ -11991,26 +11950,6 @@ var __webpack_exports__ = {};
11991
11950
  retries: 3,
11992
11951
  retryDelay: 20,
11993
11952
  timeout: 3000
11994
- }).then((res)=>{
11995
- logger?.info("[XhsSessionCheck] edith unread_count 接口请求成功", {
11996
- accountId: params.accountId,
11997
- duration: Date.now() - webSessionStart,
11998
- code: res?.code,
11999
- msg: res?.msg,
12000
- proxyInfo: http.proxyInfo
12001
- });
12002
- return res;
12003
- }).catch((e)=>{
12004
- logger?.warn("[XhsSessionCheck] edith unread_count 接口请求失败", {
12005
- accountId: params.accountId,
12006
- duration: Date.now() - webSessionStart,
12007
- code: e?.code,
12008
- message: e?.message,
12009
- data: e?.data,
12010
- extra: e?.extra,
12011
- proxyInfo: http.proxyInfo
12012
- });
12013
- throw e;
12014
11953
  });
12015
11954
  const [baseInfo, web_session] = await Promise.all([
12016
11955
  _baseInfo,
@@ -12018,18 +11957,8 @@ var __webpack_exports__ = {};
12018
11957
  ]);
12019
11958
  if (baseInfo?.code === 0) check.isValidSession = true;
12020
11959
  if (0 === web_session.code) check.isValidWebSession = true;
12021
- const _isSuccess = baseInfo?.code === web_session.code;
11960
+ baseInfo?.code, web_session.code;
12022
11961
  const message = `小红书账号有效性检测成功${_task.debug ? ` ${http.proxyInfo}` : ""}`;
12023
- logger?.info("[XhsSessionCheck] 检测完成", {
12024
- accountId: params.accountId,
12025
- totalDuration: Date.now() - startedAt,
12026
- baseInfoCode: baseInfo?.code,
12027
- webSessionCode: web_session?.code,
12028
- isValidSession: check.isValidSession,
12029
- isValidWebSession: check.isValidWebSession,
12030
- codeAligned: _isSuccess,
12031
- proxyInfo: http.proxyInfo
12032
- });
12033
11962
  return (0, share_namespaceObject.success)(check, message);
12034
11963
  };
12035
11964
  const BjhSessionCheck = async (_task, params)=>{
@@ -14604,8 +14533,19 @@ var __webpack_exports__ = {};
14604
14533
  task.logger.error(`解析 webProtectData 失败: ${error}`);
14605
14534
  return (0, share_namespaceObject.response)(414, "安全参数 webProtectData 解析失败,请重新获取后重试", "");
14606
14535
  }
14607
- const ticket = webProtectData.ticket;
14608
- const ts_sign = webProtectData.ts_sign;
14536
+ let ticket = webProtectData.ticket;
14537
+ let ts_sign = webProtectData.ts_sign;
14538
+ const serverDataCookie = params.cookies.find((it)=>"bd_ticket_guard_server_data" === it.name)?.value;
14539
+ if (serverDataCookie) try {
14540
+ const decoded = JSON.parse(Buffer.from(decodeURIComponent(serverDataCookie), "base64").toString("utf8"));
14541
+ if (decoded.ticket && decoded.ts_sign) {
14542
+ if (decoded.ticket !== ticket) task.logger.info("使用 cookie 中的最新 ticket(web_protect 已过期)");
14543
+ ticket = decoded.ticket;
14544
+ ts_sign = decoded.ts_sign;
14545
+ }
14546
+ } catch (error) {
14547
+ task.logger.warn(`解析 bd_ticket_guard_server_data 失败,回退到 web_protect: ${error}`);
14548
+ }
14609
14549
  let ec_privateKey;
14610
14550
  try {
14611
14551
  ec_privateKey = JSON.parse(JSON.parse(params.extraParam["security-sdk/s_sdk_crypt_sdk"] || "{}").data || "{}").ec_privateKey;