@iflyrpa/actions 1.2.14-beta.6 → 1.2.15

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
@@ -1859,20 +1859,12 @@ var __webpack_exports__ = {};
1859
1859
  type: "news"
1860
1860
  }
1861
1861
  });
1862
- const data = res?.data?.article.activity_list.map((_item)=>({
1862
+ return (0, share_namespaceObject.success)(res?.data?.article.activity_list.map((_item)=>({
1863
1863
  id: _item.id,
1864
1864
  name: _item.name,
1865
1865
  detail: _item.detail,
1866
1866
  is_enable: _item.is_enable
1867
- })) ?? [];
1868
- data.push({
1869
- id: "bjh_publish_num_left",
1870
- name: "账号剩余发文数",
1871
- detail: "",
1872
- is_enable: 1,
1873
- publish_num_left: res.data.ability.publish_num_left
1874
- });
1875
- return (0, share_namespaceObject.success)(data, "获取百家号配置项成功!");
1867
+ })) ?? [], "获取头条发布配置项成功");
1876
1868
  };
1877
1869
  const searchToutiaoTopicList = async (_task, params)=>{
1878
1870
  const http = new Http({
@@ -1989,6 +1981,60 @@ var __webpack_exports__ = {};
1989
1981
  return (0, share_namespaceObject.success)([]);
1990
1982
  }
1991
1983
  };
1984
+ const external_node_buffer_namespaceObject = require("node:buffer");
1985
+ const external_node_crypto_namespaceObject = require("node:crypto");
1986
+ var external_node_crypto_default = /*#__PURE__*/ __webpack_require__.n(external_node_crypto_namespaceObject);
1987
+ class XsEncrypt {
1988
+ async encryptMD5(url) {
1989
+ return external_node_crypto_default().createHash("md5").update(url, "utf8").digest("hex");
1990
+ }
1991
+ async encryptText(text) {
1992
+ const textEncoded = external_node_buffer_namespaceObject.Buffer.from(text).toString("base64");
1993
+ const cipher = external_node_crypto_default().createCipheriv("aes-128-cbc", new Uint8Array(this.keyBytes), new Uint8Array(this.iv));
1994
+ const ciphertext = cipher.update(textEncoded, "utf8", "base64");
1995
+ return ciphertext + cipher.final("base64");
1996
+ }
1997
+ async base64ToHex(encodedData) {
1998
+ const decodedData = external_node_buffer_namespaceObject.Buffer.from(encodedData, "base64");
1999
+ return decodedData.toString("hex");
2000
+ }
2001
+ async encryptPayload(payload, platform) {
2002
+ const hexPayload = await this.base64ToHex(payload);
2003
+ const obj = {
2004
+ signSvn: "56",
2005
+ signType: "x2",
2006
+ appID: platform,
2007
+ signVersion: "1",
2008
+ payload: hexPayload
2009
+ };
2010
+ const jsonString = JSON.stringify(obj, null, 0);
2011
+ return external_node_buffer_namespaceObject.Buffer.from(jsonString).toString("base64");
2012
+ }
2013
+ async encryptXs(url, a1, ts, platform = "xhs-pc-web") {
2014
+ const text = `x1=${await this.encryptMD5(`url=${url}`)};x2=0|0|0|1|0|0|1|0|0|0|1|0|0|0|0|1|0|0|0;x3=${a1};x4=${ts};`;
2015
+ return `XYW_${await this.encryptPayload(await this.encryptText(text), platform)}`;
2016
+ }
2017
+ dumps(...rest) {
2018
+ const [data, replacer = null, space = 0] = rest;
2019
+ return JSON.stringify(data, replacer, space).replace(/\n/g, "").replace(/":\s+"/g, '":"');
2020
+ }
2021
+ constructor(){
2022
+ this.words = [
2023
+ 929260340,
2024
+ 1633971297,
2025
+ 895580464,
2026
+ 925905270
2027
+ ];
2028
+ this.keyBytes = external_node_buffer_namespaceObject.Buffer.concat(this.words.map((word)=>new Uint8Array(external_node_buffer_namespaceObject.Buffer.from([
2029
+ word >> 24 & 0xff,
2030
+ word >> 16 & 0xff,
2031
+ word >> 8 & 0xff,
2032
+ 0xff & word
2033
+ ]))));
2034
+ this.iv = external_node_buffer_namespaceObject.Buffer.from("4uzjr7mbsibcaldp", "utf8");
2035
+ }
2036
+ }
2037
+ const xsEncrypt = new XsEncrypt();
1992
2038
  const searchXiaohongshuTopicList = async (_task, params)=>{
1993
2039
  const http = new Http({
1994
2040
  headers: {
@@ -1997,20 +2043,35 @@ var __webpack_exports__ = {};
1997
2043
  origin: "https://creator.xiaohongshu.com"
1998
2044
  }
1999
2045
  });
2046
+ const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
2047
+ if (!a1Cookie) return {
2048
+ code: 200,
2049
+ message: "账号数据异常,请重新绑定账号后重试。",
2050
+ data: []
2051
+ };
2000
2052
  try {
2053
+ const xt = Date.now().toString();
2054
+ const topicData = {
2055
+ keyword: params.searchValue,
2056
+ suggest_topic_request: {
2057
+ title: "",
2058
+ desc: `#${params.searchValue}`
2059
+ },
2060
+ page: {
2061
+ page_size: 20,
2062
+ page: 1
2063
+ }
2064
+ };
2065
+ const topicDataStr = xsEncrypt.dumps(topicData);
2066
+ const fatchTopic = `/web_api/sns/v1/search/topic${topicDataStr}`;
2067
+ const xs = await xsEncrypt.encryptXs(fatchTopic, a1Cookie, xt);
2001
2068
  const result = await http.api({
2002
2069
  method: "post",
2003
2070
  url: "https://edith.xiaohongshu.com/web_api/sns/v1/search/topic",
2004
- data: {
2005
- keyword: params.searchValue,
2006
- suggest_topic_request: {
2007
- title: "",
2008
- desc: `#${params.searchValue}`
2009
- },
2010
- page: {
2011
- page_size: 20,
2012
- page: 1
2013
- }
2071
+ data: topicData,
2072
+ headers: {
2073
+ "x-s": xs,
2074
+ "x-t": xt
2014
2075
  },
2015
2076
  defaultErrorMsg: "话题搜索异常,请稍后重试。"
2016
2077
  });
@@ -2553,786 +2614,6 @@ var __webpack_exports__ = {};
2553
2614
  }, "获取粉丝数失败,请检查登陆有效性!");
2554
2615
  }
2555
2616
  };
