@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.js
CHANGED
|
@@ -2661,57 +2661,366 @@ var __webpack_exports__ = {};
|
|
|
2661
2661
|
const external_node_buffer_namespaceObject = require("node:buffer");
|
|
2662
2662
|
const external_node_crypto_namespaceObject = require("node:crypto");
|
|
2663
2663
|
var external_node_crypto_default = /*#__PURE__*/ __webpack_require__.n(external_node_crypto_namespaceObject);
|
|
2664
|
-
class
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
}
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
}
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2664
|
+
class CryptoConfig {
|
|
2665
|
+
static{
|
|
2666
|
+
this.MAX_32BIT = 0xFFFFFFFF;
|
|
2667
|
+
}
|
|
2668
|
+
static{
|
|
2669
|
+
this.MAX_SIGNED_32BIT = 0x7FFFFFFF;
|
|
2670
|
+
}
|
|
2671
|
+
static{
|
|
2672
|
+
this.BASE58_ALPHABET = "NOPQRStuvwxWXYZabcyz012DEFTKLMdefghijkl4563GHIJBC7mnop89+/AUVqrsOPQefghijkABCDEFGuvwz0123456789xy";
|
|
2673
|
+
}
|
|
2674
|
+
static{
|
|
2675
|
+
this.STANDARD_BASE64_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
2676
|
+
}
|
|
2677
|
+
static{
|
|
2678
|
+
this.CUSTOM_BASE64_ALPHABET = "ZmserbBoHQtNP+wOcza/LpngG8yJq42KWYj0DSfdikx3VT16IlUAFM97hECvuRX5";
|
|
2679
|
+
}
|
|
2680
|
+
static{
|
|
2681
|
+
this.BASE58_BASE = 58;
|
|
2682
|
+
}
|
|
2683
|
+
static{
|
|
2684
|
+
this.BYTE_SIZE = 256;
|
|
2685
|
+
}
|
|
2686
|
+
static{
|
|
2687
|
+
this.HEX_KEY = "af572b95ca65b2d9ec76bb5d2e97cb653299cc663399cc663399cce673399cce6733190c06030100000000008040209048241289c4e271381c0e0703018040a05028148ac56231180c0683c16030984c2693c964b259ac56abd5eaf5fafd7e3f9f4f279349a4d2e9743a9d4e279349a4d2e9f47a3d1e8f47239148a4d269341a8d4623110884422190c86432994ca6d3e974baddee773b1d8e47a35128148ac5623198cce6f3f97c3e1f8f47a3d168b45aad562b158ac5e2f1f87c3e9f4f279349a4d269b45aad56";
|
|
2688
|
+
}
|
|
2689
|
+
static{
|
|
2690
|
+
this.TIMESTAMP_BYTES_COUNT = 16;
|
|
2691
|
+
}
|
|
2692
|
+
static{
|
|
2693
|
+
this.TIMESTAMP_XOR_KEY = 41;
|
|
2694
|
+
}
|
|
2695
|
+
static{
|
|
2696
|
+
this.STARTUP_TIME_OFFSET_MIN = 1000;
|
|
2697
|
+
}
|
|
2698
|
+
static{
|
|
2699
|
+
this.STARTUP_TIME_OFFSET_MAX = 4000;
|
|
2700
|
+
}
|
|
2701
|
+
static{
|
|
2702
|
+
this.EXPECTED_HEX_LENGTH = 32;
|
|
2703
|
+
}
|
|
2704
|
+
static{
|
|
2705
|
+
this.OUTPUT_BYTE_COUNT = 8;
|
|
2706
|
+
}
|
|
2707
|
+
static{
|
|
2708
|
+
this.HEX_CHUNK_SIZE = 2;
|
|
2709
|
+
}
|
|
2710
|
+
static{
|
|
2711
|
+
this.VERSION_BYTES = [
|
|
2712
|
+
119,
|
|
2713
|
+
104,
|
|
2714
|
+
96,
|
|
2715
|
+
41
|
|
2716
|
+
];
|
|
2717
|
+
}
|
|
2718
|
+
static{
|
|
2719
|
+
this.FIXED_SEPARATOR_BYTES = [
|
|
2720
|
+
16,
|
|
2721
|
+
0,
|
|
2722
|
+
0,
|
|
2723
|
+
0,
|
|
2724
|
+
15,
|
|
2725
|
+
5,
|
|
2726
|
+
0,
|
|
2727
|
+
0,
|
|
2728
|
+
47,
|
|
2729
|
+
1,
|
|
2730
|
+
0,
|
|
2731
|
+
0
|
|
2732
|
+
];
|
|
2733
|
+
}
|
|
2734
|
+
static{
|
|
2735
|
+
this.RANDOM_BYTE_COUNT = 4;
|
|
2736
|
+
}
|
|
2737
|
+
static{
|
|
2738
|
+
this.FIXED_INT_VALUE_1 = 15;
|
|
2739
|
+
}
|
|
2740
|
+
static{
|
|
2741
|
+
this.FIXED_INT_VALUE_2 = 1291;
|
|
2742
|
+
}
|
|
2743
|
+
static{
|
|
2744
|
+
this.ENV_STATIC_BYTES = [
|
|
2745
|
+
1,
|
|
2746
|
+
249,
|
|
2747
|
+
83,
|
|
2748
|
+
102,
|
|
2749
|
+
103,
|
|
2750
|
+
201,
|
|
2751
|
+
181,
|
|
2752
|
+
131,
|
|
2753
|
+
99,
|
|
2754
|
+
94,
|
|
2755
|
+
7,
|
|
2756
|
+
68,
|
|
2757
|
+
250,
|
|
2758
|
+
132,
|
|
2759
|
+
21
|
|
2760
|
+
];
|
|
2761
|
+
}
|
|
2762
|
+
static{
|
|
2763
|
+
this.SIGNATURE_DATA_TEMPLATE = {
|
|
2764
|
+
x0: "4.2.2",
|
|
2765
|
+
x1: "xhs-pc-web",
|
|
2766
|
+
x2: "Windows",
|
|
2767
|
+
x3: "",
|
|
2768
|
+
x4: "object"
|
|
2686
2769
|
};
|
|
2687
|
-
const jsonString = JSON.stringify(obj, null, 0);
|
|
2688
|
-
return external_node_buffer_namespaceObject.Buffer.from(jsonString).toString("base64");
|
|
2689
2770
|
}
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2771
|
+
static{
|
|
2772
|
+
this.X3_PREFIX = "mns0101_";
|
|
2773
|
+
}
|
|
2774
|
+
static{
|
|
2775
|
+
this.XYS_PREFIX = "XYS_";
|
|
2776
|
+
}
|
|
2777
|
+
}
|
|
2778
|
+
class RandomGenerator {
|
|
2779
|
+
generateRandomBytes(byteCount) {
|
|
2780
|
+
return Array.from({
|
|
2781
|
+
length: byteCount
|
|
2782
|
+
}, ()=>Math.floor(Math.random() * CryptoConfig.BYTE_SIZE));
|
|
2783
|
+
}
|
|
2784
|
+
generateRandomByteInRange(minVal, maxVal) {
|
|
2785
|
+
return Math.floor(Math.random() * (maxVal - minVal + 1)) + minVal;
|
|
2786
|
+
}
|
|
2787
|
+
generateRandomInt() {
|
|
2788
|
+
return Math.floor(Math.random() * (CryptoConfig.MAX_32BIT + 1));
|
|
2789
|
+
}
|
|
2790
|
+
}
|
|
2791
|
+
class HexProcessor {
|
|
2792
|
+
hexStringToBytes(hexString) {
|
|
2793
|
+
const byteValues = [];
|
|
2794
|
+
for(let i = 0; i < hexString.length; i += CryptoConfig.HEX_CHUNK_SIZE){
|
|
2795
|
+
const hexChunk = hexString.substr(i, CryptoConfig.HEX_CHUNK_SIZE);
|
|
2796
|
+
byteValues.push(parseInt(hexChunk, 16));
|
|
2797
|
+
}
|
|
2798
|
+
return byteValues;
|
|
2799
|
+
}
|
|
2800
|
+
processHexParameter(hexString, xorKey) {
|
|
2801
|
+
if (hexString.length !== CryptoConfig.EXPECTED_HEX_LENGTH) throw new Error(`hex parameter must be ${CryptoConfig.EXPECTED_HEX_LENGTH} characters`);
|
|
2802
|
+
const byteValues = this.hexStringToBytes(hexString);
|
|
2803
|
+
return byteValues.map((byteVal)=>byteVal ^ xorKey).slice(0, CryptoConfig.OUTPUT_BYTE_COUNT);
|
|
2804
|
+
}
|
|
2805
|
+
}
|
|
2806
|
+
class BitOperations {
|
|
2807
|
+
normalizeTo32bit(value) {
|
|
2808
|
+
return value & CryptoConfig.MAX_32BIT;
|
|
2809
|
+
}
|
|
2810
|
+
toSigned32bit(unsignedValue) {
|
|
2811
|
+
if (unsignedValue > CryptoConfig.MAX_SIGNED_32BIT) return unsignedValue - 0x100000000;
|
|
2812
|
+
return unsignedValue;
|
|
2813
|
+
}
|
|
2814
|
+
computeSeedValue(seed32bit) {
|
|
2815
|
+
const normalizedSeed = this.normalizeTo32bit(seed32bit);
|
|
2816
|
+
const shift15Bits = normalizedSeed >> 15;
|
|
2817
|
+
const shift13Bits = normalizedSeed >> 13;
|
|
2818
|
+
const shift12Bits = normalizedSeed >> 12;
|
|
2819
|
+
const shift10Bits = normalizedSeed >> 10;
|
|
2820
|
+
const xorMaskedResult = shift15Bits & ~shift13Bits | shift13Bits & ~shift15Bits;
|
|
2821
|
+
const shiftedResult = (xorMaskedResult ^ shift12Bits ^ shift10Bits) << 31 & CryptoConfig.MAX_32BIT;
|
|
2822
|
+
return this.toSigned32bit(shiftedResult);
|
|
2823
|
+
}
|
|
2824
|
+
xorTransformArray(sourceIntegers) {
|
|
2825
|
+
const resultBytes = new Uint8Array(sourceIntegers.length);
|
|
2826
|
+
const hexKeyBytes = external_node_buffer_namespaceObject.Buffer.from(CryptoConfig.HEX_KEY, 'hex');
|
|
2827
|
+
for(let index = 0; index < sourceIntegers.length; index++)resultBytes[index] = (sourceIntegers[index] ^ hexKeyBytes[index]) & 0xFF;
|
|
2828
|
+
return resultBytes;
|
|
2829
|
+
}
|
|
2830
|
+
}
|
|
2831
|
+
class Base58Encoder {
|
|
2832
|
+
encodeToB58(inputBytes) {
|
|
2833
|
+
const bytesArray = Array.isArray(inputBytes) ? inputBytes : Array.from(inputBytes);
|
|
2834
|
+
const numberAccumulator = this.bytesToNumber(bytesArray);
|
|
2835
|
+
const leadingZerosCount = this.countLeadingZeros(bytesArray);
|
|
2836
|
+
const encodedCharacters = this.numberToBase58Chars(numberAccumulator);
|
|
2837
|
+
encodedCharacters.push(...Array(leadingZerosCount).fill(CryptoConfig.BASE58_ALPHABET[0]));
|
|
2838
|
+
return encodedCharacters.reverse().join('');
|
|
2839
|
+
}
|
|
2840
|
+
bytesToNumber(inputBytes) {
|
|
2841
|
+
const bytesArray = Array.isArray(inputBytes) ? inputBytes : Array.from(inputBytes);
|
|
2842
|
+
let result = 0n;
|
|
2843
|
+
const BYTE_SIZE = 256n;
|
|
2844
|
+
for (const byteValue of bytesArray)result = result * BYTE_SIZE + BigInt(byteValue);
|
|
2845
|
+
return result;
|
|
2846
|
+
}
|
|
2847
|
+
countLeadingZeros(inputBytes) {
|
|
2848
|
+
let count = 0;
|
|
2849
|
+
for (const byteValue of inputBytes)if (0 === byteValue) count++;
|
|
2850
|
+
else break;
|
|
2851
|
+
return count;
|
|
2852
|
+
}
|
|
2853
|
+
numberToBase58Chars(number) {
|
|
2854
|
+
const characters = [];
|
|
2855
|
+
const base = BigInt(CryptoConfig.BASE58_BASE);
|
|
2856
|
+
while(number > 0n){
|
|
2857
|
+
const remainder = number % base;
|
|
2858
|
+
characters.push(CryptoConfig.BASE58_ALPHABET[Number(remainder)]);
|
|
2859
|
+
number /= base;
|
|
2860
|
+
}
|
|
2861
|
+
return characters;
|
|
2862
|
+
}
|
|
2863
|
+
}
|
|
2864
|
+
class Base64Encoder {
|
|
2865
|
+
encodeToB64(dataToEncode) {
|
|
2866
|
+
const dataBytes = external_node_buffer_namespaceObject.Buffer.from(dataToEncode, 'utf-8');
|
|
2867
|
+
const standardEncodedString = dataBytes.toString('base64');
|
|
2868
|
+
let result = '';
|
|
2869
|
+
for (const char of standardEncodedString){
|
|
2870
|
+
const index = CryptoConfig.STANDARD_BASE64_ALPHABET.indexOf(char);
|
|
2871
|
+
if (-1 !== index) result += CryptoConfig.CUSTOM_BASE64_ALPHABET[index];
|
|
2872
|
+
else result += char;
|
|
2873
|
+
}
|
|
2874
|
+
return result;
|
|
2875
|
+
}
|
|
2876
|
+
}
|
|
2877
|
+
class RequestSignatureValidator {
|
|
2878
|
+
static validateMethod(method) {
|
|
2879
|
+
if ('string' != typeof method) throw new TypeError(`method must be string, got ${typeof method}`);
|
|
2880
|
+
const upperMethod = method.trim().toUpperCase();
|
|
2881
|
+
if ('GET' !== upperMethod && 'POST' !== upperMethod) throw new Error(`method must be 'GET' or 'POST', got '${upperMethod}'`);
|
|
2882
|
+
return upperMethod;
|
|
2693
2883
|
}
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2884
|
+
static validateUri(uri) {
|
|
2885
|
+
if ('string' != typeof uri) throw new TypeError(`uri must be string, got ${typeof uri}`);
|
|
2886
|
+
if (!uri.trim()) throw new Error('uri cannot be empty');
|
|
2887
|
+
return uri.trim();
|
|
2697
2888
|
}
|
|
2889
|
+
static validateA1Value(a1Value) {
|
|
2890
|
+
if ('string' != typeof a1Value) throw new TypeError(`a1_value must be string, got ${typeof a1Value}`);
|
|
2891
|
+
if (!a1Value.trim()) throw new Error('a1_value cannot be empty');
|
|
2892
|
+
return a1Value.trim();
|
|
2893
|
+
}
|
|
2894
|
+
static validateXsecAppid(xsecAppid) {
|
|
2895
|
+
if ('string' != typeof xsecAppid) throw new TypeError(`xsec_appid must be string, got ${typeof xsecAppid}`);
|
|
2896
|
+
if (!xsecAppid.trim()) throw new Error('xsec_appid cannot be empty');
|
|
2897
|
+
return xsecAppid.trim();
|
|
2898
|
+
}
|
|
2899
|
+
static validatePayload(payload) {
|
|
2900
|
+
if (null !== payload && 'object' != typeof payload) throw new TypeError(`payload must be object or null, got ${typeof payload}`);
|
|
2901
|
+
if (null != payload) {
|
|
2902
|
+
for(const key in payload)if ('string' != typeof key) throw new TypeError(`payload keys must be string, got ${typeof key} for key '${key}'`);
|
|
2903
|
+
}
|
|
2904
|
+
return payload;
|
|
2905
|
+
}
|
|
2906
|
+
}
|
|
2907
|
+
class CryptoProcessor {
|
|
2698
2908
|
constructor(){
|
|
2699
|
-
this.
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2909
|
+
this.bitOps = new BitOperations();
|
|
2910
|
+
this.b58encoder = new Base58Encoder();
|
|
2911
|
+
this.b64encoder = new Base64Encoder();
|
|
2912
|
+
this.hexProcessor = new HexProcessor();
|
|
2913
|
+
this.randomGen = new RandomGenerator();
|
|
2914
|
+
}
|
|
2915
|
+
encodeTimestamp(ts, randomizeFirst = true) {
|
|
2916
|
+
const key = Array(8).fill(CryptoConfig.TIMESTAMP_XOR_KEY);
|
|
2917
|
+
const arr = this.intToLeBytes(ts, 8);
|
|
2918
|
+
const encoded = arr.map((a, i)=>a ^ key[i]);
|
|
2919
|
+
if (randomizeFirst) encoded[0] = this.randomGen.generateRandomByteInRange(0, 255);
|
|
2920
|
+
return encoded;
|
|
2921
|
+
}
|
|
2922
|
+
intToLeBytes(val, length = 4) {
|
|
2923
|
+
const arr = [];
|
|
2924
|
+
for(let i = 0; i < length; i++){
|
|
2925
|
+
arr.push(0xFF & val);
|
|
2926
|
+
val >>>= 8;
|
|
2927
|
+
}
|
|
2928
|
+
return arr;
|
|
2929
|
+
}
|
|
2930
|
+
strToLenPrefixedBytes(s) {
|
|
2931
|
+
const buf = external_node_buffer_namespaceObject.Buffer.from(s, 'utf-8');
|
|
2932
|
+
return [
|
|
2933
|
+
buf.length,
|
|
2934
|
+
...Array.from(buf)
|
|
2704
2935
|
];
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2936
|
+
}
|
|
2937
|
+
buildEnvironmentBytes() {
|
|
2938
|
+
return [
|
|
2939
|
+
CryptoConfig.ENV_STATIC_BYTES[0],
|
|
2940
|
+
this.randomGen.generateRandomByteInRange(10, 254),
|
|
2941
|
+
...CryptoConfig.ENV_STATIC_BYTES.slice(1)
|
|
2942
|
+
];
|
|
2943
|
+
}
|
|
2944
|
+
buildPayloadArray(hexParameter, a1Value, appIdentifier = "xhs-pc-web", stringParam = "") {
|
|
2945
|
+
const randNum = this.randomGen.generateRandomInt();
|
|
2946
|
+
const ts = Date.now();
|
|
2947
|
+
const startupTs = ts - (CryptoConfig.STARTUP_TIME_OFFSET_MIN + this.randomGen.generateRandomByteInRange(0, CryptoConfig.STARTUP_TIME_OFFSET_MAX - CryptoConfig.STARTUP_TIME_OFFSET_MIN));
|
|
2948
|
+
const arr = [];
|
|
2949
|
+
arr.push(...CryptoConfig.VERSION_BYTES);
|
|
2950
|
+
const randBytes = this.intToLeBytes(randNum, 4);
|
|
2951
|
+
arr.push(...randBytes);
|
|
2952
|
+
const xorKey = randBytes[0];
|
|
2953
|
+
arr.push(...this.encodeTimestamp(ts, true));
|
|
2954
|
+
arr.push(...this.intToLeBytes(startupTs, 8));
|
|
2955
|
+
arr.push(...this.intToLeBytes(CryptoConfig.FIXED_INT_VALUE_1));
|
|
2956
|
+
arr.push(...this.intToLeBytes(CryptoConfig.FIXED_INT_VALUE_2));
|
|
2957
|
+
const stringParamLength = external_node_buffer_namespaceObject.Buffer.from(stringParam, 'utf-8').length;
|
|
2958
|
+
arr.push(...this.intToLeBytes(stringParamLength));
|
|
2959
|
+
const md5Bytes = external_node_buffer_namespaceObject.Buffer.from(hexParameter, 'hex');
|
|
2960
|
+
const xorMd5Bytes = Array.from(md5Bytes).map((b)=>b ^ xorKey);
|
|
2961
|
+
arr.push(...xorMd5Bytes.slice(0, 8));
|
|
2962
|
+
arr.push(...this.strToLenPrefixedBytes(a1Value));
|
|
2963
|
+
arr.push(...this.strToLenPrefixedBytes(appIdentifier));
|
|
2964
|
+
arr.push(CryptoConfig.ENV_STATIC_BYTES[0], this.randomGen.generateRandomByteInRange(0, 255), ...CryptoConfig.ENV_STATIC_BYTES.slice(1));
|
|
2965
|
+
return arr;
|
|
2712
2966
|
}
|
|
2713
2967
|
}
|
|
2714
|
-
|
|
2968
|
+
class Xhshow {
|
|
2969
|
+
constructor(){
|
|
2970
|
+
this.cryptoProcessor = new CryptoProcessor();
|
|
2971
|
+
}
|
|
2972
|
+
buildContentString(method, uri, payload) {
|
|
2973
|
+
payload = payload || {};
|
|
2974
|
+
if ("POST" === method.toUpperCase()) return uri + JSON.stringify(payload);
|
|
2975
|
+
if (!payload || 0 === Object.keys(payload).length) return uri;
|
|
2976
|
+
{
|
|
2977
|
+
const params = Object.entries(payload).map(([key, value])=>{
|
|
2978
|
+
let valueStr = '';
|
|
2979
|
+
if (Array.isArray(value)) valueStr = value.map((v)=>String(v)).join(',');
|
|
2980
|
+
else if (null != value) valueStr = String(value);
|
|
2981
|
+
return `${key}=${valueStr}`;
|
|
2982
|
+
});
|
|
2983
|
+
return `${uri}?${params.join('&')}`;
|
|
2984
|
+
}
|
|
2985
|
+
}
|
|
2986
|
+
generateDValue(content) {
|
|
2987
|
+
return external_node_crypto_default().createHash('md5').update(content, 'utf-8').digest('hex');
|
|
2988
|
+
}
|
|
2989
|
+
buildSignature(dValue, a1Value, xsecAppid = "xhs-pc-web", stringParam = "") {
|
|
2990
|
+
const payloadArray = this.cryptoProcessor.buildPayloadArray(dValue, a1Value, xsecAppid, stringParam);
|
|
2991
|
+
const xorResult = this.cryptoProcessor.bitOps.xorTransformArray(payloadArray);
|
|
2992
|
+
return this.cryptoProcessor.b58encoder.encodeToB58(xorResult);
|
|
2993
|
+
}
|
|
2994
|
+
signXs(method, uri, a1Value, xsecAppid = "xhs-pc-web", payload) {
|
|
2995
|
+
const validatedMethod = RequestSignatureValidator.validateMethod(method);
|
|
2996
|
+
const validatedUri = RequestSignatureValidator.validateUri(uri);
|
|
2997
|
+
const validatedA1Value = RequestSignatureValidator.validateA1Value(a1Value);
|
|
2998
|
+
const validatedXsecAppid = RequestSignatureValidator.validateXsecAppid(xsecAppid);
|
|
2999
|
+
const validatedPayload = RequestSignatureValidator.validatePayload(payload);
|
|
3000
|
+
const signatureData = {
|
|
3001
|
+
...CryptoConfig.SIGNATURE_DATA_TEMPLATE
|
|
3002
|
+
};
|
|
3003
|
+
const contentString = this.buildContentString(validatedMethod, validatedUri, validatedPayload);
|
|
3004
|
+
const dValue = this.generateDValue(contentString);
|
|
3005
|
+
signatureData.x3 = CryptoConfig.X3_PREFIX + this.buildSignature(dValue, validatedA1Value, validatedXsecAppid, contentString);
|
|
3006
|
+
return CryptoConfig.XYS_PREFIX + this.cryptoProcessor.b64encoder.encodeToB64(JSON.stringify(signatureData));
|
|
3007
|
+
}
|
|
3008
|
+
signXsGet(uri, a1Value, xsecAppid = "xhs-pc-web", params) {
|
|
3009
|
+
const validatedUri = RequestSignatureValidator.validateUri(uri);
|
|
3010
|
+
const validatedA1Value = RequestSignatureValidator.validateA1Value(a1Value);
|
|
3011
|
+
const validatedXsecAppid = RequestSignatureValidator.validateXsecAppid(xsecAppid);
|
|
3012
|
+
const validatedParams = RequestSignatureValidator.validatePayload(params);
|
|
3013
|
+
return this.signXs("GET", validatedUri, validatedA1Value, validatedXsecAppid, validatedParams);
|
|
3014
|
+
}
|
|
3015
|
+
signXsPost(uri, a1Value, xsecAppid = "xhs-pc-web", payload) {
|
|
3016
|
+
const validatedUri = RequestSignatureValidator.validateUri(uri);
|
|
3017
|
+
const validatedA1Value = RequestSignatureValidator.validateA1Value(a1Value);
|
|
3018
|
+
const validatedXsecAppid = RequestSignatureValidator.validateXsecAppid(xsecAppid);
|
|
3019
|
+
const validatedPayload = RequestSignatureValidator.validatePayload(payload);
|
|
3020
|
+
return this.signXs("POST", validatedUri, validatedA1Value, validatedXsecAppid, validatedPayload);
|
|
3021
|
+
}
|
|
3022
|
+
}
|
|
3023
|
+
const searchXiaohongshuTopicList_xsEncrypt = new Xhshow();
|
|
2715
3024
|
const searchXiaohongshuTopicList = async (_task, params)=>{
|
|
2716
3025
|
const http = new Http({
|
|
2717
3026
|
headers: {
|
|
@@ -2739,9 +3048,8 @@ var __webpack_exports__ = {};
|
|
|
2739
3048
|
page: 1
|
|
2740
3049
|
}
|
|
2741
3050
|
};
|
|
2742
|
-
const
|
|
2743
|
-
const
|
|
2744
|
-
const xs = await searchXiaohongshuTopicList_xsEncrypt.encryptXs(fatchTopic, a1Cookie, xt);
|
|
3051
|
+
const fatchTopic = "/web_api/sns/v1/search/topic";
|
|
3052
|
+
const xs = searchXiaohongshuTopicList_xsEncrypt.signXsPost(fatchTopic, a1Cookie, "xhs-pc-web", topicData);
|
|
2745
3053
|
const result = await http.api({
|
|
2746
3054
|
method: "post",
|
|
2747
3055
|
url: "https://edith.xiaohongshu.com/web_api/sns/v1/search/topic",
|
|
@@ -3573,10 +3881,10 @@ var __webpack_exports__ = {};
|
|
|
3573
3881
|
origin: "https://creator.xiaohongshu.com"
|
|
3574
3882
|
}
|
|
3575
3883
|
});
|
|
3576
|
-
const xsEncrypt = new
|
|
3884
|
+
const xsEncrypt = new Xhshow();
|
|
3577
3885
|
const xt = Date.now().toString();
|
|
3578
3886
|
const sevenDataUrl = "/api/galaxy/v2/creator/datacenter/account/base";
|
|
3579
|
-
const xs =
|
|
3887
|
+
const xs = xsEncrypt.signXsGet(sevenDataUrl, a1Cookie, "xhs-pc-web", null);
|
|
3580
3888
|
const [overAllData, sevenData] = await Promise.all([
|
|
3581
3889
|
http.api({
|
|
3582
3890
|
method: "get",
|
|
@@ -3937,7 +4245,7 @@ var __webpack_exports__ = {};
|
|
|
3937
4245
|
async function handleXiaohongshuData(params) {
|
|
3938
4246
|
try {
|
|
3939
4247
|
const { cookies, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false } = params;
|
|
3940
|
-
const xsEncrypt = new
|
|
4248
|
+
const xsEncrypt = new Xhshow();
|
|
3941
4249
|
const a1Cookie = cookies.find((it)=>"a1" === it.name)?.value;
|
|
3942
4250
|
if (!a1Cookie) return {
|
|
3943
4251
|
code: 200,
|
|
@@ -3958,8 +4266,12 @@ var __webpack_exports__ = {};
|
|
|
3958
4266
|
});
|
|
3959
4267
|
async function fetchArticles(pageNum, a1Cookie, onlySuccess = false) {
|
|
3960
4268
|
const xt = Date.now().toString();
|
|
3961
|
-
const serveUrl =
|
|
3962
|
-
const
|
|
4269
|
+
const serveUrl = "/web_api/sns/v5/creator/note/user/posted";
|
|
4270
|
+
const serveParams = {
|
|
4271
|
+
tab: onlySuccess ? 1 : 0,
|
|
4272
|
+
page: pageNum - 1
|
|
4273
|
+
};
|
|
4274
|
+
const xs = xsEncrypt.signXsGet(serveUrl, a1Cookie, "xhs-pc-web", serveParams);
|
|
3963
4275
|
return await http.api({
|
|
3964
4276
|
method: "get",
|
|
3965
4277
|
baseURL: "https://edith.xiaohongshu.com",
|
|
@@ -3967,7 +4279,8 @@ var __webpack_exports__ = {};
|
|
|
3967
4279
|
headers: {
|
|
3968
4280
|
"x-s": xs,
|
|
3969
4281
|
"x-t": xt
|
|
3970
|
-
}
|
|
4282
|
+
},
|
|
4283
|
+
params: serveParams
|
|
3971
4284
|
});
|
|
3972
4285
|
}
|
|
3973
4286
|
const articleInfo = await fetchArticles(pageNum, a1Cookie, onlySuccess);
|
|
@@ -5589,7 +5902,7 @@ var __webpack_exports__ = {};
|
|
|
5589
5902
|
902: "登录已过期,请重新登录!",
|
|
5590
5903
|
906: "账号存在风险,请重新登录"
|
|
5591
5904
|
};
|
|
5592
|
-
const mock_xsEncrypt = new
|
|
5905
|
+
const mock_xsEncrypt = new Xhshow();
|
|
5593
5906
|
const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
5594
5907
|
const tmpCachePath = task.getTmpPath();
|
|
5595
5908
|
const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
|
|
@@ -5598,13 +5911,14 @@ var __webpack_exports__ = {};
|
|
|
5598
5911
|
message: "账号数据异常,请重新绑定账号后重试。",
|
|
5599
5912
|
data: ""
|
|
5600
5913
|
};
|
|
5914
|
+
const headers = {
|
|
5915
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
5916
|
+
origin: "https://creator.xiaohongshu.com",
|
|
5917
|
+
referer: "https://creator.xiaohongshu.com/",
|
|
5918
|
+
"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"
|
|
5919
|
+
};
|
|
5601
5920
|
const http = new Http({
|
|
5602
|
-
headers
|
|
5603
|
-
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
5604
|
-
origin: "https://creator.xiaohongshu.com",
|
|
5605
|
-
referer: "https://creator.xiaohongshu.com/",
|
|
5606
|
-
"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"
|
|
5607
|
-
}
|
|
5921
|
+
headers
|
|
5608
5922
|
});
|
|
5609
5923
|
http.addResponseInterceptor((response)=>{
|
|
5610
5924
|
const responseData = response.data;
|
|
@@ -5617,9 +5931,16 @@ var __webpack_exports__ = {};
|
|
|
5617
5931
|
};
|
|
5618
5932
|
}
|
|
5619
5933
|
});
|
|
5620
|
-
const fetchCoverUrl =
|
|
5934
|
+
const fetchCoverUrl = "/api/media/v1/upload/creator/permit";
|
|
5935
|
+
const fetchCoverParams = {
|
|
5936
|
+
biz_name: "spectrum",
|
|
5937
|
+
scene: "image",
|
|
5938
|
+
file_count: params.banners.length,
|
|
5939
|
+
version: 1,
|
|
5940
|
+
source: "web"
|
|
5941
|
+
};
|
|
5621
5942
|
const xt = Date.now().toString();
|
|
5622
|
-
const xs =
|
|
5943
|
+
const xs = mock_xsEncrypt.signXsGet(fetchCoverUrl, a1Cookie, "xhs-pc-web", fetchCoverParams);
|
|
5623
5944
|
const coverIdInfo = await http.api({
|
|
5624
5945
|
method: "get",
|
|
5625
5946
|
baseURL: "https://creator.xiaohongshu.com",
|
|
@@ -5628,7 +5949,8 @@ var __webpack_exports__ = {};
|
|
|
5628
5949
|
headers: {
|
|
5629
5950
|
"x-s": xs,
|
|
5630
5951
|
"x-t": xt
|
|
5631
|
-
}
|
|
5952
|
+
},
|
|
5953
|
+
params: fetchCoverParams
|
|
5632
5954
|
});
|
|
5633
5955
|
let uploadInfos = [];
|
|
5634
5956
|
coverIdInfo.data.uploadTempPermits.forEach((item)=>{
|
|
@@ -5702,9 +6024,8 @@ var __webpack_exports__ = {};
|
|
|
5702
6024
|
const topicData = {
|
|
5703
6025
|
topic_names: topic["name"]
|
|
5704
6026
|
};
|
|
5705
|
-
const topicDataStr = mock_xsEncrypt.dumps(topicData);
|
|
5706
6027
|
const publishXt = Date.now().toString();
|
|
5707
|
-
const publishXs =
|
|
6028
|
+
const publishXs = mock_xsEncrypt.signXsPost("/web_api/sns/capa/postgw/topic/batch_customized", a1Cookie, "xhs-pc-web", topicData);
|
|
5708
6029
|
let createTopic = await http.api({
|
|
5709
6030
|
method: "POST",
|
|
5710
6031
|
url: "https://edith.xiaohongshu.com/web_api/sns/capa/postgw/topic/batch_customized",
|
|
@@ -5803,9 +6124,8 @@ var __webpack_exports__ = {};
|
|
|
5803
6124
|
} : {}
|
|
5804
6125
|
};
|
|
5805
6126
|
publishData.common.business_binds = JSON.stringify(business_binds);
|
|
5806
|
-
const publishDataStr = mock_xsEncrypt.dumps(publishData);
|
|
5807
6127
|
const publishXt = Date.now().toString();
|
|
5808
|
-
const publishXs =
|
|
6128
|
+
const publishXs = mock_xsEncrypt.signXsPost("/web_api/sns/v2/note", a1Cookie, "xhs-pc-web", publishData);
|
|
5809
6129
|
const xscommon = GenXSCommon(a1Cookie, publishXt, publishXs);
|
|
5810
6130
|
const publishResult = await http.api({
|
|
5811
6131
|
method: "post",
|
|
@@ -5821,7 +6141,7 @@ var __webpack_exports__ = {};
|
|
|
5821
6141
|
return (0, share_namespaceObject.success)(publishResult.data?.id);
|
|
5822
6142
|
};
|
|
5823
6143
|
const rpa_GenXSCommon = __webpack_require__("./src/utils/XhsXsCommonEnc.js");
|
|
5824
|
-
const rpa_xsEncrypt = new
|
|
6144
|
+
const rpa_xsEncrypt = new Xhshow();
|
|
5825
6145
|
const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
|
|
5826
6146
|
const commonCookies = {
|
|
5827
6147
|
path: "/",
|
|
@@ -5852,7 +6172,8 @@ var __webpack_exports__ = {};
|
|
|
5852
6172
|
const url = request.url();
|
|
5853
6173
|
if (interceptUrls.some((pattern)=>url.includes(pattern))) {
|
|
5854
6174
|
const urlObj = new URL(url);
|
|
5855
|
-
|
|
6175
|
+
urlObj.pathname, urlObj.search;
|
|
6176
|
+
const fetchCoverParams = Object.fromEntries(new URLSearchParams(urlObj.search));
|
|
5856
6177
|
const xt = Date.now().toString();
|
|
5857
6178
|
const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
|
|
5858
6179
|
if (!a1Cookie) {
|
|
@@ -5870,9 +6191,8 @@ var __webpack_exports__ = {};
|
|
|
5870
6191
|
const isNoteRequest = urlObj.pathname.includes(interceptUrls[5]);
|
|
5871
6192
|
const xs = await (isNoteRequest ? (async ()=>{
|
|
5872
6193
|
const publishData = JSON.parse(request.postData() || "");
|
|
5873
|
-
|
|
5874
|
-
|
|
5875
|
-
})() : rpa_xsEncrypt.encryptXs(fetchCoverUrl, a1Cookie, xt));
|
|
6194
|
+
return rpa_xsEncrypt.signXsPost(interceptUrls[5], a1Cookie, "xhs-pc-web", publishData);
|
|
6195
|
+
})() : rpa_xsEncrypt.signXsGet(urlObj.pathname, a1Cookie, "xhs-pc-web", fetchCoverParams));
|
|
5876
6196
|
const xscommon = rpa_GenXSCommon(a1Cookie, xt, xs);
|
|
5877
6197
|
const newHeaders = {
|
|
5878
6198
|
...request.headers(),
|
|
@@ -6039,7 +6359,7 @@ var __webpack_exports__ = {};
|
|
|
6039
6359
|
return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
|
|
6040
6360
|
};
|
|
6041
6361
|
var package_namespaceObject = {
|
|
6042
|
-
i8: "1.2.
|
|
6362
|
+
i8: "1.2.23"
|
|
6043
6363
|
};
|
|
6044
6364
|
class Action {
|
|
6045
6365
|
constructor(task){
|