@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/bundle.js CHANGED
@@ -8733,8 +8733,10 @@ var __webpack_exports__ = {};
8733
8733
  navigator: ()=>_navigator,
8734
8734
  origin: ()=>utils_origin
8735
8735
  });
8736
- var package_namespaceObject = JSON.parse('{"i8":"1.0.0-beta.1"}');
8737
- var package_namespaceObject_0 = JSON.parse('{"i8":"4.0.0-beta.9"}');
8736
+ var package_namespaceObject = {
8737
+ i8: "0.1.2"
8738
+ };
8739
+ var package_namespaceObject_0 = JSON.parse('{"i8":"4.0.0-beta.13"}');
8738
8740
  const external_node_fs_namespaceObject = require("node:fs");
8739
8741
  var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
8740
8742
  const external_node_http_namespaceObject = require("node:http");
@@ -30636,35 +30638,16 @@ var __webpack_exports__ = {};
30636
30638
  }, "微信账号有效性检测完成!");
30637
30639
  };
30638
30640
  const XhsSessionCheck = async (_task, params)=>{
30639
- const logger = _task.logger;
30640
- const startedAt = Date.now();
30641
30641
  const check = {
30642
30642
  isValidSession: false,
30643
30643
  isValidWebSession: false
30644
30644
  };
30645
- const cookieNames = params.cookies.map((it)=>it.name);
30646
- logger?.info("[XhsSessionCheck] 开始执行小红书账号有效性检测", {
30647
- accountId: params.accountId,
30648
- proxyLoc: params.proxyLoc,
30649
- localIP: params.localIP,
30650
- willUseProxyAgent: !!params.localIP,
30651
- cookieCount: params.cookies.length,
30652
- cookieNames,
30653
- hasA1: cookieNames.includes("a1"),
30654
- hasWebSession: cookieNames.includes("web_session")
30655
- });
30656
30645
  const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
30657
- if (!a1Cookie) {
30658
- logger?.warn("[XhsSessionCheck] 缺失关键 cookie a1,提前返回", {
30659
- accountId: params.accountId,
30660
- cookieNames
30661
- });
30662
- return {
30663
- code: 414,
30664
- message: "账号数据异常,请重新绑定账号后重试。",
30665
- data: check
30666
- };
30667
- }
30646
+ if (!a1Cookie) return {
30647
+ code: 414,
30648
+ message: "账号数据异常,请重新绑定账号后重试。",
30649
+ data: check
30650
+ };
30668
30651
  const headers = {
30669
30652
  cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
30670
30653
  referer: "https://creator.xiaohongshu.com/new/home?source=official"
@@ -30692,7 +30675,6 @@ var __webpack_exports__ = {};
30692
30675
  return acc;
30693
30676
  }, {});
30694
30677
  const loginBaseXsHeader = sessionCheck_xsEncrypt.signHeadersGet(loginBasePath, recordCookie, "xhs-pc-web", null);