2556
- const TTSessionCheck = async (_task, params)=>{
2557
- const http = new Http({
2558
- headers: {
2559
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
2560
- referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
2561
- }
2562
- });
2563
- try {
2564
- const res = await http.api({
2565
- method: "get",
2566
- url: "https://mp.toutiao.com/mp/agw/creator_center/user_info",
2567
- defaultErrorMsg: `头条号登录状态失效。`
2568
- });
2569
- return (0, share_namespaceObject.success)(0 === res.code ? {
2570
- isValidSession: true
2571
- } : {
2572
- isValidSession: false
2573
- }, "头条账号有效性检测完成!");
2574
- } catch (error) {
2575
- return (0, share_namespaceObject.success)({
2576
- isValidSession: false
2577
- }, "头条账号有效性检测失败!");
2578
- }
2579
- };
2580
- const WxSessionCheck = async (_task, params)=>{
2581
- const http = new Http({
2582
- headers: {
2583
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";")
2584
- }
2585
- });
2586
- const fingerprint = "4695500bc93ab4ce8fb2692da6564e04";
2587
- try {
2588
- const res = await http.api({
2589
- method: "get",
2590
- url: "https://mp.weixin.qq.com/cgi-bin/appmsgpublish",
2591
- params: {
2592
- fingerprint,
2593
- sub: "list",
2594
- begin: 0,
2595
- count: 10,
2596
- query: "",
2597
- type: 1011102103,
2598
- show_type: "",
2599
- free_publish_type: 1102103,
2600
- sub_action: "list_ex",
2601
- search_card: 0,
2602
- token: params.token,
2603
- lang: "zh_CN",
2604
- f: "json",
2605
- ajax: 1
2606
- }
2607
- });
2608
- return (0, share_namespaceObject.success)(0 === res.base_resp.ret ? {
2609
- isValidSession: true
2610
- } : {
2611
- isValidSession: false
2612
- }, "微信账号有效性检测完成!");
2613
- } catch (error) {
2614
- return (0, share_namespaceObject.success)({
2615
- isValidSession: false
2616
- }, "微信账号有效性检测失败!");
2617
- }
2618
- };
2619
- const XhsSessionCheck = async (_task, params)=>{
2620
- const http = new Http({
2621
- headers: {
2622
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
2623
- referer: "https://creator.xiaohongshu.com/new/home?source=official"
2624
- }
2625
- });
2626
- try {
2627
- const res = await http.api({
2628
- method: "get",
2629
- url: "https://creator.xiaohongshu.com/api/galaxy/user/info"
2630
- });
2631
- return (0, share_namespaceObject.success)(0 === res.result ? {
2632
- isValidSession: true
2633
- } : {
2634
- isValidSession: false
2635
- }, "小红书账号有效性检测完成!");
2636
- } catch (error) {
2637
- return (0, share_namespaceObject.success)({
2638
- isValidSession: false
2639
- }, "小红书账号有效性检测完成!");
2640
- }
2641
- };
2642
- const BjhSessionCheck = async (_task, params)=>{
2643
- const http = new Http({
2644
- headers: {
2645
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
2646
- referer: "https://baijiahao.baidu.com/builder/rc/home"
2647
- }
2648
- });
2649
- try {
2650
- const res = await http.api({
2651
- method: "get",
2652
- url: "https://baijiahao.baidu.com/pcui/home/index",
2653
- defaultErrorMsg: `百家号登录状态失效。`
2654
- });
2655
- return (0, share_namespaceObject.success)(0 === res.errno ? {
2656
- isValidSession: true
2657
- } : {
2658
- isValidSession: false
2659
- }, "百家号账号有效性检测完成!");
2660
- } catch (error) {
2661
- return (0, share_namespaceObject.success)({
2662
- isValidSession: false
2663
- }, "百家号账号有效性检测失败!");
2664
- }
2665
- };
2666
- const types_errorResponse = (message, code = 500)=>({
2667
- code,
2668
- message,
2669
- data: null
2670
- });
2671
- async function getBaijiahaoData(params) {
2672
- try {
2673
- const { token } = params;
2674
- if (!token) return types_errorResponse("缺少token", 200);
2675
- const http = new Http({
2676
- headers: {
2677
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
2678
- token: String(token),
2679
- Referer: "https://baijiahao.baidu.com/builder/rc/home"
2680
- }
2681
- });
2682
- const yesterday = TimeFormatter.format(new Date().setDate(new Date().getDate() - 1), "yyyyMMdd");
2683
- const [fansData, readData, incomeData, yesterdayData] = await Promise.all([
2684
- http.api({
2685
- method: "get",
2686
- url: "https://baijiahao.baidu.com/pcui/home/index"
2687
- }),
2688
- http.api({
2689
- method: "get",
2690
- url: "https://baijiahao.baidu.com/author/eco/statistic/getauthorhistory"
2691
- }),
2692
- http.api({
2693
- method: "get",
2694
- url: "https://baijiahao.baidu.com/author/eco/income4/homepageincome"
2695
- }),
2696
- http.api({
2697
- method: "get",
2698
- url: "https://baijiahao.baidu.com/author/eco/statistics/appStatistic",
2699
- params: {
2700
- type: "all",
2701
- is_yesterday: false,
2702
- start_day: yesterday,
2703
- end_day: yesterday,
2704
- stat: 0
2705
- }
2706
- })
2707
- ]);
2708
- const bjhData = {
2709
- fansNum: fansData.data.coreData.fansCount,
2710
- fansNumYesterday: -1 == yesterdayData.data.data.fans_increase ? null : yesterdayData.data.data.fans_increase,
2711
- readNum: readData.data.total.view_count,
2712
- incomeNum: incomeData.data.all_income.total_income,
2713
- incomeNumYesterday: -1 == incomeData.data.all_income.yesterday_income ? null : incomeData.data.all_income.yesterday_income,
2714
- recommendNumYesterday: -1 == yesterdayData.data.data.recommend_count ? null : yesterdayData.data.data.recommend_count,
2715
- readNumYesterday: -1 == yesterdayData.data.data.view_count ? null : yesterdayData.data.data.view_count,
2716
- likeNumYesterday: -1 == yesterdayData.data.data.likes_count ? null : yesterdayData.data.data.likes_count,
2717
- commentNumYesterday: -1 == yesterdayData.data.data.comment_count ? null : yesterdayData.data.data.comment_count
2718
- };
2719
- return (0, share_namespaceObject.success)(bjhData, "百家号平台数据获取成功!");
2720
- } catch (error) {
2721
- return types_errorResponse(error instanceof Error ? error.message : "百家号平台数据获取失败");
2722
- }
2723
- }
2724
- async function getToutiaoData(params) {
2725
- const { cookies } = params;
2726
- try {
2727
- const http = new Http({
2728
- headers: {
2729
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
2730
- referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
2731
- }
2732
- });
2733
- const [totalData, fansDataYesterday, contentDataYesterday] = await Promise.all([
2734
- http.api({
2735
- method: "get",
2736
- url: "https://mp.toutiao.com/mp/fe_api/home/merge_v2",
2737
- params: {
2738
- app_id: 1231
2739
- }
2740
- }),
2741
- http.api({
2742
- method: "get",
2743
- url: "https://mp.toutiao.com/mp/agw/statistic/v2/fans/latest_stat",
2744
- params: {
2745
- app_id: 1231
2746
- }
2747
- }),
2748
- http.api({
2749
- method: "get",
2750
- url: "https://mp.toutiao.com/mp/agw/statistic/v2/content_stat",
2751
- params: {
2752
- type: 0,
2753
- app_id: 1231
2754
- }
2755
- })
2756
- ]);
2757
- const ttData = {
2758
- fansNum: Number(totalData.data.statistic.data.total_subscribe_count),
2759
- fansNumYesterday: fansDataYesterday.fans_stat.change_count,
2760
- readNum: Number(totalData.data.statistic.data.total_read_play_count),
2761
- incomeNum: totalData.data.statistic.data.total_income,
2762
- incomeNumYesterday: totalData.data.statistic.data.yesterday_income,
2763
- showNumYesterday: contentDataYesterday.author_stat.consume_data.impression_count,
2764
- readNumYesterday: contentDataYesterday.author_stat.consume_data.go_detail_count,
2765
- likeNumYesterday: contentDataYesterday.author_stat.interaction_data.digg_count,
2766
- commentNumYesterday: contentDataYesterday.author_stat.interaction_data.comment_count
2767
- };
2768
- return (0, share_namespaceObject.success)(ttData, "头条号粉丝数据获取成功!");
2769
- } catch (error) {
2770
- return types_errorResponse(error instanceof Error ? error.message : "头条号数据获取失败");
2771
- }
2772
- }
2773
- async function getWeixinData(params) {
2774
- const { token } = params;
2775
- if (!token) return {
2776
- code: 200,
2777
- message: "缺少token",
2778
- data: null
2779
- };
2780
- try {
2781
- const { token } = params;
2782
- if (!token) return types_errorResponse("缺少token", 200);
2783
- const http = new Http({
2784
- headers: {
2785
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";")
2786
- }
2787
- });
2788
- const userInfo = {
2789
- originalCount: 0,
2790
- totalUsers: 0,
2791
- userIncrease: 0,
2792
- yesterday: {
2793
- read: 0,
2794
- share: 0,
2795
- subscribe: 0
2796
- }
2797
- };
2798
- const userInfoHtml = await http.api({
2799
- method: "get",
2800
- url: "https://mp.weixin.qq.com/cgi-bin/home",
2801
- params: {
2802
- t: "home/index",
2803
- token,
2804
- lang: "zh_CN"
2805
- }
2806
- });
2807
- const originalMatch = userInfoHtml.trim().match(/原创内容[\s\S]*?<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
2808
- if (originalMatch) userInfo.originalCount = parseInt(originalMatch[1].replace(/,/g, ''), 10);
2809
- const totalUsersMatch = userInfoHtml.match(/总用户数[\s\S]*?<div[^>]*class=["']weui-desktop-user_sum["'][^>]*>[\s\S]*?<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
2810
- if (totalUsersMatch) userInfo.totalUsers = parseInt(totalUsersMatch[1].replace(/,/g, ''), 10);
2811
- const increaseMatch = userInfoHtml.match(/weui-desktop-user_increase_num[^>]*>\s*([+-]?)\s*<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
2812
- if (increaseMatch) {
2813
- const sign = '-' === increaseMatch[1] ? -1 : 1;
2814
- userInfo.userIncrease = sign * parseInt(increaseMatch[2].replace(/,/g, ''), 10);
2815
- }
2816
- const readMatch = userInfoHtml.match(/昨日阅读[\s\S]*?<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
2817
- if (readMatch) userInfo.yesterday.read = parseInt(readMatch[1].replace(/,/g, ''), 10);
2818
- const shareMatch = userInfoHtml.match(/昨日分享[\s\S]*?<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
2819
- if (shareMatch) userInfo.yesterday.share = parseInt(shareMatch[1].replace(/,/g, ''), 10);
2820
- const subscribeMatch = userInfoHtml.match(/昨日新增关注[\s\S]*?<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
2821
- if (subscribeMatch) userInfo.yesterday.subscribe = parseInt(subscribeMatch[1].replace(/,/g, ''), 10);
2822
- const wxData = {
2823
- fansNum: userInfo.totalUsers,
2824
- fansNumYesterday: userInfo.yesterday.subscribe,
2825
- readNumYesterday: userInfo.yesterday.read,
2826
- shareNumYesterday: userInfo.yesterday.share
2827
- };
2828
- return (0, share_namespaceObject.success)(wxData, "微信平台数据获取成功!");
2829
- } catch (error) {
2830
- return types_errorResponse(error instanceof Error ? error.message : "微信平台数据获取失败");
2831
- }
2832
- }
2833
- const external_node_buffer_namespaceObject = require("node:buffer");
2834
- const external_node_crypto_namespaceObject = require("node:crypto");
2835
- var external_node_crypto_default = /*#__PURE__*/ __webpack_require__.n(external_node_crypto_namespaceObject);
2836
- class XsEncrypt {
2837
- async encryptMD5(url) {
2838
- return external_node_crypto_default().createHash("md5").update(url, "utf8").digest("hex");
2839
- }
2840
- async encryptText(text) {
2841
- const textEncoded = external_node_buffer_namespaceObject.Buffer.from(text).toString("base64");
2842
- const cipher = external_node_crypto_default().createCipheriv("aes-128-cbc", new Uint8Array(this.keyBytes), new Uint8Array(this.iv));
2843
- const ciphertext = cipher.update(textEncoded, "utf8", "base64");
2844
- return ciphertext + cipher.final("base64");
2845
- }
2846
- async base64ToHex(encodedData) {
2847
- const decodedData = external_node_buffer_namespaceObject.Buffer.from(encodedData, "base64");
2848
- return decodedData.toString("hex");
2849
- }
2850
- async encryptPayload(payload, platform) {
2851
- const hexPayload = await this.base64ToHex(payload);
2852
- const obj = {
2853
- signSvn: "56",
2854
- signType: "x2",
2855
- appID: platform,
2856
- signVersion: "1",
2857
- payload: hexPayload
2858
- };
2859
- const jsonString = JSON.stringify(obj, null, 0);
2860
- return external_node_buffer_namespaceObject.Buffer.from(jsonString).toString("base64");
2861
- }
2862
- async encryptXs(url, a1, ts, platform = "xhs-pc-web") {
2863
- const text = `x1=${await this.encryptMD5(`url=${url}`)};x2=0|0|0|1|0|0|1|0|0|0|1|0|0|0|0|1|0|0|0;x3=${a1};x4=${ts};`;
2864
- return `XYW_${await this.encryptPayload(await this.encryptText(text), platform)}`;
2865
- }
2866
- dumps(...rest) {
2867
- const [data, replacer = null, space = 0] = rest;
2868
- return JSON.stringify(data, replacer, space).replace(/\n/g, "").replace(/":\s+"/g, '":"');
2869
- }
2870
- constructor(){
2871
- this.words = [
2872
- 929260340,
2873
- 1633971297,
2874
- 895580464,
2875
- 925905270
2876
- ];
2877
- this.keyBytes = external_node_buffer_namespaceObject.Buffer.concat(this.words.map((word)=>new Uint8Array(external_node_buffer_namespaceObject.Buffer.from([
2878
- word >> 24 & 0xff,
2879
- word >> 16 & 0xff,
2880
- word >> 8 & 0xff,
2881
- 0xff & word
2882
- ]))));
2883
- this.iv = external_node_buffer_namespaceObject.Buffer.from("4uzjr7mbsibcaldp", "utf8");
2884
- }
2885
- }
2886
- async function getXiaohongshuData(params) {
2887
- try {
2888
- const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
2889
- if (!a1Cookie) return types_errorResponse("账号数据异常,请重新绑定账号后重试。", 200);
2890
- const http = new Http({
2891
- headers: {
2892
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
2893
- referer: "https://creator.xiaohongshu.com",
2894
- origin: "https://creator.xiaohongshu.com"
2895
- }
2896
- });
2897
- const xsEncrypt = new XsEncrypt();
2898
- const xt = Date.now().toString();
2899
- const sevenDataUrl = "/api/galaxy/v2/creator/datacenter/account/base";
2900
- const xs = await xsEncrypt.encryptXs(sevenDataUrl, a1Cookie, xt);
2901
- const [overAllData, sevenData] = await Promise.all([
2902
- http.api({
2903
- method: "get",
2904
- url: "https://creator.xiaohongshu.com/api/galaxy/creator/home/personal_info"
2905
- }),
2906
- http.api({
2907
- method: "get",
2908
- baseURL: "https://creator.xiaohongshu.com",
2909
- url: sevenDataUrl,
2910
- headers: {
2911
- "x-s": xs,
2912
- "x-t": xt
2913
- }
2914
- })
2915
- ]);
2916
- const xhsData = {
2917
- fansNum: overAllData.data.fans_count,
2918
- favedNum: overAllData.data.faved_count,
2919
- watchNumLastWeek: sevenData.data.seven.view_count,
2920
- likeNumLastWeek: sevenData.data.seven.like_count,
2921
- collectNumLastWeek: sevenData.data.seven.collect_count,
2922
- commentNumLastWeek: sevenData.data.seven.comment_count,
2923
- fansNumLastWeek: sevenData.data.seven.rise_fans_count,
2924
- fansNumYesterday: sevenData.data.seven.rise_fans_list[0].count
2925
- };
2926
- return (0, share_namespaceObject.success)(xhsData, "小红书平台数据获取成功!");
2927
- } catch (error) {
2928
- return types_errorResponse(error instanceof Error ? error.message : "小红书平台数据获取失败");
2929
- }
2930
- }
2931
- const SearchAccountInfo = async (_task, params)=>{
2932
- const { platform } = params;
2933
- switch(platform){
2934
- case "toutiao":
2935
- return getToutiaoData(params);
2936
- case "xiaohongshu":
2937
- return getXiaohongshuData(params);
2938
- case "weixin":
2939
- return getWeixinData(params);
2940
- case "baijiahao":
2941
- return getBaijiahaoData(params);
2942
- default:
2943
- return (0, share_namespaceObject.success)(null, "暂不支持该平台");
2944
- }
2945
- };
2946
- const searchPublishInfo_types_errorResponse = (message, code = 500)=>({
2947
- code,
2948
- message,
2949
- data: null
2950
- });
2951
- async function handleToutiaoData(params) {
2952
- try {
2953
- const { cookies, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false } = params;
2954
- const http = new Http({
2955
- headers: {
2956
- cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";")
2957
- }
2958
- });
2959
- const visitedUid = await http.api({
2960
- url: "https://mp.toutiao.com/mp/agw/creator_center/user_info?",
2961
- method: "get",
2962
- params: {
2963
- app_id: 1231
2964
- }
2965
- });
2966
- const articleInfo = await http.api({
2967
- method: "get",
2968
- url: "https://mp.toutiao.com/api/feed/mp_provider/v1/",
2969
- params: {
2970
- provider_type: "mp_provider",
2971
- aid: "13",
2972
- app_name: "news_article",
2973
- category: "mp_all",
2974
- channel: "",
2975
- stream_api_version: "88",
2976
- genre_type_switch: '{"repost":1,"small_video":1,"toutiao_graphic":1,"weitoutiao":1,"xigua_video":1}',
2977
- device_platform: "pc",
2978
- platform_id: "0",
2979
- visited_uid: visitedUid.user_id_str,
2980
- offset: (pageNum - 1) * pageSize,
2981
- count: pageSize,
2982
- keyword: "",
2983
- client_extra_params: `{"category":"mp_all","real_app_id":"1231","need_forward":"true","offset_mode":"1","page_index":"1","status":${onlySuccess ? "2" : "8"},"source":"0"}`,
2984
- app_id: "1231"
2985
- }
2986
- });
2987
- const articleCell = articleInfo.data.map((item)=>({
2988
- title: item.assembleCell.itemCell.articleBase.title,
2989
- imageUrl: item.assembleCell.itemCell.imageList.staggerFeedCover[0].url,
2990
- createTime: item.assembleCell.itemCell.articleBase.publishTime,
2991
- redirectUrl: item.assembleCell.itemCell.articleBase.articleURL,
2992
- showNum: item.assembleCell.itemCell.itemCounter.showCount,
2993
- readNum: item.assembleCell.itemCell.itemCounter.readCount,
2994
- likeNum: item.assembleCell.itemCell.itemCounter.diggCount,
2995
- commentNum: item.assembleCell.itemCell.itemCounter.commentCount,
2996
- ...showOriginalData ? {
2997
- originalData: item
2998
- } : {}
2999
- }));
3000
- const api_base_info_json = JSON.parse(articleInfo.api_base_info.app_extra_params);
3001
- return (0, share_namespaceObject.success)({
3002
- articleCell,
3003
- ...onlySuccess ? {
3004
- pagination: {
3005
- total: api_base_info_json.total_count || -1,
3006
- pageNum,
3007
- pageSize
3008
- }
3009
- } : null
3010
- }, "头条号文章文章获取成功");
3011
- } catch (error) {
3012
- return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "头条号文章数据获取失败");
3013
- }
3014
- }
3015
- async function handleWeixinData(params) {
3016
- try {
3017
- const { cookies, token, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false } = params;
3018
- if (!token) return {
3019
- code: 200,
3020
- message: "缺少token",
3021
- data: null
3022
- };
3023
- const http = new Http({
3024
- headers: {
3025
- cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";")
3026
- }
3027
- });
3028
- const ParsePublishPage = (body)=>{
3029
- const match = body.match(/publish_page\s*=\s*({[\s\S]*?});/);
3030
- if (!match) throw new Error('无法提取 publish_page 字段');
3031
- let parsedData = JSON.parse(match[1]);
3032
- const decodeEntities = function(str, decode = false) {
3033
- const encodeMap = [
3034
- "&",
3035
- "&amp;",
3036
- "<",
3037
- "&lt;",
3038
- ">",
3039
- "&gt;",
3040
- " ",
3041
- "&nbsp;",
3042
- '"',
3043
- "&quot;",
3044
- "'",
3045
- "&#39;"
3046
- ];
3047
- const decodeMap = [
3048
- "&#39;",
3049
- "'",
3050
- "&quot;",
3051
- '"',
3052
- "&nbsp;",
3053
- " ",
3054
- "&gt;",
3055
- ">",
3056
- "&lt;",
3057
- "<",
3058
- "&amp;",
3059
- "&",
3060
- "&#60;",
3061
- "<",
3062
- "&#62;",
3063
- ">"
3064
- ];
3065
- const map = decode ? decodeMap : encodeMap;
3066
- let result = str;
3067
- for(let i = 0; i < map.length; i += 2)result = result.replace(new RegExp(map[i], "g"), map[i + 1]);
3068
- return result;
3069
- };
3070
- const finalData = {
3071
- ...parsedData,
3072
- publish_list: parsedData.publish_list.map((item)=>{
3073
- const decoded = decodeEntities(item.publish_info, true);
3074
- const parsedInfo = JSON.parse(decoded);
3075
- return {
3076
- publish_type: item.publish_type,
3077
- publish_info: parsedInfo
3078
- };
3079
- })
3080
- };
3081
- return finalData;
3082
- };
3083
- async function fetchArticles(begin, pageSize, token) {
3084
- return http.api({
3085
- method: "get",
3086
- url: 'https://mp.weixin.qq.com/cgi-bin/appmsgpublish',
3087
- params: {
3088
- sub: "list",
3089
- begin: begin,
3090
- count: pageSize,
3091
- token: token,
3092
- lang: "zh_CN"
3093
- }
3094
- });
3095
- }
3096
- let size = pageSize > 20 ? 20 : pageSize;
3097
- let rawArticlesInfo = await fetchArticles((pageNum - 1) * size, size, token);
3098
- let articlesInfo = ParsePublishPage(rawArticlesInfo);
3099
- if (!onlySuccess && pageSize > 20) {
3100
- let totalFetched = articlesInfo.publish_list.length;
3101
- let nextPage = pageNum + 1;
3102
- while(totalFetched < pageSize){
3103
- const remaining = pageSize - totalFetched;
3104
- const currentPageSize = remaining > 20 ? 20 : remaining;
3105
- let _rawArticlesInfo = await fetchArticles((nextPage - 1) * 20, currentPageSize, token);
3106
- let parsed = ParsePublishPage(_rawArticlesInfo);
3107
- articlesInfo.publish_list = articlesInfo.publish_list.concat(parsed.publish_list);
3108
- totalFetched = articlesInfo.publish_list.length;
3109
- if (parsed.publish_list.length < currentPageSize) break;
3110
- nextPage++;
3111
- }
3112
- }
3113
- const articleCell = articlesInfo?.publish_list.map((item)=>({
3114
- title: item.publish_info.appmsg_info[0].title,
3115
- imageUrl: item.publish_info.appmsg_info[0].cover,
3116
- createTime: item.publish_info.appmsg_info[0].line_info.send_time,
3117
- redirectUrl: item.publish_info.appmsg_info[0].content_url,
3118
- readNum: item.publish_info.appmsg_info[0].read_num,
3119
- likeNum: item.publish_info.appmsg_info[0].old_like_num,
3120
- shareNum: item.publish_info.appmsg_info[0].share_num,
3121
- recommendNum: item.publish_info.appmsg_info[0].like_num,
3122
- ...showOriginalData ? {
3123
- originalData: item
3124
- } : {}
3125
- }));
3126
- return (0, share_namespaceObject.success)({
3127
- articleCell,
3128
- ...onlySuccess ? {
3129
- pagination: {
3130
- total: articlesInfo?.total_count,
3131
- pageNum,
3132
- pageSize
3133
- }
3134
- } : null
3135
- }, "微信文章文章获取成功");
3136
- } catch (error) {
3137
- return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "微信文章数据获取失败");
3138
- }
3139
- }
3140
- async function handleBaijiahaoData(params) {
3141
- try {
3142
- const { cookies, token, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false } = params;
3143
- if (!token) return {
3144
- code: 200,
3145
- message: "缺少token",
3146
- data: null
3147
- };
3148
- const http = new Http({
3149
- headers: {
3150
- cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
3151
- token: token
3152
- }
3153
- });
3154
- async function fetchArticles(pageNum, pageSize, onlySuccess = false) {
3155
- return await http.api({
3156
- method: "get",
3157
- url: "https://baijiahao.baidu.com/pcui/article/lists",
3158
- params: {
3159
- currentPage: pageNum,
3160
- pageSize: pageSize,
3161
- search: "",
3162
- type: "",
3163
- collection: onlySuccess ? "publish" : "",
3164
- clearBeforeFetch: false,
3165
- dynamic: 1
3166
- }
3167
- });
3168
- }
3169
- const articleInfo = await fetchArticles(pageNum, pageSize, onlySuccess);
3170
- let filtered = articleInfo.data.list.filter((item)=>"draft" !== item.status);
3171
- const totalPage = articleInfo.data.page?.totalPage || 1;
3172
- let currentPage = pageNum + 1;
3173
- const usedPages = new Set();
3174
- while(filtered.length < pageSize && currentPage <= totalPage){
3175
- if (usedPages.has(currentPage)) {
3176
- currentPage++;
3177
- continue;
3178
- }
3179
- const res = await fetchArticles(currentPage, pageSize, onlySuccess);
3180
- usedPages.add(currentPage);
3181
- const validItems = res.data.list.filter((item)=>"draft" !== item.status);
3182
- filtered.push(...validItems);
3183
- currentPage++;
3184
- }
3185
- const final = filtered.slice(0, pageSize);
3186
- const articleCell = final.map((item)=>({
3187
- title: item.title,
3188
- imageUrl: JSON.parse(item.cover_images)[0].src,
3189
- createTime: Math.floor(new Date(item.publish_at.replace(/-/g, "/")).getTime() / 1000),
3190
- redirectUrl: item.url,
3191
- recommendNum: item.rec_amount,
3192
- collectNum: item.collection_amount,
3193
- readNum: item.read_amount,
3194
- likeNum: item.like_amount,
3195
- commentNum: item.comment_amount,
3196
- shareNum: item.share_amount,
3197
- ...showOriginalData ? {
3198
- originalData: item
3199
- } : {}
3200
- }));
3201
- return (0, share_namespaceObject.success)({
3202
- articleCell,
3203
- ...onlySuccess ? {
3204
- pagination: {
3205
- total: articleInfo.data.page?.totalCount,
3206
- pageNum,
3207
- pageSize
3208
- }
3209
- } : null
3210
- }, "百家号文章数据获取成功");
3211
- } catch (error) {
3212
- return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "百家号文章数据获取失败");
3213
- }
3214
- }
3215
- async function handleXiaohongshuData(params) {
3216
- try {
3217
- const { cookies, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false } = params;
3218
- const xsEncrypt = new XsEncrypt();
3219
- const a1Cookie = cookies.find((it)=>"a1" === it.name)?.value;
3220
- if (!a1Cookie) return {
3221
- code: 200,
3222
- message: "账号数据异常",
3223
- data: null
3224
- };
3225
- if (onlySuccess && 10 != pageSize) return {
3226
- code: 200,
3227
- message: "小红书pageSize不可修改",
3228
- data: null
3229
- };
3230
- const http = new Http({
3231
- headers: {
3232
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
3233
- referer: "https://creator.xiaohongshu.com",
3234
- origin: "https://creator.xiaohongshu.com"
3235
- }
3236
- });
3237
- async function fetchArticles(pageNum, a1Cookie, onlySuccess = false) {
3238
- const xt = Date.now().toString();
3239
- const serveUrl = `/web_api/sns/v5/creator/note/user/posted?tab=${onlySuccess ? 1 : 0}&page=${pageNum - 1}`;
3240
- const xs = await xsEncrypt.encryptXs(serveUrl, a1Cookie, xt);
3241
- return await http.api({
3242
- method: "get",
3243
- baseURL: "https://edith.xiaohongshu.com",
3244
- url: serveUrl,
3245
- headers: {
3246
- "x-s": xs,
3247
- "x-t": xt
3248
- }
3249
- });
3250
- }
3251
- const articleInfo = await fetchArticles(pageNum, a1Cookie, onlySuccess);
3252
- let hasNextpage = -1 != articleInfo.data.page;
3253
- let filtered = articleInfo.data.notes;
3254
- let currentPage = pageNum + 1;
3255
- const usedPages = new Set();
3256
- while(filtered.length < pageSize && hasNextpage){
3257
- if (usedPages.has(currentPage)) {
3258
- currentPage++;
3259
- continue;
3260
- }
3261
- const res = await fetchArticles(currentPage, a1Cookie, onlySuccess);
3262
- usedPages.add(currentPage);
3263
- const validItems = res.data.notes;
3264
- filtered.push(...validItems);
3265
- currentPage++;
3266
- hasNextpage = -1 != res.data.page;
3267
- }
3268
- const final = filtered.slice(0, pageSize);
3269
- const articleCell = final.map((item)=>({
3270
- title: item.display_title,
3271
- imageUrl: item.images_list[0].url,
3272
- createTime: Math.floor(new Date(item.time.replace(/-/g, "/")).getTime() / 1000),
3273
- redirectUrl: `https://www.xiaohongshu.com/explore/${item.id}?xsec_token=${item.xsec_token}&xsec_source=pc_creatormng`,
3274
- readNum: item.view_count,
3275
- likeNum: item.likes,
3276
- commentNum: item.comments_count,
3277
- collectNum: item.collected_count,
3278
- shareNum: item.shared_count,
3279
- ...showOriginalData ? {
3280
- originalData: item
3281
- } : {}
3282
- }));
3283
- return (0, share_namespaceObject.success)({
3284
- articleCell,
3285
- ...onlySuccess ? {
3286
- pagination: {
3287
- nextPage: hasNextpage,
3288
- pageNum,
3289
- pageSize
3290
- }
3291
- } : null
3292
- }, "小红书文章数据获取成功");
3293
- } catch (error) {
3294
- return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "小红书文章数据获取失败");
3295
- }
3296
- }
3297
- const FetchArticles = async (_task, params)=>{
3298
- const { platform } = params;
3299
- switch(platform){
3300
- case "toutiao":
3301
- return handleToutiaoData(params);
3302
- case "weixin":
3303
- return handleWeixinData(params);
3304
- case "baijiahao":
3305
- return handleBaijiahaoData(params);
3306
- case "xiaohongshu":
3307
- return handleXiaohongshuData(params);
3308
- default:
3309
- return (0, share_namespaceObject.success)(null, "暂不支持该平台");
3310
- }
3311
- };
3312
- const getWeixinConfig = async (_task, params)=>{
3313
- const http = new Http({
3314
- headers: {
3315
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";")
3316
- }
3317
- });
3318
- const fingerprint = "4695500bc93ab4ce8fb2692da6564e04";
3319
- const res = await http.api({
3320
- method: "get",
3321
- url: "https://mp.weixin.qq.com/cgi-bin/masssendpage",
3322
- params: {
3323
- f: 'json',
3324
- token: params.token,
3325
- lang: 'zh_CN',
3326
- ajax: 1,
3327
- fingerprint: fingerprint,
3328
- random: Math.random().toString()
3329
- }
3330
- });
3331
- const filtered = {
3332
- publishQuota: 0 === res.base_resp.ret ? res.quota_detail_list.filter((item)=>"kQuotaTypeMassSendNormal" === item.quota_type).map((item)=>item.quota_item_list) : []
3333
- };
3334
- return (0, share_namespaceObject.success)(filtered, 0 === res.base_resp.ret ? "微信配置信息获取成功!" : "微信配置信息获取失败!");
3335
- };
3336
2617
  const weitoutiaoPublish_mock_mockAction = async (task, params)=>{
3337
2618
  const tmpCachePath = task.getTmpPath();
3338
2619
  const http = new Http({
@@ -4858,7 +4139,8 @@ var __webpack_exports__ = {};
4858
4139
  915: "所属C端账号手机号被修改,请重新登录",
4859
4140
  914: "所属C端账号密码被修改,请重新登录",
4860
4141
  903: "账户已登出,需重新登陆重试!",
4861
- 902: "登录已过期,请重新登录!"
4142
+ 902: "登录已过期,请重新登录!",
4143
+ 906: "账号存在风险,请重新登录"
4862
4144
  };
4863
4145
  const mock_xsEncrypt = new XsEncrypt();
4864
4146
  const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
@@ -4901,33 +4183,63 @@ var __webpack_exports__ = {};
4901
4183
  "x-t": xt
4902
4184
  }
4903
4185
  });
