@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/bundle.js +394 -94
- package/dist/bundle.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +394 -94
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +395 -94
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +0 -1
- package/dist/utils/xhsXsEncrypt.d.ts +19 -35
- package/package.json +2 -2
package/dist/bundle.js
CHANGED
|
@@ -3673,7 +3673,6 @@ var __webpack_exports__ = {};
|
|
|
3673
3673
|
__webpack_require__.r(__webpack_exports__);
|
|
3674
3674
|
__webpack_require__.d(__webpack_exports__, {
|
|
3675
3675
|
version: ()=>package_namespaceObject.i8,
|
|
3676
|
-
BetaFlag: ()=>BetaFlag,
|
|
3677
3676
|
Action: ()=>Action
|
|
3678
3677
|
});
|
|
3679
3678
|
var common_utils_namespaceObject = {};
|
|
@@ -14982,8 +14981,7 @@ var __webpack_exports__ = {};
|
|
|
14982
14981
|
20040034: "封面图片推荐jpg、png格式,不支持gif格式。",
|
|
14983
14982
|
20040124: "服务器异常,请稍后重试!",
|
|
14984
14983
|
20040001: "当前用户未登录,请登陆后重试!",
|
|
14985
|
-
401100025: "该应用不支持此媒资类型"
|
|
14986
|
-
401100033: "图片宽高不满足要求"
|
|
14984
|
+
401100025: "该应用不支持此媒资类型"
|
|
14987
14985
|
};
|
|
14988
14986
|
const mockAction = async (task, params)=>{
|
|
14989
14987
|
const { baijiahaoSingleCover, baijiahaoMultCover, baijiahaoCoverType } = params.settingInfo;
|
|
@@ -15108,7 +15106,6 @@ var __webpack_exports__ = {};
|
|
|
15108
15106
|
};
|
|
15109
15107
|
const isDraft = "draft" === params.saveType;
|
|
15110
15108
|
const saveUrl = isDraft ? "https://baijiahao.baidu.com/pcui/article/save?callback=bjhdraft" : "https://baijiahao.baidu.com/pcui/article/publish?callback=bjhpublish";
|
|
15111
|
-
task._timerRecord['PrePublish'] = Date.now();
|
|
15112
15109
|
const res = await http.api({
|
|
15113
15110
|
method: "post",
|
|
15114
15111
|
url: saveUrl,
|
|
@@ -15246,7 +15243,6 @@ var __webpack_exports__ = {};
|
|
|
15246
15243
|
}
|
|
15247
15244
|
};
|
|
15248
15245
|
page.on("response", handleResponse);
|
|
15249
|
-
task._timerRecord['PrePublish'] = Date.now();
|
|
15250
15246
|
const operatorContainer = page.locator(".editor-component-operator");
|
|
15251
15247
|
if ("draft" === params.saveType) await operatorContainer.locator(".op-btn-outter-content").filter({
|
|
15252
15248
|
hasText: "存草稿"
|
|
@@ -15551,57 +15547,366 @@ var __webpack_exports__ = {};
|
|
|
15551
15547
|
const external_node_buffer_namespaceObject = require("node:buffer");
|
|
15552
15548
|
const external_node_crypto_namespaceObject = require("node:crypto");
|
|
15553
15549
|
var external_node_crypto_default = /*#__PURE__*/ __webpack_require__.n(external_node_crypto_namespaceObject);
|
|
15554
|
-
class
|
|
15555
|
-
|
|
15556
|
-
|
|
15557
|
-
}
|
|
15558
|
-
|
|
15559
|
-
|
|
15560
|
-
|
|
15561
|
-
|
|
15562
|
-
|
|
15563
|
-
}
|
|
15564
|
-
|
|
15565
|
-
|
|
15566
|
-
|
|
15567
|
-
|
|
15568
|
-
|
|
15569
|
-
|
|
15570
|
-
|
|
15571
|
-
|
|
15572
|
-
|
|
15573
|
-
|
|
15574
|
-
|
|
15575
|
-
|
|
15550
|
+
class CryptoConfig {
|
|
15551
|
+
static{
|
|
15552
|
+
this.MAX_32BIT = 0xFFFFFFFF;
|
|
15553
|
+
}
|
|
15554
|
+
static{
|
|
15555
|
+
this.MAX_SIGNED_32BIT = 0x7FFFFFFF;
|
|
15556
|
+
}
|
|
15557
|
+
static{
|
|
15558
|
+
this.BASE58_ALPHABET = "NOPQRStuvwxWXYZabcyz012DEFTKLMdefghijkl4563GHIJBC7mnop89+/AUVqrsOPQefghijkABCDEFGuvwz0123456789xy";
|
|
15559
|
+
}
|
|
15560
|
+
static{
|
|
15561
|
+
this.STANDARD_BASE64_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
15562
|
+
}
|
|
15563
|
+
static{
|
|
15564
|
+
this.CUSTOM_BASE64_ALPHABET = "ZmserbBoHQtNP+wOcza/LpngG8yJq42KWYj0DSfdikx3VT16IlUAFM97hECvuRX5";
|
|
15565
|
+
}
|
|
15566
|
+
static{
|
|
15567
|
+
this.BASE58_BASE = 58;
|
|
15568
|
+
}
|
|
15569
|
+
static{
|
|
15570
|
+
this.BYTE_SIZE = 256;
|
|
15571
|
+
}
|
|
15572
|
+
static{
|
|
15573
|
+
this.HEX_KEY = "af572b95ca65b2d9ec76bb5d2e97cb653299cc663399cc663399cce673399cce6733190c06030100000000008040209048241289c4e271381c0e0703018040a05028148ac56231180c0683c16030984c2693c964b259ac56abd5eaf5fafd7e3f9f4f279349a4d2e9743a9d4e279349a4d2e9f47a3d1e8f47239148a4d269341a8d4623110884422190c86432994ca6d3e974baddee773b1d8e47a35128148ac5623198cce6f3f97c3e1f8f47a3d168b45aad562b158ac5e2f1f87c3e9f4f279349a4d269b45aad56";
|
|
15574
|
+
}
|
|
15575
|
+
static{
|
|
15576
|
+
this.TIMESTAMP_BYTES_COUNT = 16;
|
|
15577
|
+
}
|
|
15578
|
+
static{
|
|
15579
|
+
this.TIMESTAMP_XOR_KEY = 41;
|
|
15580
|
+
}
|
|
15581
|
+
static{
|
|
15582
|
+
this.STARTUP_TIME_OFFSET_MIN = 1000;
|
|
15583
|
+
}
|
|
15584
|
+
static{
|
|
15585
|
+
this.STARTUP_TIME_OFFSET_MAX = 4000;
|
|
15586
|
+
}
|
|
15587
|
+
static{
|
|
15588
|
+
this.EXPECTED_HEX_LENGTH = 32;
|
|
15589
|
+
}
|
|
15590
|
+
static{
|
|
15591
|
+
this.OUTPUT_BYTE_COUNT = 8;
|
|
15592
|
+
}
|
|
15593
|
+
static{
|
|
15594
|
+
this.HEX_CHUNK_SIZE = 2;
|
|
15595
|
+
}
|
|
15596
|
+
static{
|
|
15597
|
+
this.VERSION_BYTES = [
|
|
15598
|
+
119,
|
|
15599
|
+
104,
|
|
15600
|
+
96,
|
|
15601
|
+
41
|
|
15602
|
+
];
|
|
15603
|
+
}
|
|
15604
|
+
static{
|
|
15605
|
+
this.FIXED_SEPARATOR_BYTES = [
|
|
15606
|
+
16,
|
|
15607
|
+
0,
|
|
15608
|
+
0,
|
|
15609
|
+
0,
|
|
15610
|
+
15,
|
|
15611
|
+
5,
|
|
15612
|
+
0,
|
|
15613
|
+
0,
|
|
15614
|
+
47,
|
|
15615
|
+
1,
|
|
15616
|
+
0,
|
|
15617
|
+
0
|
|
15618
|
+
];
|
|
15619
|
+
}
|
|
15620
|
+
static{
|
|
15621
|
+
this.RANDOM_BYTE_COUNT = 4;
|
|
15622
|
+
}
|
|
15623
|
+
static{
|
|
15624
|
+
this.FIXED_INT_VALUE_1 = 15;
|
|
15625
|
+
}
|
|
15626
|
+
static{
|
|
15627
|
+
this.FIXED_INT_VALUE_2 = 1291;
|
|
15628
|
+
}
|
|
15629
|
+
static{
|
|
15630
|
+
this.ENV_STATIC_BYTES = [
|
|
15631
|
+
1,
|
|
15632
|
+
249,
|
|
15633
|
+
83,
|
|
15634
|
+
102,
|
|
15635
|
+
103,
|
|
15636
|
+
201,
|
|
15637
|
+
181,
|
|
15638
|
+
131,
|
|
15639
|
+
99,
|
|
15640
|
+
94,
|
|
15641
|
+
7,
|
|
15642
|
+
68,
|
|
15643
|
+
250,
|
|
15644
|
+
132,
|
|
15645
|
+
21
|
|
15646
|
+
];
|
|
15647
|
+
}
|
|
15648
|
+
static{
|
|
15649
|
+
this.SIGNATURE_DATA_TEMPLATE = {
|
|
15650
|
+
x0: "4.2.2",
|
|
15651
|
+
x1: "xhs-pc-web",
|
|
15652
|
+
x2: "Windows",
|
|
15653
|
+
x3: "",
|
|
15654
|
+
x4: "object"
|
|
15576
15655
|
};
|
|
15577
|
-
const jsonString = JSON.stringify(obj, null, 0);
|
|
15578
|
-
return external_node_buffer_namespaceObject.Buffer.from(jsonString).toString("base64");
|
|
15579
15656
|
}
|
|
15580
|
-
|
|
15581
|
-
|
|
15582
|
-
|
|
15657
|
+
static{
|
|
15658
|
+
this.X3_PREFIX = "mns0101_";
|
|
15659
|
+
}
|
|
15660
|
+
static{
|
|
15661
|
+
this.XYS_PREFIX = "XYS_";
|
|
15662
|
+
}
|
|
15663
|
+
}
|
|
15664
|
+
class RandomGenerator {
|
|
15665
|
+
generateRandomBytes(byteCount) {
|
|
15666
|
+
return Array.from({
|
|
15667
|
+
length: byteCount
|
|
15668
|
+
}, ()=>Math.floor(Math.random() * CryptoConfig.BYTE_SIZE));
|
|
15669
|
+
}
|
|
15670
|
+
generateRandomByteInRange(minVal, maxVal) {
|
|
15671
|
+
return Math.floor(Math.random() * (maxVal - minVal + 1)) + minVal;
|
|
15672
|
+
}
|
|
15673
|
+
generateRandomInt() {
|
|
15674
|
+
return Math.floor(Math.random() * (CryptoConfig.MAX_32BIT + 1));
|
|
15675
|
+
}
|
|
15676
|
+
}
|
|
15677
|
+
class HexProcessor {
|
|
15678
|
+
hexStringToBytes(hexString) {
|
|
15679
|
+
const byteValues = [];
|
|
15680
|
+
for(let i = 0; i < hexString.length; i += CryptoConfig.HEX_CHUNK_SIZE){
|
|
15681
|
+
const hexChunk = hexString.substr(i, CryptoConfig.HEX_CHUNK_SIZE);
|
|
15682
|
+
byteValues.push(parseInt(hexChunk, 16));
|
|
15683
|
+
}
|
|
15684
|
+
return byteValues;
|
|
15685
|
+
}
|
|
15686
|
+
processHexParameter(hexString, xorKey) {
|
|
15687
|
+
if (hexString.length !== CryptoConfig.EXPECTED_HEX_LENGTH) throw new Error(`hex parameter must be ${CryptoConfig.EXPECTED_HEX_LENGTH} characters`);
|
|
15688
|
+
const byteValues = this.hexStringToBytes(hexString);
|
|
15689
|
+
return byteValues.map((byteVal)=>byteVal ^ xorKey).slice(0, CryptoConfig.OUTPUT_BYTE_COUNT);
|
|
15583
15690
|
}
|
|
15584
|
-
|
|
15585
|
-
|
|
15586
|
-
|
|
15691
|
+
}
|
|
15692
|
+
class BitOperations {
|
|
15693
|
+
normalizeTo32bit(value) {
|
|
15694
|
+
return value & CryptoConfig.MAX_32BIT;
|
|
15695
|
+
}
|
|
15696
|
+
toSigned32bit(unsignedValue) {
|
|
15697
|
+
if (unsignedValue > CryptoConfig.MAX_SIGNED_32BIT) return unsignedValue - 0x100000000;
|
|
15698
|
+
return unsignedValue;
|
|
15699
|
+
}
|
|
15700
|
+
computeSeedValue(seed32bit) {
|
|
15701
|
+
const normalizedSeed = this.normalizeTo32bit(seed32bit);
|
|
15702
|
+
const shift15Bits = normalizedSeed >> 15;
|
|
15703
|
+
const shift13Bits = normalizedSeed >> 13;
|
|
15704
|
+
const shift12Bits = normalizedSeed >> 12;
|
|
15705
|
+
const shift10Bits = normalizedSeed >> 10;
|
|
15706
|
+
const xorMaskedResult = shift15Bits & ~shift13Bits | shift13Bits & ~shift15Bits;
|
|
15707
|
+
const shiftedResult = (xorMaskedResult ^ shift12Bits ^ shift10Bits) << 31 & CryptoConfig.MAX_32BIT;
|
|
15708
|
+
return this.toSigned32bit(shiftedResult);
|
|
15709
|
+
}
|
|
15710
|
+
xorTransformArray(sourceIntegers) {
|
|
15711
|
+
const resultBytes = new Uint8Array(sourceIntegers.length);
|
|
15712
|
+
const hexKeyBytes = external_node_buffer_namespaceObject.Buffer.from(CryptoConfig.HEX_KEY, 'hex');
|
|
15713
|
+
for(let index = 0; index < sourceIntegers.length; index++)resultBytes[index] = (sourceIntegers[index] ^ hexKeyBytes[index]) & 0xFF;
|
|
15714
|
+
return resultBytes;
|
|
15715
|
+
}
|
|
15716
|
+
}
|
|
15717
|
+
class Base58Encoder {
|
|
15718
|
+
encodeToB58(inputBytes) {
|
|
15719
|
+
const bytesArray = Array.isArray(inputBytes) ? inputBytes : Array.from(inputBytes);
|
|
15720
|
+
const numberAccumulator = this.bytesToNumber(bytesArray);
|
|
15721
|
+
const leadingZerosCount = this.countLeadingZeros(bytesArray);
|
|
15722
|
+
const encodedCharacters = this.numberToBase58Chars(numberAccumulator);
|
|
15723
|
+
encodedCharacters.push(...Array(leadingZerosCount).fill(CryptoConfig.BASE58_ALPHABET[0]));
|
|
15724
|
+
return encodedCharacters.reverse().join('');
|
|
15725
|
+
}
|
|
15726
|
+
bytesToNumber(inputBytes) {
|
|
15727
|
+
const bytesArray = Array.isArray(inputBytes) ? inputBytes : Array.from(inputBytes);
|
|
15728
|
+
let result = 0n;
|
|
15729
|
+
const BYTE_SIZE = 256n;
|
|
15730
|
+
for (const byteValue of bytesArray)result = result * BYTE_SIZE + BigInt(byteValue);
|
|
15731
|
+
return result;
|
|
15732
|
+
}
|
|
15733
|
+
countLeadingZeros(inputBytes) {
|
|
15734
|
+
let count = 0;
|
|
15735
|
+
for (const byteValue of inputBytes)if (0 === byteValue) count++;
|
|
15736
|
+
else break;
|
|
15737
|
+
return count;
|
|
15738
|
+
}
|
|
15739
|
+
numberToBase58Chars(number) {
|
|
15740
|
+
const characters = [];
|
|
15741
|
+
const base = BigInt(CryptoConfig.BASE58_BASE);
|
|
15742
|
+
while(number > 0n){
|
|
15743
|
+
const remainder = number % base;
|
|
15744
|
+
characters.push(CryptoConfig.BASE58_ALPHABET[Number(remainder)]);
|
|
15745
|
+
number /= base;
|
|
15746
|
+
}
|
|
15747
|
+
return characters;
|
|
15748
|
+
}
|
|
15749
|
+
}
|
|
15750
|
+
class Base64Encoder {
|
|
15751
|
+
encodeToB64(dataToEncode) {
|
|
15752
|
+
const dataBytes = external_node_buffer_namespaceObject.Buffer.from(dataToEncode, 'utf-8');
|
|
15753
|
+
const standardEncodedString = dataBytes.toString('base64');
|
|
15754
|
+
let result = '';
|
|
15755
|
+
for (const char of standardEncodedString){
|
|
15756
|
+
const index = CryptoConfig.STANDARD_BASE64_ALPHABET.indexOf(char);
|
|
15757
|
+
if (-1 !== index) result += CryptoConfig.CUSTOM_BASE64_ALPHABET[index];
|
|
15758
|
+
else result += char;
|
|
15759
|
+
}
|
|
15760
|
+
return result;
|
|
15587
15761
|
}
|
|
15762
|
+
}
|
|
15763
|
+
class RequestSignatureValidator {
|
|
15764
|
+
static validateMethod(method) {
|
|
15765
|
+
if ('string' != typeof method) throw new TypeError(`method must be string, got ${typeof method}`);
|
|
15766
|
+
const upperMethod = method.trim().toUpperCase();
|
|
15767
|
+
if ('GET' !== upperMethod && 'POST' !== upperMethod) throw new Error(`method must be 'GET' or 'POST', got '${upperMethod}'`);
|
|
15768
|
+
return upperMethod;
|
|
15769
|
+
}
|
|
15770
|
+
static validateUri(uri) {
|
|
15771
|
+
if ('string' != typeof uri) throw new TypeError(`uri must be string, got ${typeof uri}`);
|
|
15772
|
+
if (!uri.trim()) throw new Error('uri cannot be empty');
|
|
15773
|
+
return uri.trim();
|
|
15774
|
+
}
|
|
15775
|
+
static validateA1Value(a1Value) {
|
|
15776
|
+
if ('string' != typeof a1Value) throw new TypeError(`a1_value must be string, got ${typeof a1Value}`);
|
|
15777
|
+
if (!a1Value.trim()) throw new Error('a1_value cannot be empty');
|
|
15778
|
+
return a1Value.trim();
|
|
15779
|
+
}
|
|
15780
|
+
static validateXsecAppid(xsecAppid) {
|
|
15781
|
+
if ('string' != typeof xsecAppid) throw new TypeError(`xsec_appid must be string, got ${typeof xsecAppid}`);
|
|
15782
|
+
if (!xsecAppid.trim()) throw new Error('xsec_appid cannot be empty');
|
|
15783
|
+
return xsecAppid.trim();
|
|
15784
|
+
}
|
|
15785
|
+
static validatePayload(payload) {
|
|
15786
|
+
if (null !== payload && 'object' != typeof payload) throw new TypeError(`payload must be object or null, got ${typeof payload}`);
|
|
15787
|
+
if (null != payload) {
|
|
15788
|
+
for(const key in payload)if ('string' != typeof key) throw new TypeError(`payload keys must be string, got ${typeof key} for key '${key}'`);
|
|
15789
|
+
}
|
|
15790
|
+
return payload;
|
|
15791
|
+
}
|
|
15792
|
+
}
|
|
15793
|
+
class CryptoProcessor {
|
|
15588
15794
|
constructor(){
|
|
15589
|
-
this.
|
|
15590
|
-
|
|
15591
|
-
|
|
15592
|
-
|
|
15593
|
-
|
|
15795
|
+
this.bitOps = new BitOperations();
|
|
15796
|
+
this.b58encoder = new Base58Encoder();
|
|
15797
|
+
this.b64encoder = new Base64Encoder();
|
|
15798
|
+
this.hexProcessor = new HexProcessor();
|
|
15799
|
+
this.randomGen = new RandomGenerator();
|
|
15800
|
+
}
|
|
15801
|
+
encodeTimestamp(ts, randomizeFirst = true) {
|
|
15802
|
+
const key = Array(8).fill(CryptoConfig.TIMESTAMP_XOR_KEY);
|
|
15803
|
+
const arr = this.intToLeBytes(ts, 8);
|
|
15804
|
+
const encoded = arr.map((a, i)=>a ^ key[i]);
|
|
15805
|
+
if (randomizeFirst) encoded[0] = this.randomGen.generateRandomByteInRange(0, 255);
|
|
15806
|
+
return encoded;
|
|
15807
|
+
}
|
|
15808
|
+
intToLeBytes(val, length = 4) {
|
|
15809
|
+
const arr = [];
|
|
15810
|
+
for(let i = 0; i < length; i++){
|
|
15811
|
+
arr.push(0xFF & val);
|
|
15812
|
+
val >>>= 8;
|
|
15813
|
+
}
|
|
15814
|
+
return arr;
|
|
15815
|
+
}
|
|
15816
|
+
strToLenPrefixedBytes(s) {
|
|
15817
|
+
const buf = external_node_buffer_namespaceObject.Buffer.from(s, 'utf-8');
|
|
15818
|
+
return [
|
|
15819
|
+
buf.length,
|
|
15820
|
+
...Array.from(buf)
|
|
15594
15821
|
];
|
|
15595
|
-
|
|
15596
|
-
|
|
15597
|
-
|
|
15598
|
-
|
|
15599
|
-
|
|
15600
|
-
|
|
15601
|
-
|
|
15822
|
+
}
|
|
15823
|
+
buildEnvironmentBytes() {
|
|
15824
|
+
return [
|
|
15825
|
+
CryptoConfig.ENV_STATIC_BYTES[0],
|
|
15826
|
+
this.randomGen.generateRandomByteInRange(10, 254),
|
|
15827
|
+
...CryptoConfig.ENV_STATIC_BYTES.slice(1)
|
|
15828
|
+
];
|
|
15829
|
+
}
|
|
15830
|
+
buildPayloadArray(hexParameter, a1Value, appIdentifier = "xhs-pc-web", stringParam = "") {
|
|
15831
|
+
const randNum = this.randomGen.generateRandomInt();
|
|
15832
|
+
const ts = Date.now();
|
|
15833
|
+
const startupTs = ts - (CryptoConfig.STARTUP_TIME_OFFSET_MIN + this.randomGen.generateRandomByteInRange(0, CryptoConfig.STARTUP_TIME_OFFSET_MAX - CryptoConfig.STARTUP_TIME_OFFSET_MIN));
|
|
15834
|
+
const arr = [];
|
|
15835
|
+
arr.push(...CryptoConfig.VERSION_BYTES);
|
|
15836
|
+
const randBytes = this.intToLeBytes(randNum, 4);
|
|
15837
|
+
arr.push(...randBytes);
|
|
15838
|
+
const xorKey = randBytes[0];
|
|
15839
|
+
arr.push(...this.encodeTimestamp(ts, true));
|
|
15840
|
+
arr.push(...this.intToLeBytes(startupTs, 8));
|
|
15841
|
+
arr.push(...this.intToLeBytes(CryptoConfig.FIXED_INT_VALUE_1));
|
|
15842
|
+
arr.push(...this.intToLeBytes(CryptoConfig.FIXED_INT_VALUE_2));
|
|
15843
|
+
const stringParamLength = external_node_buffer_namespaceObject.Buffer.from(stringParam, 'utf-8').length;
|
|
15844
|
+
arr.push(...this.intToLeBytes(stringParamLength));
|
|
15845
|
+
const md5Bytes = external_node_buffer_namespaceObject.Buffer.from(hexParameter, 'hex');
|
|
15846
|
+
const xorMd5Bytes = Array.from(md5Bytes).map((b)=>b ^ xorKey);
|
|
15847
|
+
arr.push(...xorMd5Bytes.slice(0, 8));
|
|
15848
|
+
arr.push(...this.strToLenPrefixedBytes(a1Value));
|
|
15849
|
+
arr.push(...this.strToLenPrefixedBytes(appIdentifier));
|
|
15850
|
+
arr.push(CryptoConfig.ENV_STATIC_BYTES[0], this.randomGen.generateRandomByteInRange(0, 255), ...CryptoConfig.ENV_STATIC_BYTES.slice(1));
|
|
15851
|
+
return arr;
|
|
15852
|
+
}
|
|
15853
|
+
}
|
|
15854
|
+
class Xhshow {
|
|
15855
|
+
constructor(){
|
|
15856
|
+
this.cryptoProcessor = new CryptoProcessor();
|
|
15857
|
+
}
|
|
15858
|
+
buildContentString(method, uri, payload) {
|
|
15859
|
+
payload = payload || {};
|
|
15860
|
+
if ("POST" === method.toUpperCase()) return uri + JSON.stringify(payload);
|
|
15861
|
+
if (!payload || 0 === Object.keys(payload).length) return uri;
|
|
15862
|
+
{
|
|
15863
|
+
const params = Object.entries(payload).map(([key, value])=>{
|
|
15864
|
+
let valueStr = '';
|
|
15865
|
+
if (Array.isArray(value)) valueStr = value.map((v)=>String(v)).join(',');
|
|
15866
|
+
else if (null != value) valueStr = String(value);
|
|
15867
|
+
return `${key}=${valueStr}`;
|
|
15868
|
+
});
|
|
15869
|
+
return `${uri}?${params.join('&')}`;
|
|
15870
|
+
}
|
|
15871
|
+
}
|
|
15872
|
+
generateDValue(content) {
|
|
15873
|
+
return external_node_crypto_default().createHash('md5').update(content, 'utf-8').digest('hex');
|
|
15874
|
+
}
|
|
15875
|
+
buildSignature(dValue, a1Value, xsecAppid = "xhs-pc-web", stringParam = "") {
|
|
15876
|
+
const payloadArray = this.cryptoProcessor.buildPayloadArray(dValue, a1Value, xsecAppid, stringParam);
|
|
15877
|
+
const xorResult = this.cryptoProcessor.bitOps.xorTransformArray(payloadArray);
|
|
15878
|
+
return this.cryptoProcessor.b58encoder.encodeToB58(xorResult);
|
|
15879
|
+
}
|
|
15880
|
+
signXs(method, uri, a1Value, xsecAppid = "xhs-pc-web", payload) {
|
|
15881
|
+
const validatedMethod = RequestSignatureValidator.validateMethod(method);
|
|
15882
|
+
const validatedUri = RequestSignatureValidator.validateUri(uri);
|
|
15883
|
+
const validatedA1Value = RequestSignatureValidator.validateA1Value(a1Value);
|
|
15884
|
+
const validatedXsecAppid = RequestSignatureValidator.validateXsecAppid(xsecAppid);
|
|
15885
|
+
const validatedPayload = RequestSignatureValidator.validatePayload(payload);
|
|
15886
|
+
const signatureData = {
|
|
15887
|
+
...CryptoConfig.SIGNATURE_DATA_TEMPLATE
|
|
15888
|
+
};
|
|
15889
|
+
const contentString = this.buildContentString(validatedMethod, validatedUri, validatedPayload);
|
|
15890
|
+
const dValue = this.generateDValue(contentString);
|
|
15891
|
+
signatureData.x3 = CryptoConfig.X3_PREFIX + this.buildSignature(dValue, validatedA1Value, validatedXsecAppid, contentString);
|
|
15892
|
+
return CryptoConfig.XYS_PREFIX + this.cryptoProcessor.b64encoder.encodeToB64(JSON.stringify(signatureData));
|
|
15893
|
+
}
|
|
15894
|
+
signXsGet(uri, a1Value, xsecAppid = "xhs-pc-web", params) {
|
|
15895
|
+
const validatedUri = RequestSignatureValidator.validateUri(uri);
|
|
15896
|
+
const validatedA1Value = RequestSignatureValidator.validateA1Value(a1Value);
|
|
15897
|
+
const validatedXsecAppid = RequestSignatureValidator.validateXsecAppid(xsecAppid);
|
|
15898
|
+
const validatedParams = RequestSignatureValidator.validatePayload(params);
|
|
15899
|
+
return this.signXs("GET", validatedUri, validatedA1Value, validatedXsecAppid, validatedParams);
|
|
15900
|
+
}
|
|
15901
|
+
signXsPost(uri, a1Value, xsecAppid = "xhs-pc-web", payload) {
|
|
15902
|
+
const validatedUri = RequestSignatureValidator.validateUri(uri);
|
|
15903
|
+
const validatedA1Value = RequestSignatureValidator.validateA1Value(a1Value);
|
|
15904
|
+
const validatedXsecAppid = RequestSignatureValidator.validateXsecAppid(xsecAppid);
|
|
15905
|
+
const validatedPayload = RequestSignatureValidator.validatePayload(payload);
|
|
15906
|
+
return this.signXs("POST", validatedUri, validatedA1Value, validatedXsecAppid, validatedPayload);
|
|
15602
15907
|
}
|
|
15603
15908
|
}
|
|
15604
|
-
const searchXiaohongshuTopicList_xsEncrypt = new
|
|
15909
|
+
const searchXiaohongshuTopicList_xsEncrypt = new Xhshow();
|
|
15605
15910
|
const searchXiaohongshuTopicList = async (_task, params)=>{
|
|
15606
15911
|
const http = new Http({
|
|
15607
15912
|
headers: {
|
|
@@ -15629,9 +15934,8 @@ var __webpack_exports__ = {};
|
|
|
15629
15934
|
page: 1
|
|
15630
15935
|
}
|
|
15631
15936
|
};
|
|
15632
|
-
const
|
|
15633
|
-
const
|
|
15634
|
-
const xs = await searchXiaohongshuTopicList_xsEncrypt.encryptXs(fatchTopic, a1Cookie, xt);
|
|
15937
|
+
const fatchTopic = "/web_api/sns/v1/search/topic";
|
|
15938
|
+
const xs = searchXiaohongshuTopicList_xsEncrypt.signXsPost(fatchTopic, a1Cookie, "xhs-pc-web", topicData);
|
|
15635
15939
|
const result = await http.api({
|
|
15636
15940
|
method: "post",
|
|
15637
15941
|
url: "https://edith.xiaohongshu.com/web_api/sns/v1/search/topic",
|
|
@@ -15812,7 +16116,6 @@ var __webpack_exports__ = {};
|
|
|
15812
16116
|
article_ad_type: getAddTypeValue(params.settingInfo.toutiaoAd),
|
|
15813
16117
|
claim_exclusive: toutiaoExclusive ? toutiaoExclusive : toutiaoOriginal?.includes("exclusive") ? 1 : 0
|
|
15814
16118
|
};
|
|
15815
|
-
task._timerRecord['PrePublish'] = Date.now();
|
|
15816
16119
|
const msToken = params.cookies.find((it)=>"msToken" === it.name)?.value;
|
|
15817
16120
|
let publishOption = {};
|
|
15818
16121
|
if (msToken) {
|
|
@@ -16057,7 +16360,6 @@ var __webpack_exports__ = {};
|
|
|
16057
16360
|
const confirmBtn = page.locator('div.byte-modal-footer button.byte-btn-primary:has-text("确定")');
|
|
16058
16361
|
if (await confirmBtn.isVisible()) await confirmBtn.click();
|
|
16059
16362
|
}
|
|
16060
|
-
task._timerRecord['PrePublish'] = Date.now();
|
|
16061
16363
|
if ("publish" === params.saveType) {
|
|
16062
16364
|
await page.locator(".publish-footer button").filter({
|
|
16063
16365
|
hasText: params.settingInfo.timer ? "定时发布" : "确认发布"
|
|
@@ -16465,10 +16767,10 @@ var __webpack_exports__ = {};
|
|
|
16465
16767
|
origin: "https://creator.xiaohongshu.com"
|
|
16466
16768
|
}
|
|
16467
16769
|
});
|
|
16468
|
-
const xsEncrypt = new
|
|
16770
|
+
const xsEncrypt = new Xhshow();
|
|
16469
16771
|
const xt = Date.now().toString();
|
|
16470
16772
|
const sevenDataUrl = "/api/galaxy/v2/creator/datacenter/account/base";
|
|
16471
|
-
const xs =
|
|
16773
|
+
const xs = xsEncrypt.signXsGet(sevenDataUrl, a1Cookie, "xhs-pc-web", null);
|
|
16472
16774
|
const [overAllData, sevenData] = await Promise.all([
|
|
16473
16775
|
http.api({
|
|
16474
16776
|
method: "get",
|
|
@@ -16829,7 +17131,7 @@ var __webpack_exports__ = {};
|
|
|
16829
17131
|
async function handleXiaohongshuData(params) {
|
|
16830
17132
|
try {
|
|
16831
17133
|
const { cookies, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false } = params;
|
|
16832
|
-
const xsEncrypt = new
|
|
17134
|
+
const xsEncrypt = new Xhshow();
|
|
16833
17135
|
const a1Cookie = cookies.find((it)=>"a1" === it.name)?.value;
|
|
16834
17136
|
if (!a1Cookie) return {
|
|
16835
17137
|
code: 200,
|
|
@@ -16850,8 +17152,12 @@ var __webpack_exports__ = {};
|
|
|
16850
17152
|
});
|
|
16851
17153
|
async function fetchArticles(pageNum, a1Cookie, onlySuccess = false) {
|
|
16852
17154
|
const xt = Date.now().toString();
|
|
16853
|
-
const serveUrl =
|
|
16854
|
-
const
|
|
17155
|
+
const serveUrl = "/web_api/sns/v5/creator/note/user/posted";
|
|
17156
|
+
const serveParams = {
|
|
17157
|
+
tab: onlySuccess ? 1 : 0,
|
|
17158
|
+
page: pageNum - 1
|
|
17159
|
+
};
|
|
17160
|
+
const xs = xsEncrypt.signXsGet(serveUrl, a1Cookie, "xhs-pc-web", serveParams);
|
|
16855
17161
|
return await http.api({
|
|
16856
17162
|
method: "get",
|
|
16857
17163
|
baseURL: "https://edith.xiaohongshu.com",
|
|
@@ -16859,7 +17165,8 @@ var __webpack_exports__ = {};
|
|
|
16859
17165
|
headers: {
|
|
16860
17166
|
"x-s": xs,
|
|
16861
17167
|
"x-t": xt
|
|
16862
|
-
}
|
|
17168
|
+
},
|
|
17169
|
+
params: serveParams
|
|
16863
17170
|
});
|
|
16864
17171
|
}
|
|
16865
17172
|
const articleInfo = await fetchArticles(pageNum, a1Cookie, onlySuccess);
|
|
@@ -17490,7 +17797,6 @@ var __webpack_exports__ = {};
|
|
|
17490
17797
|
masssend_check: 1,
|
|
17491
17798
|
is_masssend: 1
|
|
17492
17799
|
};
|
|
17493
|
-
task._timerRecord['PrePublish'] = Date.now();
|
|
17494
17800
|
const { appMsgId } = await http.api({
|
|
17495
17801
|
method: "post",
|
|
17496
17802
|
url: "https://mp.weixin.qq.com/cgi-bin/operate_appmsg",
|
|
@@ -18149,7 +18455,6 @@ var __webpack_exports__ = {};
|
|
|
18149
18455
|
await poperInstance.locator('.frm_radio_item label[for="not_recomment_0"]').click();
|
|
18150
18456
|
}
|
|
18151
18457
|
await page.waitForTimeout(1000);
|
|
18152
|
-
task._timerRecord['PrePublish'] = Date.now();
|
|
18153
18458
|
const articleId = await new Promise(async (resolve)=>{
|
|
18154
18459
|
const handleResponse = async (response)=>{
|
|
18155
18460
|
const url = response.url();
|
|
@@ -18483,7 +18788,7 @@ var __webpack_exports__ = {};
|
|
|
18483
18788
|
902: "登录已过期,请重新登录!",
|
|
18484
18789
|
906: "账号存在风险,请重新登录"
|
|
18485
18790
|
};
|
|
18486
|
-
const mock_xsEncrypt = new
|
|
18791
|
+
const mock_xsEncrypt = new Xhshow();
|
|
18487
18792
|
const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
18488
18793
|
const tmpCachePath = task.getTmpPath();
|
|
18489
18794
|
const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
|
|
@@ -18492,13 +18797,14 @@ var __webpack_exports__ = {};
|
|
|
18492
18797
|
message: "账号数据异常,请重新绑定账号后重试。",
|
|
18493
18798
|
data: ""
|
|
18494
18799
|
};
|
|
18800
|
+
const headers = {
|
|
18801
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
18802
|
+
origin: "https://creator.xiaohongshu.com",
|
|
18803
|
+
referer: "https://creator.xiaohongshu.com/",
|
|
18804
|
+
"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"
|
|
18805
|
+
};
|
|
18495
18806
|
const http = new Http({
|
|
18496
|
-
headers
|
|
18497
|
-
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
18498
|
-
origin: "https://creator.xiaohongshu.com",
|
|
18499
|
-
referer: "https://creator.xiaohongshu.com/",
|
|
18500
|
-
"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"
|
|
18501
|
-
}
|
|
18807
|
+
headers
|
|
18502
18808
|
});
|
|
18503
18809
|
http.addResponseInterceptor((response)=>{
|
|
18504
18810
|
const responseData = response.data;
|
|
@@ -18511,9 +18817,16 @@ var __webpack_exports__ = {};
|
|
|
18511
18817
|
};
|
|
18512
18818
|
}
|
|
18513
18819
|
});
|
|
18514
|
-
const fetchCoverUrl =
|
|
18820
|
+
const fetchCoverUrl = "/api/media/v1/upload/creator/permit";
|
|
18821
|
+
const fetchCoverParams = {
|
|
18822
|
+
biz_name: "spectrum",
|
|
18823
|
+
scene: "image",
|
|
18824
|
+
file_count: params.banners.length,
|
|
18825
|
+
version: 1,
|
|
18826
|
+
source: "web"
|
|
18827
|
+
};
|
|
18515
18828
|
const xt = Date.now().toString();
|
|
18516
|
-
const xs =
|
|
18829
|
+
const xs = mock_xsEncrypt.signXsGet(fetchCoverUrl, a1Cookie, "xhs-pc-web", fetchCoverParams);
|
|
18517
18830
|
const coverIdInfo = await http.api({
|
|
18518
18831
|
method: "get",
|
|
18519
18832
|
baseURL: "https://creator.xiaohongshu.com",
|
|
@@ -18522,7 +18835,8 @@ var __webpack_exports__ = {};
|
|
|
18522
18835
|
headers: {
|
|
18523
18836
|
"x-s": xs,
|
|
18524
18837
|
"x-t": xt
|
|
18525
|
-
}
|
|
18838
|
+
},
|
|
18839
|
+
params: fetchCoverParams
|
|
18526
18840
|
});
|
|
18527
18841
|
let uploadInfos = [];
|
|
18528
18842
|
coverIdInfo.data.uploadTempPermits.forEach((item)=>{
|
|
@@ -18596,9 +18910,8 @@ var __webpack_exports__ = {};
|
|
|
18596
18910
|
const topicData = {
|
|
18597
18911
|
topic_names: topic["name"]
|
|
18598
18912
|
};
|
|
18599
|
-
const topicDataStr = mock_xsEncrypt.dumps(topicData);
|
|
18600
18913
|
const publishXt = Date.now().toString();
|
|
18601
|
-
const publishXs =
|
|
18914
|
+
const publishXs = mock_xsEncrypt.signXsPost("/web_api/sns/capa/postgw/topic/batch_customized", a1Cookie, "xhs-pc-web", topicData);
|
|
18602
18915
|
let createTopic = await http.api({
|
|
18603
18916
|
method: "POST",
|
|
18604
18917
|
url: "https://edith.xiaohongshu.com/web_api/sns/capa/postgw/topic/batch_customized",
|
|
@@ -18681,7 +18994,6 @@ var __webpack_exports__ = {};
|
|
|
18681
18994
|
};
|
|
18682
18995
|
}
|
|
18683
18996
|
}
|
|
18684
|
-
task._timerRecord['PrePublish'] = Date.now();
|
|
18685
18997
|
const business_binds = {
|
|
18686
18998
|
version: 1,
|
|
18687
18999
|
bizType: "",
|
|
@@ -18698,9 +19010,8 @@ var __webpack_exports__ = {};
|
|
|
18698
19010
|
} : {}
|
|
18699
19011
|
};
|
|
18700
19012
|
publishData.common.business_binds = JSON.stringify(business_binds);
|
|
18701
|
-
const publishDataStr = mock_xsEncrypt.dumps(publishData);
|
|
18702
19013
|
const publishXt = Date.now().toString();
|
|
18703
|
-
const publishXs =
|
|
19014
|
+
const publishXs = mock_xsEncrypt.signXsPost("/web_api/sns/v2/note", a1Cookie, "xhs-pc-web", publishData);
|
|
18704
19015
|
const xscommon = GenXSCommon(a1Cookie, publishXt, publishXs);
|
|
18705
19016
|
const publishResult = await http.api({
|
|
18706
19017
|
method: "post",
|
|
@@ -18716,7 +19027,7 @@ var __webpack_exports__ = {};
|
|
|
18716
19027
|
return success(publishResult.data?.id);
|
|
18717
19028
|
};
|
|
18718
19029
|
const rpa_GenXSCommon = __webpack_require__("./src/utils/XhsXsCommonEnc.js");
|
|
18719
|
-
const rpa_xsEncrypt = new
|
|
19030
|
+
const rpa_xsEncrypt = new Xhshow();
|
|
18720
19031
|
const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
|
|
18721
19032
|
const commonCookies = {
|
|
18722
19033
|
path: "/",
|
|
@@ -18747,7 +19058,8 @@ var __webpack_exports__ = {};
|
|
|
18747
19058
|
const url = request.url();
|
|
18748
19059
|
if (interceptUrls.some((pattern)=>url.includes(pattern))) {
|
|
18749
19060
|
const urlObj = new URL(url);
|
|
18750
|
-
|
|
19061
|
+
urlObj.pathname, urlObj.search;
|
|
19062
|
+
const fetchCoverParams = Object.fromEntries(new URLSearchParams(urlObj.search));
|
|
18751
19063
|
const xt = Date.now().toString();
|
|
18752
19064
|
const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
|
|
18753
19065
|
if (!a1Cookie) {
|
|
@@ -18765,9 +19077,8 @@ var __webpack_exports__ = {};
|
|
|
18765
19077
|
const isNoteRequest = urlObj.pathname.includes(interceptUrls[5]);
|
|
18766
19078
|
const xs = await (isNoteRequest ? (async ()=>{
|
|
18767
19079
|
const publishData = JSON.parse(request.postData() || "");
|
|
18768
|
-
|
|
18769
|
-
|
|
18770
|
-
})() : rpa_xsEncrypt.encryptXs(fetchCoverUrl, a1Cookie, xt));
|
|
19080
|
+
return rpa_xsEncrypt.signXsPost(interceptUrls[5], a1Cookie, "xhs-pc-web", publishData);
|
|
19081
|
+
})() : rpa_xsEncrypt.signXsGet(urlObj.pathname, a1Cookie, "xhs-pc-web", fetchCoverParams));
|
|
18771
19082
|
const xscommon = rpa_GenXSCommon(a1Cookie, xt, xs);
|
|
18772
19083
|
const newHeaders = {
|
|
18773
19084
|
...request.headers(),
|
|
@@ -18909,7 +19220,6 @@ var __webpack_exports__ = {};
|
|
|
18909
19220
|
hasText: "仅自己可见"
|
|
18910
19221
|
}).click();
|
|
18911
19222
|
}
|
|
18912
|
-
task._timerRecord['PrePublish'] = Date.now();
|
|
18913
19223
|
const releaseTimeInstance = page.locator("label").filter({
|
|
18914
19224
|
hasText: params.isImmediatelyPublish ? "立即发布" : "定时发布"
|
|
18915
19225
|
});
|
|
@@ -18935,31 +19245,21 @@ var __webpack_exports__ = {};
|
|
|
18935
19245
|
return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
|
|
18936
19246
|
};
|
|
18937
19247
|
var package_namespaceObject = {
|
|
18938
|
-
i8: "1.2.
|
|
19248
|
+
i8: "1.2.23"
|
|
18939
19249
|
};
|
|
18940
|
-
const BetaFlag = "HuiwenCanary";
|
|
18941
19250
|
class Action {
|
|
18942
19251
|
constructor(task){
|
|
18943
19252
|
this.task = task;
|
|
18944
19253
|
}
|
|
18945
19254
|
async bindTask(func, params) {
|
|
18946
19255
|
let responseData;
|
|
18947
|
-
this.task.isBeta = this.task?.isFeatOn(BetaFlag) ?? false;
|
|
18948
|
-
this.task._timerRecord = {
|
|
18949
|
-
ActionStart: Date.now()
|
|
18950
|
-
};
|
|
18951
19256
|
if (this.task.setArticleId) this.task.setArticleId(params.articleId ?? "");
|
|
18952
|
-
if (
|
|
18953
|
-
if (void 0 !== this.task.isInitializedGB) this.task.setGbInitType(this.task.isInitializedGB);
|
|
18954
|
-
if ("object" == typeof params) params.cookies = params?.cookies ?? [];
|
|
19257
|
+
if ("object" == typeof params && null !== params) params.cookies = params?.cookies ?? [];
|
|
18955
19258
|
try {
|
|
18956
19259
|
responseData = await func(this.task, params);
|
|
18957
19260
|
} catch (error) {
|
|
18958
19261
|
responseData = Http.handleApiError(error);
|
|
18959
|
-
} finally{
|
|
18960
|
-
this.task._timerRecord['ActionEnd'] = Date.now();
|
|
18961
19262
|
}
|
|
18962
|
-
if (this.task.isBeta && this.task.setTimeConsuming) this.task.setTimeConsuming(this.task._timerRecord);
|
|
18963
19263
|
if (200 === responseData.code) this.task.logger.info(`${func.name} action params error`, responseData);
|
|
18964
19264
|
else if (0 !== responseData.code) {
|
|
18965
19265
|
this.task.logger.error(responseData.message || `${func.name} 执行失败`, stringifyError(responseData.data), responseData.extra);
|