30695
- const baseInfoStart = Date.now();
30696
30678
  const _baseInfo = http.api({
30697
30679
  method: "get",
30698
30680
  baseURL: "https://creator.xiaohongshu.com",
@@ -30702,28 +30684,7 @@ var __webpack_exports__ = {};
30702
30684
  retries: 3,
30703
30685
  retryDelay: 20,
30704
30686
  timeout: 3000
30705
- }).then((res)=>{
30706
- logger?.info("[XhsSessionCheck] creator base 接口请求成功", {
30707
- accountId: params.accountId,
30708
- duration: Date.now() - baseInfoStart,
30709
- code: res?.code,
30710
- msg: res?.msg,
30711
- proxyInfo: http.proxyInfo
30712
- });
30713
- return res;
30714
- }).catch((e)=>{
30715
- logger?.warn("[XhsSessionCheck] creator base 接口请求失败", {
30716
- accountId: params.accountId,
30717
- duration: Date.now() - baseInfoStart,
30718
- code: e?.code,
30719
- message: e?.message,
30720
- data: e?.data,
30721
- extra: e?.extra,
30722
- proxyInfo: http.proxyInfo
30723
- });
30724
- return e.data;
30725
- });
30726
- const webSessionStart = Date.now();
30687
+ }).catch((e)=>e.data);
30727
30688
  const _web_session = http.api({
30728
30689
  method: "get",
30729
30690
  url: "https://edith.xiaohongshu.com/api/sns/web/unread_count"
@@ -30731,26 +30692,6 @@ var __webpack_exports__ = {};
30731
30692
  retries: 3,
30732
30693
  retryDelay: 20,
30733
30694
  timeout: 3000
30734
- }).then((res)=>{
30735
- logger?.info("[XhsSessionCheck] edith unread_count 接口请求成功", {
30736
- accountId: params.accountId,
30737
- duration: Date.now() - webSessionStart,
30738
- code: res?.code,
30739
- msg: res?.msg,
30740
- proxyInfo: http.proxyInfo
30741
- });
30742
- return res;
30743
- }).catch((e)=>{
30744
- logger?.warn("[XhsSessionCheck] edith unread_count 接口请求失败", {
30745
- accountId: params.accountId,
30746
- duration: Date.now() - webSessionStart,
30747
- code: e?.code,
30748
- message: e?.message,
30749
- data: e?.data,
30750
- extra: e?.extra,
30751
- proxyInfo: http.proxyInfo
30752
- });
30753
- throw e;
30754
30695
  });
30755
30696
  const [baseInfo, web_session] = await Promise.all([
30756
30697
  _baseInfo,
@@ -30758,18 +30699,8 @@ var __webpack_exports__ = {};
30758
30699
  ]);
30759
30700
  if (baseInfo?.code === 0) check.isValidSession = true;
30760
30701
  if (0 === web_session.code) check.isValidWebSession = true;
30761
- const _isSuccess = baseInfo?.code === web_session.code;
30702
+ baseInfo?.code, web_session.code;
30762
30703
  const message = `小红书账号有效性检测成功${_task.debug ? ` ${http.proxyInfo}` : ""}`;
30763
- logger?.info("[XhsSessionCheck] 检测完成", {
30764
- accountId: params.accountId,
30765
- totalDuration: Date.now() - startedAt,
30766
- baseInfoCode: baseInfo?.code,
30767
- webSessionCode: web_session?.code,
30768
- isValidSession: check.isValidSession,
30769
- isValidWebSession: check.isValidWebSession,
30770
- codeAligned: _isSuccess,
30771
- proxyInfo: http.proxyInfo
30772
- });
30773
30704
  return success(check, message);
30774
30705
  };
30775
30706
  const BjhSessionCheck = async (_task, params)=>{
@@ -34830,8 +34761,19 @@ var __webpack_exports__ = {};
34830
34761
  task.logger.error(`解析 webProtectData 失败: ${error}`);
34831
34762
  return utils_response(414, "安全参数 webProtectData 解析失败,请重新获取后重试", "");
34832
34763
  }
34833
- const ticket = webProtectData.ticket;
34834
- const ts_sign = webProtectData.ts_sign;
34764
+ let ticket = webProtectData.ticket;
34765
+ let ts_sign = webProtectData.ts_sign;
34766
+ const serverDataCookie = params.cookies.find((it)=>"bd_ticket_guard_server_data" === it.name)?.value;
34767
+ if (serverDataCookie) try {
34768
+ const decoded = JSON.parse(Buffer.from(decodeURIComponent(serverDataCookie), "base64").toString("utf8"));
34769
+ if (decoded.ticket && decoded.ts_sign) {
34770
+ if (decoded.ticket !== ticket) task.logger.info("使用 cookie 中的最新 ticket(web_protect 已过期)");
34771
+ ticket = decoded.ticket;
34772
+ ts_sign = decoded.ts_sign;
34773
+ }
34774
+ } catch (error) {
34775
+ task.logger.warn(`解析 bd_ticket_guard_server_data 失败,回退到 web_protect: ${error}`);
34776
+ }
34835
34777
  let ec_privateKey;
34836
34778
  try {
34837
34779
  ec_privateKey = JSON.parse(JSON.parse(params.extraParam["security-sdk/s_sdk_crypt_sdk"] || "{}").data || "{}").ec_privateKey;