@iflyrpa/actions 1.2.22 → 1.2.24

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
@@ -2047,8 +2047,7 @@ const errnoMap = {
2047
2047
  20040034: "封面图片推荐jpg、png格式,不支持gif格式。",
2048
2048
  20040124: "服务器异常,请稍后重试!",
2049
2049
  20040001: "当前用户未登录,请登陆后重试!",
2050
- 401100025: "该应用不支持此媒资类型",
2051
- 401100033: "图片宽高不满足要求"
2050
+ 401100025: "该应用不支持此媒资类型"
2052
2051
  };
2053
2052
  const mockAction = async (task, params)=>{
2054
2053
  const { baijiahaoSingleCover, baijiahaoMultCover, baijiahaoCoverType } = params.settingInfo;
@@ -2173,7 +2172,6 @@ const mockAction = async (task, params)=>{
2173
2172
  };
2174
2173
  const isDraft = "draft" === params.saveType;
2175
2174
  const saveUrl = isDraft ? "https://baijiahao.baidu.com/pcui/article/save?callback=bjhdraft" : "https://baijiahao.baidu.com/pcui/article/publish?callback=bjhpublish";
2176
- task._timerRecord['PrePublish'] = Date.now();
2177
2175
  const res = await http.api({
2178
2176
  method: "post",
2179
2177
  url: saveUrl,
@@ -2311,7 +2309,6 @@ const rpaAction = async (task, params)=>{
2311
2309
  }
2312
2310
  };
2313
2311
  page.on("response", handleResponse);
2314
- task._timerRecord['PrePublish'] = Date.now();
2315
2312
  const operatorContainer = page.locator(".editor-component-operator");
2316
2313
  if ("draft" === params.saveType) await operatorContainer.locator(".op-btn-outter-content").filter({
2317
2314
  hasText: "存草稿"
@@ -2613,57 +2610,366 @@ const searchXiaohongshuLocation = async (_task, params)=>{
2613
2610
  return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)([]);
2614
2611
  }
2615
2612
  };
2616
- class XsEncrypt {
2617
- async encryptMD5(url) {
2618
- return __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__["default"].createHash("md5").update(url, "utf8").digest("hex");
2619
- }
2620
- async encryptText(text) {
2621
- const textEncoded = __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from(text).toString("base64");
2622
- const cipher = __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__["default"].createCipheriv("aes-128-cbc", new Uint8Array(this.keyBytes), new Uint8Array(this.iv));
2623
- const ciphertext = cipher.update(textEncoded, "utf8", "base64");
2624
- return ciphertext + cipher.final("base64");
2625
- }
2626
- async base64ToHex(encodedData) {
2627
- const decodedData = __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from(encodedData, "base64");
2628
- return decodedData.toString("hex");
2629
- }
2630
- async encryptPayload(payload, platform) {
2631
- const hexPayload = await this.base64ToHex(payload);
2632
- const obj = {
2633
- signSvn: "56",
2634
- signType: "x2",
2635
- appID: platform,
2636
- signVersion: "1",
2637
- payload: hexPayload
2613
+ class CryptoConfig {
2614
+ static{
2615
+ this.MAX_32BIT = 0xFFFFFFFF;
2616
+ }
2617
+ static{
2618
+ this.MAX_SIGNED_32BIT = 0x7FFFFFFF;
2619
+ }
2620
+ static{
2621
+ this.BASE58_ALPHABET = "NOPQRStuvwxWXYZabcyz012DEFTKLMdefghijkl4563GHIJBC7mnop89+/AUVqrsOPQefghijkABCDEFGuvwz0123456789xy";
2622
+ }
2623
+ static{
2624
+ this.STANDARD_BASE64_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
2625
+ }
2626
+ static{
2627
+ this.CUSTOM_BASE64_ALPHABET = "ZmserbBoHQtNP+wOcza/LpngG8yJq42KWYj0DSfdikx3VT16IlUAFM97hECvuRX5";
2628
+ }
2629
+ static{
2630
+ this.BASE58_BASE = 58;
2631
+ }
2632
+ static{
2633
+ this.BYTE_SIZE = 256;
2634
+ }
2635
+ static{
2636
+ this.HEX_KEY = "af572b95ca65b2d9ec76bb5d2e97cb653299cc663399cc663399cce673399cce6733190c06030100000000008040209048241289c4e271381c0e0703018040a05028148ac56231180c0683c16030984c2693c964b259ac56abd5eaf5fafd7e3f9f4f279349a4d2e9743a9d4e279349a4d2e9f47a3d1e8f47239148a4d269341a8d4623110884422190c86432994ca6d3e974baddee773b1d8e47a35128148ac5623198cce6f3f97c3e1f8f47a3d168b45aad562b158ac5e2f1f87c3e9f4f279349a4d269b45aad56";
2637
+ }
2638
+ static{
2639
+ this.TIMESTAMP_BYTES_COUNT = 16;
2640
+ }
2641
+ static{
2642
+ this.TIMESTAMP_XOR_KEY = 41;
2643
+ }
2644
+ static{
2645
+ this.STARTUP_TIME_OFFSET_MIN = 1000;
2646
+ }
2647
+ static{
2648
+ this.STARTUP_TIME_OFFSET_MAX = 4000;
2649
+ }
2650
+ static{
2651
+ this.EXPECTED_HEX_LENGTH = 32;
2652
+ }
2653
+ static{
2654
+ this.OUTPUT_BYTE_COUNT = 8;
2655
+ }
2656
+ static{
2657
+ this.HEX_CHUNK_SIZE = 2;
2658
+ }
2659
+ static{
2660
+ this.VERSION_BYTES = [
2661
+ 119,
2662
+ 104,
2663
+ 96,
2664
+ 41
2665
+ ];
2666
+ }
2667
+ static{
2668
+ this.FIXED_SEPARATOR_BYTES = [
2669
+ 16,
2670
+ 0,
2671
+ 0,
2672
+ 0,
2673
+ 15,
2674
+ 5,
2675
+ 0,
2676
+ 0,
2677
+ 47,
2678
+ 1,
2679
+ 0,
2680
+ 0
2681
+ ];
2682
+ }
2683
+ static{
2684
+ this.RANDOM_BYTE_COUNT = 4;
2685
+ }
2686
+ static{
2687
+ this.FIXED_INT_VALUE_1 = 15;
2688
+ }
2689
+ static{
2690
+ this.FIXED_INT_VALUE_2 = 1291;
2691
+ }
2692
+ static{
2693
+ this.ENV_STATIC_BYTES = [
2694
+ 1,
2695
+ 249,
2696
+ 83,
2697
+ 102,
2698
+ 103,
2699
+ 201,
2700
+ 181,
2701
+ 131,
2702
+ 99,
2703
+ 94,
2704
+ 7,
2705
+ 68,
2706
+ 250,
2707
+ 132,
2708
+ 21
2709
+ ];
2710
+ }
2711
+ static{
2712
+ this.SIGNATURE_DATA_TEMPLATE = {
2713
+ x0: "4.2.2",
2714
+ x1: "xhs-pc-web",
2715
+ x2: "Windows",
2716
+ x3: "",
2717
+ x4: "object"
2638
2718
  };
2639
- const jsonString = JSON.stringify(obj, null, 0);
2640
- return __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from(jsonString).toString("base64");
2641
2719
  }
2642
- async encryptXs(url, a1, ts, platform = "xhs-pc-web") {
2643
- 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};`;
2644
- return `XYW_${await this.encryptPayload(await this.encryptText(text), platform)}`;
2720
+ static{
2721
+ this.X3_PREFIX = "mns0101_";
2722
+ }
2723
+ static{
2724
+ this.XYS_PREFIX = "XYS_";
2725
+ }
2726
+ }
2727
+ class RandomGenerator {
2728
+ generateRandomBytes(byteCount) {
2729
+ return Array.from({
2730
+ length: byteCount
2731
+ }, ()=>Math.floor(Math.random() * CryptoConfig.BYTE_SIZE));
2732
+ }
2733
+ generateRandomByteInRange(minVal, maxVal) {
2734
+ return Math.floor(Math.random() * (maxVal - minVal + 1)) + minVal;
2735
+ }
2736
+ generateRandomInt() {
2737
+ return Math.floor(Math.random() * (CryptoConfig.MAX_32BIT + 1));
2738
+ }
2739
+ }
2740
+ class HexProcessor {
2741
+ hexStringToBytes(hexString) {
2742
+ const byteValues = [];
2743
+ for(let i = 0; i < hexString.length; i += CryptoConfig.HEX_CHUNK_SIZE){
2744
+ const hexChunk = hexString.substr(i, CryptoConfig.HEX_CHUNK_SIZE);
2745
+ byteValues.push(parseInt(hexChunk, 16));
2746
+ }
2747
+ return byteValues;
2748
+ }
2749
+ processHexParameter(hexString, xorKey) {
2750
+ if (hexString.length !== CryptoConfig.EXPECTED_HEX_LENGTH) throw new Error(`hex parameter must be ${CryptoConfig.EXPECTED_HEX_LENGTH} characters`);
2751
+ const byteValues = this.hexStringToBytes(hexString);
2752
+ return byteValues.map((byteVal)=>byteVal ^ xorKey).slice(0, CryptoConfig.OUTPUT_BYTE_COUNT);
2645
2753
  }
2646
- dumps(...rest) {
2647
- const [data, replacer = null, space = 0] = rest;
2648
- return JSON.stringify(data, replacer, space).replace(/\n/g, "").replace(/":\s+"/g, '":"');
2754
+ }
2755
+ class BitOperations {
2756
+ normalizeTo32bit(value) {
2757
+ return value & CryptoConfig.MAX_32BIT;
2758
+ }
2759
+ toSigned32bit(unsignedValue) {
2760
+ if (unsignedValue > CryptoConfig.MAX_SIGNED_32BIT) return unsignedValue - 0x100000000;
2761
+ return unsignedValue;
2762
+ }
2763
+ computeSeedValue(seed32bit) {
2764
+ const normalizedSeed = this.normalizeTo32bit(seed32bit);
2765
+ const shift15Bits = normalizedSeed >> 15;
2766
+ const shift13Bits = normalizedSeed >> 13;
2767
+ const shift12Bits = normalizedSeed >> 12;
2768
+ const shift10Bits = normalizedSeed >> 10;
2769
+ const xorMaskedResult = shift15Bits & ~shift13Bits | shift13Bits & ~shift15Bits;
2770
+ const shiftedResult = (xorMaskedResult ^ shift12Bits ^ shift10Bits) << 31 & CryptoConfig.MAX_32BIT;
2771
+ return this.toSigned32bit(shiftedResult);
2772
+ }
2773
+ xorTransformArray(sourceIntegers) {
2774
+ const resultBytes = new Uint8Array(sourceIntegers.length);
2775
+ const hexKeyBytes = __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from(CryptoConfig.HEX_KEY, 'hex');
2776
+ for(let index = 0; index < sourceIntegers.length; index++)resultBytes[index] = (sourceIntegers[index] ^ hexKeyBytes[index]) & 0xFF;
2777
+ return resultBytes;
2778
+ }
2779
+ }
2780
+ class Base58Encoder {
2781
+ encodeToB58(inputBytes) {
2782
+ const bytesArray = Array.isArray(inputBytes) ? inputBytes : Array.from(inputBytes);
2783
+ const numberAccumulator = this.bytesToNumber(bytesArray);
2784
+ const leadingZerosCount = this.countLeadingZeros(bytesArray);
2785
+ const encodedCharacters = this.numberToBase58Chars(numberAccumulator);
2786
+ encodedCharacters.push(...Array(leadingZerosCount).fill(CryptoConfig.BASE58_ALPHABET[0]));
2787
+ return encodedCharacters.reverse().join('');
2788
+ }
2789
+ bytesToNumber(inputBytes) {
2790
+ const bytesArray = Array.isArray(inputBytes) ? inputBytes : Array.from(inputBytes);
2791
+ let result = 0n;
2792
+ const BYTE_SIZE = 256n;
2793
+ for (const byteValue of bytesArray)result = result * BYTE_SIZE + BigInt(byteValue);
2794
+ return result;
2795
+ }
2796
+ countLeadingZeros(inputBytes) {
2797
+ let count = 0;
2798
+ for (const byteValue of inputBytes)if (0 === byteValue) count++;
2799
+ else break;
2800
+ return count;
2801
+ }
2802
+ numberToBase58Chars(number) {
2803
+ const characters = [];
2804
+ const base = BigInt(CryptoConfig.BASE58_BASE);
2805
+ while(number > 0n){
2806
+ const remainder = number % base;
2807
+ characters.push(CryptoConfig.BASE58_ALPHABET[Number(remainder)]);
2808
+ number /= base;
2809
+ }
2810
+ return characters;
2649
2811
  }
2812
+ }
2813
+ class Base64Encoder {
2814
+ encodeToB64(dataToEncode) {
2815
+ const dataBytes = __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from(dataToEncode, 'utf-8');
2816
+ const standardEncodedString = dataBytes.toString('base64');
2817
+ let result = '';
2818
+ for (const char of standardEncodedString){
2819
+ const index = CryptoConfig.STANDARD_BASE64_ALPHABET.indexOf(char);
2820
+ if (-1 !== index) result += CryptoConfig.CUSTOM_BASE64_ALPHABET[index];
2821
+ else result += char;
2822
+ }
2823
+ return result;
2824
+ }
2825
+ }
2826
+ class RequestSignatureValidator {
2827
+ static validateMethod(method) {
2828
+ if ('string' != typeof method) throw new TypeError(`method must be string, got ${typeof method}`);
2829
+ const upperMethod = method.trim().toUpperCase();
2830
+ if ('GET' !== upperMethod && 'POST' !== upperMethod) throw new Error(`method must be 'GET' or 'POST', got '${upperMethod}'`);
2831
+ return upperMethod;
2832
+ }
2833
+ static validateUri(uri) {
2834
+ if ('string' != typeof uri) throw new TypeError(`uri must be string, got ${typeof uri}`);
2835
+ if (!uri.trim()) throw new Error('uri cannot be empty');
2836
+ return uri.trim();
2837
+ }
2838
+ static validateA1Value(a1Value) {
2839
+ if ('string' != typeof a1Value) throw new TypeError(`a1_value must be string, got ${typeof a1Value}`);
2840
+ if (!a1Value.trim()) throw new Error('a1_value cannot be empty');
2841
+ return a1Value.trim();
2842
+ }
2843
+ static validateXsecAppid(xsecAppid) {
2844
+ if ('string' != typeof xsecAppid) throw new TypeError(`xsec_appid must be string, got ${typeof xsecAppid}`);
2845
+ if (!xsecAppid.trim()) throw new Error('xsec_appid cannot be empty');
2846
+ return xsecAppid.trim();
2847
+ }
2848
+ static validatePayload(payload) {
2849
+ if (null !== payload && 'object' != typeof payload) throw new TypeError(`payload must be object or null, got ${typeof payload}`);
2850
+ if (null != payload) {
2851
+ for(const key in payload)if ('string' != typeof key) throw new TypeError(`payload keys must be string, got ${typeof key} for key '${key}'`);
2852
+ }
2853
+ return payload;
2854
+ }
2855
+ }
2856
+ class CryptoProcessor {
2650
2857
  constructor(){
2651
- this.words = [
2652
- 929260340,
2653
- 1633971297,
2654
- 895580464,
2655
- 925905270
2858
+ this.bitOps = new BitOperations();
2859
+ this.b58encoder = new Base58Encoder();
2860
+ this.b64encoder = new Base64Encoder();
2861
+ this.hexProcessor = new HexProcessor();
2862
+ this.randomGen = new RandomGenerator();
2863
+ }
2864
+ encodeTimestamp(ts, randomizeFirst = true) {
2865
+ const key = Array(8).fill(CryptoConfig.TIMESTAMP_XOR_KEY);
2866
+ const arr = this.intToLeBytes(ts, 8);
2867
+ const encoded = arr.map((a, i)=>a ^ key[i]);
2868
+ if (randomizeFirst) encoded[0] = this.randomGen.generateRandomByteInRange(0, 255);
2869
+ return encoded;
2870
+ }
2871
+ intToLeBytes(val, length = 4) {
2872
+ const arr = [];
2873
+ for(let i = 0; i < length; i++){
2874
+ arr.push(0xFF & val);
2875
+ val >>>= 8;
2876
+ }
2877
+ return arr;
2878
+ }
2879
+ strToLenPrefixedBytes(s) {
2880
+ const buf = __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from(s, 'utf-8');
2881
+ return [
2882
+ buf.length,
2883
+ ...Array.from(buf)
2656
2884
  ];
2657
- this.keyBytes = __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.concat(this.words.map((word)=>new Uint8Array(__WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from([
2658
- word >> 24 & 0xff,
2659
- word >> 16 & 0xff,
2660
- word >> 8 & 0xff,
2661
- 0xff & word
2662
- ]))));
2663
- this.iv = __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from("4uzjr7mbsibcaldp", "utf8");
2885
+ }
2886
+ buildEnvironmentBytes() {
2887
+ return [
2888
+ CryptoConfig.ENV_STATIC_BYTES[0],
2889
+ this.randomGen.generateRandomByteInRange(10, 254),
2890
+ ...CryptoConfig.ENV_STATIC_BYTES.slice(1)
2891
+ ];
2892
+ }
2893
+ buildPayloadArray(hexParameter, a1Value, appIdentifier = "xhs-pc-web", stringParam = "") {
2894
+ const randNum = this.randomGen.generateRandomInt();
2895
+ const ts = Date.now();
2896
+ const startupTs = ts - (CryptoConfig.STARTUP_TIME_OFFSET_MIN + this.randomGen.generateRandomByteInRange(0, CryptoConfig.STARTUP_TIME_OFFSET_MAX - CryptoConfig.STARTUP_TIME_OFFSET_MIN));
2897
+ const arr = [];
2898
+ arr.push(...CryptoConfig.VERSION_BYTES);
2899
+ const randBytes = this.intToLeBytes(randNum, 4);
2900
+ arr.push(...randBytes);
2901
+ const xorKey = randBytes[0];
2902
+ arr.push(...this.encodeTimestamp(ts, true));
2903
+ arr.push(...this.intToLeBytes(startupTs, 8));
2904
+ arr.push(...this.intToLeBytes(CryptoConfig.FIXED_INT_VALUE_1));
2905
+ arr.push(...this.intToLeBytes(CryptoConfig.FIXED_INT_VALUE_2));
2906
+ const stringParamLength = __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from(stringParam, 'utf-8').length;
2907
+ arr.push(...this.intToLeBytes(stringParamLength));
2908
+ const md5Bytes = __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from(hexParameter, 'hex');
2909
+ const xorMd5Bytes = Array.from(md5Bytes).map((b)=>b ^ xorKey);
2910
+ arr.push(...xorMd5Bytes.slice(0, 8));
2911
+ arr.push(...this.strToLenPrefixedBytes(a1Value));
2912
+ arr.push(...this.strToLenPrefixedBytes(appIdentifier));
2913
+ arr.push(CryptoConfig.ENV_STATIC_BYTES[0], this.randomGen.generateRandomByteInRange(0, 255), ...CryptoConfig.ENV_STATIC_BYTES.slice(1));
2914
+ return arr;
2664
2915
  }
2665
2916
  }
2666
- const searchXiaohongshuTopicList_xsEncrypt = new XsEncrypt();
2917
+ class Xhshow {
2918
+ constructor(){
2919
+ this.cryptoProcessor = new CryptoProcessor();
2920
+ }
2921
+ buildContentString(method, uri, payload) {
2922
+ payload = payload || {};
2923
+ if ("POST" === method.toUpperCase()) return uri + JSON.stringify(payload);
2924
+ if (!payload || 0 === Object.keys(payload).length) return uri;
2925
+ {
2926
+ const params = Object.entries(payload).map(([key, value])=>{
2927
+ let valueStr = '';
2928
+ if (Array.isArray(value)) valueStr = value.map((v)=>String(v)).join(',');
2929
+ else if (null != value) valueStr = String(value);
2930
+ return `${key}=${valueStr}`;
2931
+ });
2932
+ return `${uri}?${params.join('&')}`;
2933
+ }
2934
+ }
2935
+ generateDValue(content) {
2936
+ return __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__["default"].createHash('md5').update(content, 'utf-8').digest('hex');
2937
+ }
2938
+ buildSignature(dValue, a1Value, xsecAppid = "xhs-pc-web", stringParam = "") {
2939
+ const payloadArray = this.cryptoProcessor.buildPayloadArray(dValue, a1Value, xsecAppid, stringParam);
2940
+ const xorResult = this.cryptoProcessor.bitOps.xorTransformArray(payloadArray);
2941
+ return this.cryptoProcessor.b58encoder.encodeToB58(xorResult);
2942
+ }
2943
+ signXs(method, uri, a1Value, xsecAppid = "xhs-pc-web", payload) {
2944
+ const validatedMethod = RequestSignatureValidator.validateMethod(method);
2945
+ const validatedUri = RequestSignatureValidator.validateUri(uri);
2946
+ const validatedA1Value = RequestSignatureValidator.validateA1Value(a1Value);
2947
+ const validatedXsecAppid = RequestSignatureValidator.validateXsecAppid(xsecAppid);
2948
+ const validatedPayload = RequestSignatureValidator.validatePayload(payload);
2949
+ const signatureData = {
2950
+ ...CryptoConfig.SIGNATURE_DATA_TEMPLATE
2951
+ };
2952
+ const contentString = this.buildContentString(validatedMethod, validatedUri, validatedPayload);
2953
+ const dValue = this.generateDValue(contentString);
2954
+ signatureData.x3 = CryptoConfig.X3_PREFIX + this.buildSignature(dValue, validatedA1Value, validatedXsecAppid, contentString);
2955
+ return CryptoConfig.XYS_PREFIX + this.cryptoProcessor.b64encoder.encodeToB64(JSON.stringify(signatureData));
2956
+ }
2957
+ signXsGet(uri, a1Value, xsecAppid = "xhs-pc-web", params) {
2958
+ const validatedUri = RequestSignatureValidator.validateUri(uri);
2959
+ const validatedA1Value = RequestSignatureValidator.validateA1Value(a1Value);
2960
+ const validatedXsecAppid = RequestSignatureValidator.validateXsecAppid(xsecAppid);
2961
+ const validatedParams = RequestSignatureValidator.validatePayload(params);
2962
+ return this.signXs("GET", validatedUri, validatedA1Value, validatedXsecAppid, validatedParams);
2963
+ }
2964
+ signXsPost(uri, a1Value, xsecAppid = "xhs-pc-web", payload) {
2965
+ const validatedUri = RequestSignatureValidator.validateUri(uri);
2966
+ const validatedA1Value = RequestSignatureValidator.validateA1Value(a1Value);
2967
+ const validatedXsecAppid = RequestSignatureValidator.validateXsecAppid(xsecAppid);
2968
+ const validatedPayload = RequestSignatureValidator.validatePayload(payload);
2969
+ return this.signXs("POST", validatedUri, validatedA1Value, validatedXsecAppid, validatedPayload);
2970
+ }
2971
+ }
2972
+ const searchXiaohongshuTopicList_xsEncrypt = new Xhshow();
2667
2973
  const searchXiaohongshuTopicList = async (_task, params)=>{
2668
2974
  const http = new Http({
2669
2975
  headers: {
@@ -2691,9 +2997,8 @@ const searchXiaohongshuTopicList = async (_task, params)=>{
2691
2997
  page: 1
2692
2998
  }
2693
2999
  };
2694
- const topicDataStr = searchXiaohongshuTopicList_xsEncrypt.dumps(topicData);
2695
- const fatchTopic = `/web_api/sns/v1/search/topic${topicDataStr}`;
2696
- const xs = await searchXiaohongshuTopicList_xsEncrypt.encryptXs(fatchTopic, a1Cookie, xt);
3000
+ const fatchTopic = "/web_api/sns/v1/search/topic";
3001
+ const xs = searchXiaohongshuTopicList_xsEncrypt.signXsPost(fatchTopic, a1Cookie, "xhs-pc-web", topicData);
2697
3002
  const result = await http.api({
2698
3003
  method: "post",
2699
3004
  url: "https://edith.xiaohongshu.com/web_api/sns/v1/search/topic",
@@ -2874,7 +3179,6 @@ const mock_mockAction = async (task, params)=>{
2874
3179
  article_ad_type: getAddTypeValue(params.settingInfo.toutiaoAd),
2875
3180
  claim_exclusive: toutiaoExclusive ? toutiaoExclusive : toutiaoOriginal?.includes("exclusive") ? 1 : 0
2876
3181
  };
2877
- task._timerRecord['PrePublish'] = Date.now();
2878
3182
  const msToken = params.cookies.find((it)=>"msToken" === it.name)?.value;
2879
3183
  let publishOption = {};
2880
3184
  if (msToken) {
@@ -3119,7 +3423,6 @@ const rpa_rpaAction = async (task, params)=>{
3119
3423
  const confirmBtn = page.locator('div.byte-modal-footer button.byte-btn-primary:has-text("确定")');
3120
3424
  if (await confirmBtn.isVisible()) await confirmBtn.click();
3121
3425
  }
3122
- task._timerRecord['PrePublish'] = Date.now();
3123
3426
  if ("publish" === params.saveType) {
3124
3427
  await page.locator(".publish-footer button").filter({
3125
3428
  hasText: params.settingInfo.timer ? "定时发布" : "确认发布"
@@ -3527,10 +3830,10 @@ async function getXiaohongshuData(params) {
3527
3830
  origin: "https://creator.xiaohongshu.com"
3528
3831
  }
3529
3832
  });
3530
- const xsEncrypt = new XsEncrypt();
3833
+ const xsEncrypt = new Xhshow();
3531
3834
  const xt = Date.now().toString();
3532
3835
  const sevenDataUrl = "/api/galaxy/v2/creator/datacenter/account/base";
3533
- const xs = await xsEncrypt.encryptXs(sevenDataUrl, a1Cookie, xt);
3836
+ const xs = xsEncrypt.signXsGet(sevenDataUrl, a1Cookie, "xhs-pc-web", null);
3534
3837
  const [overAllData, sevenData] = await Promise.all([
3535
3838
  http.api({
3536
3839
  method: "get",
@@ -3891,7 +4194,7 @@ async function handleBaijiahaoData(params) {
3891
4194
  async function handleXiaohongshuData(params) {
3892
4195
  try {
3893
4196
  const { cookies, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false } = params;
3894
- const xsEncrypt = new XsEncrypt();
4197
+ const xsEncrypt = new Xhshow();
3895
4198
  const a1Cookie = cookies.find((it)=>"a1" === it.name)?.value;
3896
4199
  if (!a1Cookie) return {
3897
4200
  code: 200,
@@ -3912,8 +4215,12 @@ async function handleXiaohongshuData(params) {
3912
4215
  });
3913
4216
  async function fetchArticles(pageNum, a1Cookie, onlySuccess = false) {
3914
4217
  const xt = Date.now().toString();
3915
- const serveUrl = `/web_api/sns/v5/creator/note/user/posted?tab=${onlySuccess ? 1 : 0}&page=${pageNum - 1}`;
3916
- const xs = await xsEncrypt.encryptXs(serveUrl, a1Cookie, xt);
4218
+ const serveUrl = "/web_api/sns/v5/creator/note/user/posted";
4219
+ const serveParams = {
4220
+ tab: onlySuccess ? 1 : 0,
4221
+ page: pageNum - 1
4222
+ };
4223
+ const xs = xsEncrypt.signXsGet(serveUrl, a1Cookie, "xhs-pc-web", serveParams);
3917
4224
  return await http.api({
3918
4225
  method: "get",
3919
4226
  baseURL: "https://edith.xiaohongshu.com",
@@ -3921,7 +4228,8 @@ async function handleXiaohongshuData(params) {
3921
4228
  headers: {
3922
4229
  "x-s": xs,
3923
4230
  "x-t": xt
3924
- }
4231
+ },
4232
+ params: serveParams
3925
4233
  });
3926
4234
  }
3927
4235
  const articleInfo = await fetchArticles(pageNum, a1Cookie, onlySuccess);
@@ -4552,7 +4860,6 @@ const weixinPublish_mock_mockAction = async (task, params)=>{
4552
4860
  masssend_check: 1,
4553
4861
  is_masssend: 1
4554
4862
  };
4555
- task._timerRecord['PrePublish'] = Date.now();
4556
4863
  const { appMsgId } = await http.api({
4557
4864
  method: "post",
4558
4865
  url: "https://mp.weixin.qq.com/cgi-bin/operate_appmsg",
@@ -5211,7 +5518,6 @@ const weixinPublish_rpa_rpaAction = async (task, params)=>{
5211
5518
  await poperInstance.locator('.frm_radio_item label[for="not_recomment_0"]').click();
5212
5519
  }
5213
5520
  await page.waitForTimeout(1000);
5214
- task._timerRecord['PrePublish'] = Date.now();
5215
5521
  const articleId = await new Promise(async (resolve)=>{
5216
5522
  const handleResponse = async (response)=>{
5217
5523
  const url = response.url();
@@ -5545,7 +5851,7 @@ const xiaohongshuPublish_mock_errnoMap = {
5545
5851
  902: "登录已过期,请重新登录!",
5546
5852
  906: "账号存在风险,请重新登录"
5547
5853
  };
5548
- const mock_xsEncrypt = new XsEncrypt();
5854
+ const mock_xsEncrypt = new Xhshow();
5549
5855
  const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
5550
5856
  const tmpCachePath = task.getTmpPath();
5551
5857
  const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
@@ -5554,13 +5860,14 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
5554
5860
  message: "账号数据异常,请重新绑定账号后重试。",
5555
5861
  data: ""
5556
5862
  };
5863
+ const headers = {
5864
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
5865
+ origin: "https://creator.xiaohongshu.com",
5866
+ referer: "https://creator.xiaohongshu.com/",
5867
+ "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36"
5868
+ };
5557
5869
  const http = new Http({
5558
- headers: {
5559
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
5560
- origin: "https://creator.xiaohongshu.com",
5561
- referer: "https://creator.xiaohongshu.com/",
5562
- "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36"
5563
- }
5870
+ headers
5564
5871
  });
5565
5872
  http.addResponseInterceptor((response)=>{
5566
5873
  const responseData = response.data;
@@ -5573,9 +5880,16 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
5573
5880
  };
5574
5881
  }
5575
5882
  });
5576
- const fetchCoverUrl = `/api/media/v1/upload/creator/permit?biz_name=spectrum&scene=image&file_count=${params.banners.length}&version=1&source=web`;
5883
+ const fetchCoverUrl = "/api/media/v1/upload/creator/permit";
5884
+ const fetchCoverParams = {
5885
+ biz_name: "spectrum",
5886
+ scene: "image",
5887
+ file_count: params.banners.length,
5888
+ version: 1,
5889
+ source: "web"
5890
+ };
5577
5891
  const xt = Date.now().toString();
5578
- const xs = await mock_xsEncrypt.encryptXs(fetchCoverUrl, a1Cookie, xt);
5892
+ const xs = mock_xsEncrypt.signXsGet(fetchCoverUrl, a1Cookie, "xhs-pc-web", fetchCoverParams);
5579
5893
  const coverIdInfo = await http.api({
5580
5894
  method: "get",
5581
5895
  baseURL: "https://creator.xiaohongshu.com",
@@ -5584,7 +5898,8 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
5584
5898
  headers: {
5585
5899
  "x-s": xs,
5586
5900
  "x-t": xt
5587
- }
5901
+ },
5902
+ params: fetchCoverParams
5588
5903
  });
5589
5904
  let uploadInfos = [];
5590
5905
  coverIdInfo.data.uploadTempPermits.forEach((item)=>{
@@ -5658,9 +5973,8 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
5658
5973
  const topicData = {
5659
5974
  topic_names: topic["name"]
5660
5975
  };
5661
- const topicDataStr = mock_xsEncrypt.dumps(topicData);
5662
5976
  const publishXt = Date.now().toString();
5663
- const publishXs = await mock_xsEncrypt.encryptXs(`/web_api/sns/capa/postgw/topic/batch_customized${topicDataStr}`, a1Cookie, publishXt);
5977
+ const publishXs = mock_xsEncrypt.signXsPost("/web_api/sns/capa/postgw/topic/batch_customized", a1Cookie, "xhs-pc-web", topicData);
5664
5978
  let createTopic = await http.api({
5665
5979
  method: "POST",
5666
5980
  url: "https://edith.xiaohongshu.com/web_api/sns/capa/postgw/topic/batch_customized",
@@ -5743,7 +6057,6 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
5743
6057
  };
5744
6058
  }
5745
6059
  }
5746
- task._timerRecord['PrePublish'] = Date.now();
5747
6060
  const business_binds = {
5748
6061
  version: 1,
5749
6062
  bizType: "",
@@ -5760,9 +6073,8 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
5760
6073
  } : {}
5761
6074
  };
5762
6075
  publishData.common.business_binds = JSON.stringify(business_binds);
5763
- const publishDataStr = mock_xsEncrypt.dumps(publishData);
5764
6076
  const publishXt = Date.now().toString();
5765
- const publishXs = await mock_xsEncrypt.encryptXs(`/web_api/sns/v2/note${publishDataStr}`, a1Cookie, publishXt);
6077
+ const publishXs = mock_xsEncrypt.signXsPost("/web_api/sns/v2/note", a1Cookie, "xhs-pc-web", publishData);
5766
6078
  const xscommon = GenXSCommon(a1Cookie, publishXt, publishXs);
5767
6079
  const publishResult = await http.api({
5768
6080
  method: "post",
@@ -5778,7 +6090,7 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
5778
6090
  return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(publishResult.data?.id);
5779
6091
  };
5780
6092
  const rpa_GenXSCommon = __webpack_require__("./src/utils/XhsXsCommonEnc.js");
5781
- const rpa_xsEncrypt = new XsEncrypt();
6093
+ const rpa_xsEncrypt = new Xhshow();
5782
6094
  const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
5783
6095
  const commonCookies = {
5784
6096
  path: "/",
@@ -5809,7 +6121,8 @@ const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
5809
6121
  const url = request.url();
5810
6122
  if (interceptUrls.some((pattern)=>url.includes(pattern))) {
5811
6123
  const urlObj = new URL(url);
5812
- const fetchCoverUrl = urlObj.pathname + urlObj.search;
6124
+ urlObj.pathname, urlObj.search;
6125
+ const fetchCoverParams = Object.fromEntries(new URLSearchParams(urlObj.search));
5813
6126
  const xt = Date.now().toString();
5814
6127
  const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
5815
6128
  if (!a1Cookie) {
@@ -5827,9 +6140,8 @@ const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
5827
6140
  const isNoteRequest = urlObj.pathname.includes(interceptUrls[5]);
5828
6141
  const xs = await (isNoteRequest ? (async ()=>{
5829
6142
  const publishData = JSON.parse(request.postData() || "");
5830
- const publishDataStr = rpa_xsEncrypt.dumps(publishData);
5831
- return rpa_xsEncrypt.encryptXs(interceptUrls[5] + publishDataStr, a1Cookie, xt);
5832
- })() : rpa_xsEncrypt.encryptXs(fetchCoverUrl, a1Cookie, xt));
6143
+ return rpa_xsEncrypt.signXsPost(interceptUrls[5], a1Cookie, "xhs-pc-web", publishData);
6144
+ })() : rpa_xsEncrypt.signXsGet(urlObj.pathname, a1Cookie, "xhs-pc-web", fetchCoverParams));
5833
6145
  const xscommon = rpa_GenXSCommon(a1Cookie, xt, xs);
5834
6146
  const newHeaders = {
5835
6147
  ...request.headers(),
@@ -5971,7 +6283,6 @@ const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
5971
6283
  hasText: "仅自己可见"
5972
6284
  }).click();
5973
6285
  }
5974
- task._timerRecord['PrePublish'] = Date.now();
5975
6286
  const releaseTimeInstance = page.locator("label").filter({
5976
6287
  hasText: params.isImmediatelyPublish ? "立即发布" : "定时发布"
5977
6288
  });
@@ -5997,31 +6308,21 @@ const xiaohongshuPublish = async (task, params)=>{
5997
6308
  return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
5998
6309
  };
5999
6310
  var package_namespaceObject = {
6000
- i8: "1.2.21"
6311
+ i8: "1.2.23"
6001
6312
  };
6002
- const BetaFlag = "HuiwenCanary";
6003
6313
  class Action {
6004
6314
  constructor(task){
6005
6315
  this.task = task;
6006
6316
  }
6007
6317
  async bindTask(func, params) {
6008
6318
  let responseData;
6009
- this.task.isBeta = this.task?.isFeatOn(BetaFlag) ?? false;
6010
- this.task._timerRecord = {
6011
- ActionStart: Date.now()
6012
- };
6013
6319
  if (this.task.setArticleId) this.task.setArticleId(params.articleId ?? "");
6014
- if (this.task.setSaveType) this.task.setSaveType(params.saveType ?? "");
6015
- if (void 0 !== this.task.isInitializedGB) this.task.setGbInitType(this.task.isInitializedGB);
6016
- if ("object" == typeof params) params.cookies = params?.cookies ?? [];
6320
+ if ("object" == typeof params && null !== params) params.cookies = params?.cookies ?? [];
6017
6321
  try {
6018
6322
  responseData = await func(this.task, params);
6019
6323
  } catch (error) {
6020
6324
  responseData = Http.handleApiError(error);
6021
- } finally{
6022
- this.task._timerRecord['ActionEnd'] = Date.now();
6023
6325
  }
6024
- if (this.task.isBeta && this.task.setTimeConsuming) this.task.setTimeConsuming(this.task._timerRecord);
6025
6326
  if (200 === responseData.code) this.task.logger.info(`${func.name} action params error`, responseData);
6026
6327
  else if (0 !== responseData.code) {
6027
6328
  this.task.logger.error(responseData.message || `${func.name} 执行失败`, stringifyError(responseData.data), responseData.extra);
@@ -6106,6 +6407,6 @@ class Action {
6106
6407
  }
6107
6408
  }
6108
6409
  var __webpack_exports__version = package_namespaceObject.i8;
6109
- export { Action, BetaFlag, __webpack_exports__version as version };
6410
+ export { Action, __webpack_exports__version as version };
6110
6411
 
6111
6412
  //# sourceMappingURL=index.mjs.map