4904
- const coverIds = coverIdInfo.data.uploadTempPermits[0].fileIds;
4905
- const ossToken = coverIdInfo.data.uploadTempPermits[0].token;
4906
- if (!coverIds || !ossToken) return {
4186
+ let uploadInfos = [];
4187
+ coverIdInfo.data.uploadTempPermits.map((item)=>{
4188
+ uploadInfos.push({
4189
+ bucket: "",
4190
+ uploadAddr: item.uploadAddr,
4191
+ fileIds: item.fileIds,
4192
+ token: item.token
4193
+ });
4194
+ });
4195
+ if (0 === uploadInfos.length) return {
4907
4196
  code: 200,
4908
4197
  message: "图片上传失败,请稍后重试!",
4909
4198
  data: ""
4910
4199
  };
4911
- const uploadFile = async (url, index)=>{
4200
+ const uploadFile = async (url, index, infoIndex = 0)=>{
4912
4201
  const fileName = (0, share_namespaceObject.getFilenameFromUrl)(url);
4913
4202
  const localUrl = await (0, share_namespaceObject.downloadImage)(url, external_node_path_default().join(tmpCachePath, fileName));
4914
- const ossFileId = coverIds[index];
4915
4203
  const fileBuffer = external_node_fs_default().readFileSync(localUrl);
4916
- await http.api({
4917
- method: "put",
4918
- url: `https://ros-upload.xiaohongshu.com/${ossFileId}`,
4919
- data: fileBuffer,
4920
- headers: {
4921
- "x-cos-security-token": ossToken
4922
- },
4923
- defaultErrorMsg: "图片上传异常,请稍后重试发布。"
4924
- });
4925
- return {
4926
- ossFileId,
4927
- ossToken
4204
+ const tryUpload = async (uploadIndex)=>{
4205
+ if (uploadIndex >= uploadInfos.length) {
4206
+ external_node_fs_default().unlinkSync(localUrl);
4207
+ return {
4208
+ ossFileId: "",
4209
+ ossToken: ""
4210
+ };
4211
+ }
4212
+ const currentInfo = uploadInfos[uploadIndex];
4213
+ const ossFileId = currentInfo.fileIds[0];
4214
+ const ossToken = currentInfo.token;
4215
+ const ossDomain = currentInfo.uploadAddr;
4216
+ try {
4217
+ await http.api({
4218
+ method: "put",
4219
+ url: `https://${ossDomain}/${ossFileId}`,
4220
+ data: fileBuffer,
4221
+ headers: {
4222
+ "x-cos-security-token": ossToken
4223
+ },
4224
+ defaultErrorMsg: "图片上传异常,请稍后重试发布。"
4225
+ });
4226
+ return {
4227
+ ossFileId,
4228
+ ossToken
4229
+ };
4230
+ } catch (error) {
4231
+ return tryUpload(uploadIndex + 1);
4232
+ }
4928
4233
  };
4234
+ return tryUpload(infoIndex);
4929
4235
  };
4930
4236
  const coverInfos = await Promise.all(params.banners.map((it, idx)=>uploadFile(it, idx)));
4237
+ const invalidUpload = coverInfos.find((it)=>"" === it.ossToken || "" == it.ossFileId);
4238
+ if (invalidUpload) return {
4239
+ code: 200,
4240
+ message: "图片上传异常,请稍后重试发布。",
4241
+ data: ""
4242
+ };
4931
4243
  if (params.topic && params.topic.length > 0) await Promise.all(params.topic.map(async (topic)=>{
4932
4244
  if (!topic["id"]) {
4933
4245
  const topicData = {
@@ -5264,7 +4576,9 @@ var __webpack_exports__ = {};
5264
4576
  if ("mockApi" === params.actionType) return xiaohongshuPublish_mock_mockAction(task, params);
5265
4577
  return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
5266
4578
  };
5267
- var package_namespaceObject = JSON.parse('{"i8":"1.2.14-beta.5"}');
4579
+ var package_namespaceObject = {
4580
+ i8: "1.2.14"
4581
+ };
5268
4582
  class Action {
5269
4583
  constructor(task){
5270
4584
  this.task = task;
@@ -5285,24 +4599,6 @@ var __webpack_exports__ = {};
5285
4599
  } else this.task.logger.info(`${func.name} action success`);
5286
4600
  return responseData;
5287
4601
  }
5288
- FetchArticles(params) {
5289
- return this.bindTask(FetchArticles, params);
5290
- }
5291
- SearchAccountInfo(params) {
5292
- return this.bindTask(SearchAccountInfo, params);
5293
- }
5294
- TTSessionCheck(params) {
5295
- return this.bindTask(TTSessionCheck, params);
5296
- }
5297
- WxSessionCheck(params) {
5298
- return this.bindTask(WxSessionCheck, params);
5299
- }
5300
- XhsSessionCheck(params) {
5301
- return this.bindTask(XhsSessionCheck, params);
5302
- }
5303
- BjhSessionCheck(params) {
5304
- return this.bindTask(BjhSessionCheck, params);
5305
- }
5306
4602
  searchToutiaoTopicList(params) {
5307
4603
  return this.bindTask(searchToutiaoTopicList, params);
5308
4604
  }
@@ -5327,9 +4623,6 @@ var __webpack_exports__ = {};
5327
4623
  getToutiaoConfig(params) {
5328
4624
  return this.bindTask(getToutiaoConfig, params);
5329
4625
  }
5330
- getWeixinConfig(params) {
5331
- return this.bindTask(getWeixinConfig, params);
5332
- }
5333
4626
  getBaijiahaoConfig(params) {
5334
4627
  return this.bindTask(getBaijiahaoConfig, params);
5335
4628
  }