@iflyrpa/actions 1.2.14 → 1.2.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/xiaohongshuPublish/mock.d.ts +1 -1
- package/dist/bundle.js +135 -88
- package/dist/bundle.js.map +1 -1
- package/dist/index.js +135 -88
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +132 -85
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type PublishAction } from ".";
|
|
2
2
|
export declare const mockAction: PublishAction;
|
package/dist/bundle.js
CHANGED
|
@@ -14856,6 +14856,60 @@ var __webpack_exports__ = {};
|
|
|
14856
14856
|
return success([]);
|
|
14857
14857
|
}
|
|
14858
14858
|
};
|
|
14859
|
+
const external_node_buffer_namespaceObject = require("node:buffer");
|
|
14860
|
+
const external_node_crypto_namespaceObject = require("node:crypto");
|
|
14861
|
+
var external_node_crypto_default = /*#__PURE__*/ __webpack_require__.n(external_node_crypto_namespaceObject);
|
|
14862
|
+
class XsEncrypt {
|
|
14863
|
+
async encryptMD5(url) {
|
|
14864
|
+
return external_node_crypto_default().createHash("md5").update(url, "utf8").digest("hex");
|
|
14865
|
+
}
|
|
14866
|
+
async encryptText(text) {
|
|
14867
|
+
const textEncoded = external_node_buffer_namespaceObject.Buffer.from(text).toString("base64");
|
|
14868
|
+
const cipher = external_node_crypto_default().createCipheriv("aes-128-cbc", new Uint8Array(this.keyBytes), new Uint8Array(this.iv));
|
|
14869
|
+
const ciphertext = cipher.update(textEncoded, "utf8", "base64");
|
|
14870
|
+
return ciphertext + cipher.final("base64");
|
|
14871
|
+
}
|
|
14872
|
+
async base64ToHex(encodedData) {
|
|
14873
|
+
const decodedData = external_node_buffer_namespaceObject.Buffer.from(encodedData, "base64");
|
|
14874
|
+
return decodedData.toString("hex");
|
|
14875
|
+
}
|
|
14876
|
+
async encryptPayload(payload, platform) {
|
|
14877
|
+
const hexPayload = await this.base64ToHex(payload);
|
|
14878
|
+
const obj = {
|
|
14879
|
+
signSvn: "56",
|
|
14880
|
+
signType: "x2",
|
|
14881
|
+
appID: platform,
|
|
14882
|
+
signVersion: "1",
|
|
14883
|
+
payload: hexPayload
|
|
14884
|
+
};
|
|
14885
|
+
const jsonString = JSON.stringify(obj, null, 0);
|
|
14886
|
+
return external_node_buffer_namespaceObject.Buffer.from(jsonString).toString("base64");
|
|
14887
|
+
}
|
|
14888
|
+
async encryptXs(url, a1, ts, platform = "xhs-pc-web") {
|
|
14889
|
+
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};`;
|
|
14890
|
+
return `XYW_${await this.encryptPayload(await this.encryptText(text), platform)}`;
|
|
14891
|
+
}
|
|
14892
|
+
dumps(...rest) {
|
|
14893
|
+
const [data, replacer = null, space = 0] = rest;
|
|
14894
|
+
return JSON.stringify(data, replacer, space).replace(/\n/g, "").replace(/":\s+"/g, '":"');
|
|
14895
|
+
}
|
|
14896
|
+
constructor(){
|
|
14897
|
+
this.words = [
|
|
14898
|
+
929260340,
|
|
14899
|
+
1633971297,
|
|
14900
|
+
895580464,
|
|
14901
|
+
925905270
|
|
14902
|
+
];
|
|
14903
|
+
this.keyBytes = external_node_buffer_namespaceObject.Buffer.concat(this.words.map((word)=>new Uint8Array(external_node_buffer_namespaceObject.Buffer.from([
|
|
14904
|
+
word >> 24 & 0xff,
|
|
14905
|
+
word >> 16 & 0xff,
|
|
14906
|
+
word >> 8 & 0xff,
|
|
14907
|
+
0xff & word
|
|
14908
|
+
]))));
|
|
14909
|
+
this.iv = external_node_buffer_namespaceObject.Buffer.from("4uzjr7mbsibcaldp", "utf8");
|
|
14910
|
+
}
|
|
14911
|
+
}
|
|
14912
|
+
const xsEncrypt = new XsEncrypt();
|
|
14859
14913
|
const searchXiaohongshuTopicList = async (_task, params)=>{
|
|
14860
14914
|
const http = new Http({
|
|
14861
14915
|
headers: {
|
|
@@ -14864,20 +14918,35 @@ var __webpack_exports__ = {};
|
|
|
14864
14918
|
origin: "https://creator.xiaohongshu.com"
|
|
14865
14919
|
}
|
|
14866
14920
|
});
|
|
14921
|
+
const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
|
|
14922
|
+
if (!a1Cookie) return {
|
|
14923
|
+
code: 200,
|
|
14924
|
+
message: "账号数据异常,请重新绑定账号后重试。",
|
|
14925
|
+
data: []
|
|
14926
|
+
};
|
|
14867
14927
|
try {
|
|
14928
|
+
const xt = Date.now().toString();
|
|
14929
|
+
const topicData = {
|
|
14930
|
+
keyword: params.searchValue,
|
|
14931
|
+
suggest_topic_request: {
|
|
14932
|
+
title: "",
|
|
14933
|
+
desc: `#${params.searchValue}`
|
|
14934
|
+
},
|
|
14935
|
+
page: {
|
|
14936
|
+
page_size: 20,
|
|
14937
|
+
page: 1
|
|
14938
|
+
}
|
|
14939
|
+
};
|
|
14940
|
+
const topicDataStr = xsEncrypt.dumps(topicData);
|
|
14941
|
+
const fatchTopic = `/web_api/sns/v1/search/topic${topicDataStr}`;
|
|
14942
|
+
const xs = await xsEncrypt.encryptXs(fatchTopic, a1Cookie, xt);
|
|
14868
14943
|
const result = await http.api({
|
|
14869
14944
|
method: "post",
|
|
14870
14945
|
url: "https://edith.xiaohongshu.com/web_api/sns/v1/search/topic",
|
|
14871
|
-
data:
|
|
14872
|
-
|
|
14873
|
-
|
|
14874
|
-
|
|
14875
|
-
desc: `#${params.searchValue}`
|
|
14876
|
-
},
|
|
14877
|
-
page: {
|
|
14878
|
-
page_size: 20,
|
|
14879
|
-
page: 1
|
|
14880
|
-
}
|
|
14946
|
+
data: topicData,
|
|
14947
|
+
headers: {
|
|
14948
|
+
"x-s": xs,
|
|
14949
|
+
"x-t": xt
|
|
14881
14950
|
},
|
|
14882
14951
|
defaultErrorMsg: "话题搜索异常,请稍后重试。"
|
|
14883
14952
|
});
|
|
@@ -16941,66 +17010,14 @@ var __webpack_exports__ = {};
|
|
|
16941
17010
|
if ("mockApi" === params.actionType) return weixinmpPublish_mock_mockAction(task, params);
|
|
16942
17011
|
return executeAction(weixinmpPublish_mock_mockAction, weixinmpPublish_rpa_rpaAction)(task, params);
|
|
16943
17012
|
};
|
|
16944
|
-
const external_node_buffer_namespaceObject = require("node:buffer");
|
|
16945
|
-
const external_node_crypto_namespaceObject = require("node:crypto");
|
|
16946
|
-
var external_node_crypto_default = /*#__PURE__*/ __webpack_require__.n(external_node_crypto_namespaceObject);
|
|
16947
|
-
class XsEncrypt {
|
|
16948
|
-
async encryptMD5(url) {
|
|
16949
|
-
return external_node_crypto_default().createHash("md5").update(url, "utf8").digest("hex");
|
|
16950
|
-
}
|
|
16951
|
-
async encryptText(text) {
|
|
16952
|
-
const textEncoded = external_node_buffer_namespaceObject.Buffer.from(text).toString("base64");
|
|
16953
|
-
const cipher = external_node_crypto_default().createCipheriv("aes-128-cbc", new Uint8Array(this.keyBytes), new Uint8Array(this.iv));
|
|
16954
|
-
const ciphertext = cipher.update(textEncoded, "utf8", "base64");
|
|
16955
|
-
return ciphertext + cipher.final("base64");
|
|
16956
|
-
}
|
|
16957
|
-
async base64ToHex(encodedData) {
|
|
16958
|
-
const decodedData = external_node_buffer_namespaceObject.Buffer.from(encodedData, "base64");
|
|
16959
|
-
return decodedData.toString("hex");
|
|
16960
|
-
}
|
|
16961
|
-
async encryptPayload(payload, platform) {
|
|
16962
|
-
const hexPayload = await this.base64ToHex(payload);
|
|
16963
|
-
const obj = {
|
|
16964
|
-
signSvn: "56",
|
|
16965
|
-
signType: "x2",
|
|
16966
|
-
appID: platform,
|
|
16967
|
-
signVersion: "1",
|
|
16968
|
-
payload: hexPayload
|
|
16969
|
-
};
|
|
16970
|
-
const jsonString = JSON.stringify(obj, null, 0);
|
|
16971
|
-
return external_node_buffer_namespaceObject.Buffer.from(jsonString).toString("base64");
|
|
16972
|
-
}
|
|
16973
|
-
async encryptXs(url, a1, ts, platform = "xhs-pc-web") {
|
|
16974
|
-
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};`;
|
|
16975
|
-
return `XYW_${await this.encryptPayload(await this.encryptText(text), platform)}`;
|
|
16976
|
-
}
|
|
16977
|
-
dumps(...rest) {
|
|
16978
|
-
const [data, replacer = null, space = 0] = rest;
|
|
16979
|
-
return JSON.stringify(data, replacer, space).replace(/\n/g, "").replace(/":\s+"/g, '":"');
|
|
16980
|
-
}
|
|
16981
|
-
constructor(){
|
|
16982
|
-
this.words = [
|
|
16983
|
-
929260340,
|
|
16984
|
-
1633971297,
|
|
16985
|
-
895580464,
|
|
16986
|
-
925905270
|
|
16987
|
-
];
|
|
16988
|
-
this.keyBytes = external_node_buffer_namespaceObject.Buffer.concat(this.words.map((word)=>new Uint8Array(external_node_buffer_namespaceObject.Buffer.from([
|
|
16989
|
-
word >> 24 & 0xff,
|
|
16990
|
-
word >> 16 & 0xff,
|
|
16991
|
-
word >> 8 & 0xff,
|
|
16992
|
-
0xff & word
|
|
16993
|
-
]))));
|
|
16994
|
-
this.iv = external_node_buffer_namespaceObject.Buffer.from("4uzjr7mbsibcaldp", "utf8");
|
|
16995
|
-
}
|
|
16996
|
-
}
|
|
16997
17013
|
const xiaohongshuPublish_mock_errnoMap = {
|
|
16998
17014
|
915: "所属C端账号手机号被修改,请重新登录",
|
|
16999
17015
|
914: "所属C端账号密码被修改,请重新登录",
|
|
17000
17016
|
903: "账户已登出,需重新登陆重试!",
|
|
17001
|
-
902: "登录已过期,请重新登录!"
|
|
17017
|
+
902: "登录已过期,请重新登录!",
|
|
17018
|
+
906: "账号存在风险,请重新登录"
|
|
17002
17019
|
};
|
|
17003
|
-
const
|
|
17020
|
+
const mock_xsEncrypt = new XsEncrypt();
|
|
17004
17021
|
const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
17005
17022
|
const tmpCachePath = task.getTmpPath();
|
|
17006
17023
|
const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
|
|
@@ -17030,7 +17047,7 @@ var __webpack_exports__ = {};
|
|
|
17030
17047
|
});
|
|
17031
17048
|
const fetchCoverUrl = `/api/media/v1/upload/creator/permit?biz_name=spectrum&scene=image&file_count=${params.banners.length}&version=1&source=web`;
|
|
17032
17049
|
const xt = Date.now().toString();
|
|
17033
|
-
const xs = await
|
|
17050
|
+
const xs = await mock_xsEncrypt.encryptXs(fetchCoverUrl, a1Cookie, xt);
|
|
17034
17051
|
const coverIdInfo = await http.api({
|
|
17035
17052
|
method: "get",
|
|
17036
17053
|
baseURL: "https://creator.xiaohongshu.com",
|
|
@@ -17041,41 +17058,71 @@ var __webpack_exports__ = {};
|
|
|
17041
17058
|
"x-t": xt
|
|
17042
17059
|
}
|
|
17043
17060
|
});
|
|
17044
|
-
|
|
17045
|
-
|
|
17046
|
-
|
|
17061
|
+
let uploadInfos = [];
|
|
17062
|
+
coverIdInfo.data.uploadTempPermits.map((item)=>{
|
|
17063
|
+
uploadInfos.push({
|
|
17064
|
+
bucket: "",
|
|
17065
|
+
uploadAddr: item.uploadAddr,
|
|
17066
|
+
fileIds: item.fileIds,
|
|
17067
|
+
token: item.token
|
|
17068
|
+
});
|
|
17069
|
+
});
|
|
17070
|
+
if (0 === uploadInfos.length) return {
|
|
17047
17071
|
code: 200,
|
|
17048
17072
|
message: "图片上传失败,请稍后重试!",
|
|
17049
17073
|
data: ""
|
|
17050
17074
|
};
|
|
17051
|
-
const uploadFile = async (url, index)=>{
|
|
17075
|
+
const uploadFile = async (url, index, infoIndex = 0)=>{
|
|
17052
17076
|
const fileName = getFilenameFromUrl(url);
|
|
17053
17077
|
const localUrl = await downloadImage(url, external_node_path_default().join(tmpCachePath, fileName));
|
|
17054
|
-
const ossFileId = coverIds[index];
|
|
17055
17078
|
const fileBuffer = external_node_fs_default().readFileSync(localUrl);
|
|
17056
|
-
|
|
17057
|
-
|
|
17058
|
-
|
|
17059
|
-
|
|
17060
|
-
|
|
17061
|
-
|
|
17062
|
-
|
|
17063
|
-
|
|
17064
|
-
|
|
17065
|
-
|
|
17066
|
-
|
|
17067
|
-
|
|
17079
|
+
const tryUpload = async (uploadIndex)=>{
|
|
17080
|
+
if (uploadIndex >= uploadInfos.length) {
|
|
17081
|
+
external_node_fs_default().unlinkSync(localUrl);
|
|
17082
|
+
return {
|
|
17083
|
+
ossFileId: "",
|
|
17084
|
+
ossToken: ""
|
|
17085
|
+
};
|
|
17086
|
+
}
|
|
17087
|
+
const currentInfo = uploadInfos[uploadIndex];
|
|
17088
|
+
const ossFileId = currentInfo.fileIds[0];
|
|
17089
|
+
const ossToken = currentInfo.token;
|
|
17090
|
+
const ossDomain = currentInfo.uploadAddr;
|
|
17091
|
+
try {
|
|
17092
|
+
await http.api({
|
|
17093
|
+
method: "put",
|
|
17094
|
+
url: `https://${ossDomain}/${ossFileId}`,
|
|
17095
|
+
data: fileBuffer,
|
|
17096
|
+
headers: {
|
|
17097
|
+
"x-cos-security-token": ossToken
|
|
17098
|
+
},
|
|
17099
|
+
defaultErrorMsg: "图片上传异常,请稍后重试发布。"
|
|
17100
|
+
});
|
|
17101
|
+
return {
|
|
17102
|
+
ossFileId,
|
|
17103
|
+
ossToken
|
|
17104
|
+
};
|
|
17105
|
+
} catch (error) {
|
|
17106
|
+
return tryUpload(uploadIndex + 1);
|
|
17107
|
+
}
|
|
17068
17108
|
};
|
|
17109
|
+
return tryUpload(infoIndex);
|
|
17069
17110
|
};
|
|
17070
17111
|
const coverInfos = await Promise.all(params.banners.map((it, idx)=>uploadFile(it, idx)));
|
|
17112
|
+
const invalidUpload = coverInfos.find((it)=>"" === it.ossToken || "" == it.ossFileId);
|
|
17113
|
+
if (invalidUpload) return {
|
|
17114
|
+
code: 200,
|
|
17115
|
+
message: "图片上传异常,请稍后重试发布。",
|
|
17116
|
+
data: ""
|
|
17117
|
+
};
|
|
17071
17118
|
if (params.topic && params.topic.length > 0) await Promise.all(params.topic.map(async (topic)=>{
|
|
17072
17119
|
if (!topic["id"]) {
|
|
17073
17120
|
const topicData = {
|
|
17074
17121
|
topic_names: topic["name"]
|
|
17075
17122
|
};
|
|
17076
|
-
const topicDataStr =
|
|
17123
|
+
const topicDataStr = mock_xsEncrypt.dumps(topicData);
|
|
17077
17124
|
const publishXt = Date.now().toString();
|
|
17078
|
-
const publishXs = await
|
|
17125
|
+
const publishXs = await mock_xsEncrypt.encryptXs(`/web_api/sns/capa/postgw/topic/batch_customized${topicDataStr}`, a1Cookie, publishXt);
|
|
17079
17126
|
let createTopic = await http.api({
|
|
17080
17127
|
method: "POST",
|
|
17081
17128
|
url: "https://edith.xiaohongshu.com/web_api/sns/capa/postgw/topic/batch_customized",
|
|
@@ -17174,9 +17221,9 @@ var __webpack_exports__ = {};
|
|
|
17174
17221
|
} : {}
|
|
17175
17222
|
};
|
|
17176
17223
|
publishData.common.business_binds = JSON.stringify(business_binds);
|
|
17177
|
-
const publishDataStr =
|
|
17224
|
+
const publishDataStr = mock_xsEncrypt.dumps(publishData);
|
|
17178
17225
|
const publishXt = Date.now().toString();
|
|
17179
|
-
const publishXs = await
|
|
17226
|
+
const publishXs = await mock_xsEncrypt.encryptXs(`/web_api/sns/v2/note${publishDataStr}`, a1Cookie, publishXt);
|
|
17180
17227
|
const publishResult = await http.api({
|
|
17181
17228
|
method: "post",
|
|
17182
17229
|
url: "https://edith.xiaohongshu.com/web_api/sns/v2/note",
|
|
@@ -17405,7 +17452,7 @@ var __webpack_exports__ = {};
|
|
|
17405
17452
|
return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
|
|
17406
17453
|
};
|
|
17407
17454
|
var package_namespaceObject = {
|
|
17408
|
-
i8: "1.2.
|
|
17455
|
+
i8: "1.2.14"
|
|
17409
17456
|
};
|
|
17410
17457
|
class Action {
|
|
17411
17458
|
constructor(task){
|