@iflyrpa/actions 1.2.23 → 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/bundle.js +392 -72
- package/dist/bundle.js.map +1 -1
- package/dist/index.js +392 -72
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +392 -72
- package/dist/index.mjs.map +1 -1
- package/dist/utils/xhsXsEncrypt.d.ts +19 -35
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2610,57 +2610,366 @@ const searchXiaohongshuLocation = async (_task, params)=>{
|
|
|
2610
2610
|
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)([]);
|
|
2611
2611
|
}
|
|
2612
2612
|
};
|
|
2613
|
-
class
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
}
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
}
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
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"
|
|
2635
2718
|
};
|
|
2636
|
-
const jsonString = JSON.stringify(obj, null, 0);
|
|
2637
|
-
return __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from(jsonString).toString("base64");
|
|
2638
2719
|
}
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
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);
|
|
2753
|
+
}
|
|
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;
|
|
2642
2801
|
}
|
|
2643
|
-
|
|
2644
|
-
const
|
|
2645
|
-
|
|
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;
|
|
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;
|
|
2646
2854
|
}
|
|
2855
|
+
}
|
|
2856
|
+
class CryptoProcessor {
|
|
2647
2857
|
constructor(){
|
|
2648
|
-
this.
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
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)
|
|
2653
2884
|
];
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
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;
|
|
2661
2915
|
}
|
|
2662
2916
|
}
|
|
2663
|
-
|
|
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();
|
|
2664
2973
|
const searchXiaohongshuTopicList = async (_task, params)=>{
|
|
2665
2974
|
const http = new Http({
|
|
2666
2975
|
headers: {
|
|
@@ -2688,9 +2997,8 @@ const searchXiaohongshuTopicList = async (_task, params)=>{
|
|
|
2688
2997
|
page: 1
|
|
2689
2998
|
}
|
|
2690
2999
|
};
|
|
2691
|
-
const
|
|
2692
|
-
const
|
|
2693
|
-
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);
|
|
2694
3002
|
const result = await http.api({
|
|
2695
3003
|
method: "post",
|
|
2696
3004
|
url: "https://edith.xiaohongshu.com/web_api/sns/v1/search/topic",
|
|
@@ -3522,10 +3830,10 @@ async function getXiaohongshuData(params) {
|
|
|
3522
3830
|
origin: "https://creator.xiaohongshu.com"
|
|
3523
3831
|
}
|
|
3524
3832
|
});
|
|
3525
|
-
const xsEncrypt = new
|
|
3833
|
+
const xsEncrypt = new Xhshow();
|
|
3526
3834
|
const xt = Date.now().toString();
|
|
3527
3835
|
const sevenDataUrl = "/api/galaxy/v2/creator/datacenter/account/base";
|
|
3528
|
-
const xs =
|
|
3836
|
+
const xs = xsEncrypt.signXsGet(sevenDataUrl, a1Cookie, "xhs-pc-web", null);
|
|
3529
3837
|
const [overAllData, sevenData] = await Promise.all([
|
|
3530
3838
|
http.api({
|
|
3531
3839
|
method: "get",
|
|
@@ -3886,7 +4194,7 @@ async function handleBaijiahaoData(params) {
|
|
|
3886
4194
|
async function handleXiaohongshuData(params) {
|
|
3887
4195
|
try {
|
|
3888
4196
|
const { cookies, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false } = params;
|
|
3889
|
-
const xsEncrypt = new
|
|
4197
|
+
const xsEncrypt = new Xhshow();
|
|
3890
4198
|
const a1Cookie = cookies.find((it)=>"a1" === it.name)?.value;
|
|
3891
4199
|
if (!a1Cookie) return {
|
|
3892
4200
|
code: 200,
|
|
@@ -3907,8 +4215,12 @@ async function handleXiaohongshuData(params) {
|
|
|
3907
4215
|
});
|
|
3908
4216
|
async function fetchArticles(pageNum, a1Cookie, onlySuccess = false) {
|
|
3909
4217
|
const xt = Date.now().toString();
|
|
3910
|
-
const serveUrl =
|
|
3911
|
-
const
|
|
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);
|
|
3912
4224
|
return await http.api({
|
|
3913
4225
|
method: "get",
|
|
3914
4226
|
baseURL: "https://edith.xiaohongshu.com",
|
|
@@ -3916,7 +4228,8 @@ async function handleXiaohongshuData(params) {
|
|
|
3916
4228
|
headers: {
|
|
3917
4229
|
"x-s": xs,
|
|
3918
4230
|
"x-t": xt
|
|
3919
|
-
}
|
|
4231
|
+
},
|
|
4232
|
+
params: serveParams
|
|
3920
4233
|
});
|
|
3921
4234
|
}
|
|
3922
4235
|
const articleInfo = await fetchArticles(pageNum, a1Cookie, onlySuccess);
|
|
@@ -5538,7 +5851,7 @@ const xiaohongshuPublish_mock_errnoMap = {
|
|
|
5538
5851
|
902: "登录已过期,请重新登录!",
|
|
5539
5852
|
906: "账号存在风险,请重新登录"
|
|
5540
5853
|
};
|
|
5541
|
-
const mock_xsEncrypt = new
|
|
5854
|
+
const mock_xsEncrypt = new Xhshow();
|
|
5542
5855
|
const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
5543
5856
|
const tmpCachePath = task.getTmpPath();
|
|
5544
5857
|
const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
|
|
@@ -5547,13 +5860,14 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
|
5547
5860
|
message: "账号数据异常,请重新绑定账号后重试。",
|
|
5548
5861
|
data: ""
|
|
5549
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
|
+
};
|
|
5550
5869
|
const http = new Http({
|
|
5551
|
-
headers
|
|
5552
|
-
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
5553
|
-
origin: "https://creator.xiaohongshu.com",
|
|
5554
|
-
referer: "https://creator.xiaohongshu.com/",
|
|
5555
|
-
"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"
|
|
5556
|
-
}
|
|
5870
|
+
headers
|
|
5557
5871
|
});
|
|
5558
5872
|
http.addResponseInterceptor((response)=>{
|
|
5559
5873
|
const responseData = response.data;
|
|
@@ -5566,9 +5880,16 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
|
5566
5880
|
};
|
|
5567
5881
|
}
|
|
5568
5882
|
});
|
|
5569
|
-
const fetchCoverUrl =
|
|
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
|
+
};
|
|
5570
5891
|
const xt = Date.now().toString();
|
|
5571
|
-
const xs =
|
|
5892
|
+
const xs = mock_xsEncrypt.signXsGet(fetchCoverUrl, a1Cookie, "xhs-pc-web", fetchCoverParams);
|
|
5572
5893
|
const coverIdInfo = await http.api({
|
|
5573
5894
|
method: "get",
|
|
5574
5895
|
baseURL: "https://creator.xiaohongshu.com",
|
|
@@ -5577,7 +5898,8 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
|
5577
5898
|
headers: {
|
|
5578
5899
|
"x-s": xs,
|
|
5579
5900
|
"x-t": xt
|
|
5580
|
-
}
|
|
5901
|
+
},
|
|
5902
|
+
params: fetchCoverParams
|
|
5581
5903
|
});
|
|
5582
5904
|
let uploadInfos = [];
|
|
5583
5905
|
coverIdInfo.data.uploadTempPermits.forEach((item)=>{
|
|
@@ -5651,9 +5973,8 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
|
5651
5973
|
const topicData = {
|
|
5652
5974
|
topic_names: topic["name"]
|
|
5653
5975
|
};
|
|
5654
|
-
const topicDataStr = mock_xsEncrypt.dumps(topicData);
|
|
5655
5976
|
const publishXt = Date.now().toString();
|
|
5656
|
-
const publishXs =
|
|
5977
|
+
const publishXs = mock_xsEncrypt.signXsPost("/web_api/sns/capa/postgw/topic/batch_customized", a1Cookie, "xhs-pc-web", topicData);
|
|
5657
5978
|
let createTopic = await http.api({
|
|
5658
5979
|
method: "POST",
|
|
5659
5980
|
url: "https://edith.xiaohongshu.com/web_api/sns/capa/postgw/topic/batch_customized",
|
|
@@ -5752,9 +6073,8 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
|
5752
6073
|
} : {}
|
|
5753
6074
|
};
|
|
5754
6075
|
publishData.common.business_binds = JSON.stringify(business_binds);
|
|
5755
|
-
const publishDataStr = mock_xsEncrypt.dumps(publishData);
|
|
5756
6076
|
const publishXt = Date.now().toString();
|
|
5757
|
-
const publishXs =
|
|
6077
|
+
const publishXs = mock_xsEncrypt.signXsPost("/web_api/sns/v2/note", a1Cookie, "xhs-pc-web", publishData);
|
|
5758
6078
|
const xscommon = GenXSCommon(a1Cookie, publishXt, publishXs);
|
|
5759
6079
|
const publishResult = await http.api({
|
|
5760
6080
|
method: "post",
|
|
@@ -5770,7 +6090,7 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
|
5770
6090
|
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(publishResult.data?.id);
|
|
5771
6091
|
};
|
|
5772
6092
|
const rpa_GenXSCommon = __webpack_require__("./src/utils/XhsXsCommonEnc.js");
|
|
5773
|
-
const rpa_xsEncrypt = new
|
|
6093
|
+
const rpa_xsEncrypt = new Xhshow();
|
|
5774
6094
|
const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
|
|
5775
6095
|
const commonCookies = {
|
|
5776
6096
|
path: "/",
|
|
@@ -5801,7 +6121,8 @@ const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
|
|
|
5801
6121
|
const url = request.url();
|
|
5802
6122
|
if (interceptUrls.some((pattern)=>url.includes(pattern))) {
|
|
5803
6123
|
const urlObj = new URL(url);
|
|
5804
|
-
|
|
6124
|
+
urlObj.pathname, urlObj.search;
|
|
6125
|
+
const fetchCoverParams = Object.fromEntries(new URLSearchParams(urlObj.search));
|
|
5805
6126
|
const xt = Date.now().toString();
|
|
5806
6127
|
const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
|
|
5807
6128
|
if (!a1Cookie) {
|
|
@@ -5819,9 +6140,8 @@ const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
|
|
|
5819
6140
|
const isNoteRequest = urlObj.pathname.includes(interceptUrls[5]);
|
|
5820
6141
|
const xs = await (isNoteRequest ? (async ()=>{
|
|
5821
6142
|
const publishData = JSON.parse(request.postData() || "");
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
})() : 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));
|
|
5825
6145
|
const xscommon = rpa_GenXSCommon(a1Cookie, xt, xs);
|
|
5826
6146
|
const newHeaders = {
|
|
5827
6147
|
...request.headers(),
|
|
@@ -5988,7 +6308,7 @@ const xiaohongshuPublish = async (task, params)=>{
|
|
|
5988
6308
|
return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
|
|
5989
6309
|
};
|
|
5990
6310
|
var package_namespaceObject = {
|
|
5991
|
-
i8: "1.2.
|
|
6311
|
+
i8: "1.2.23"
|
|
5992
6312
|
};
|
|
5993
6313
|
class Action {
|
|
5994
6314
|
constructor(task){
|