@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
package/dist/index.mjs
CHANGED
|
@@ -1933,6 +1933,57 @@ const searchXiaohongshuLocation = async (_task, params)=>{
|
|
|
1933
1933
|
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)([]);
|
|
1934
1934
|
}
|
|
1935
1935
|
};
|
|
1936
|
+
class XsEncrypt {
|
|
1937
|
+
async encryptMD5(url) {
|
|
1938
|
+
return __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__["default"].createHash("md5").update(url, "utf8").digest("hex");
|
|
1939
|
+
}
|
|
1940
|
+
async encryptText(text) {
|
|
1941
|
+
const textEncoded = __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from(text).toString("base64");
|
|
1942
|
+
const cipher = __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__["default"].createCipheriv("aes-128-cbc", new Uint8Array(this.keyBytes), new Uint8Array(this.iv));
|
|
1943
|
+
const ciphertext = cipher.update(textEncoded, "utf8", "base64");
|
|
1944
|
+
return ciphertext + cipher.final("base64");
|
|
1945
|
+
}
|
|
1946
|
+
async base64ToHex(encodedData) {
|
|
1947
|
+
const decodedData = __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from(encodedData, "base64");
|
|
1948
|
+
return decodedData.toString("hex");
|
|
1949
|
+
}
|
|
1950
|
+
async encryptPayload(payload, platform) {
|
|
1951
|
+
const hexPayload = await this.base64ToHex(payload);
|
|
1952
|
+
const obj = {
|
|
1953
|
+
signSvn: "56",
|
|
1954
|
+
signType: "x2",
|
|
1955
|
+
appID: platform,
|
|
1956
|
+
signVersion: "1",
|
|
1957
|
+
payload: hexPayload
|
|
1958
|
+
};
|
|
1959
|
+
const jsonString = JSON.stringify(obj, null, 0);
|
|
1960
|
+
return __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from(jsonString).toString("base64");
|
|
1961
|
+
}
|
|
1962
|
+
async encryptXs(url, a1, ts, platform = "xhs-pc-web") {
|
|
1963
|
+
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};`;
|
|
1964
|
+
return `XYW_${await this.encryptPayload(await this.encryptText(text), platform)}`;
|
|
1965
|
+
}
|
|
1966
|
+
dumps(...rest) {
|
|
1967
|
+
const [data, replacer = null, space = 0] = rest;
|
|
1968
|
+
return JSON.stringify(data, replacer, space).replace(/\n/g, "").replace(/":\s+"/g, '":"');
|
|
1969
|
+
}
|
|
1970
|
+
constructor(){
|
|
1971
|
+
this.words = [
|
|
1972
|
+
929260340,
|
|
1973
|
+
1633971297,
|
|
1974
|
+
895580464,
|
|
1975
|
+
925905270
|
|
1976
|
+
];
|
|
1977
|
+
this.keyBytes = __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.concat(this.words.map((word)=>new Uint8Array(__WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from([
|
|
1978
|
+
word >> 24 & 0xff,
|
|
1979
|
+
word >> 16 & 0xff,
|
|
1980
|
+
word >> 8 & 0xff,
|
|
1981
|
+
0xff & word
|
|
1982
|
+
]))));
|
|
1983
|
+
this.iv = __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from("4uzjr7mbsibcaldp", "utf8");
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1986
|
+
const xsEncrypt = new XsEncrypt();
|
|
1936
1987
|
const searchXiaohongshuTopicList = async (_task, params)=>{
|
|
1937
1988
|
const http = new Http({
|
|
1938
1989
|
headers: {
|
|
@@ -1941,20 +1992,35 @@ const searchXiaohongshuTopicList = async (_task, params)=>{
|
|
|
1941
1992
|
origin: "https://creator.xiaohongshu.com"
|
|
1942
1993
|
}
|
|
1943
1994
|
});
|
|
1995
|
+
const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
|
|
1996
|
+
if (!a1Cookie) return {
|
|
1997
|
+
code: 200,
|
|
1998
|
+
message: "账号数据异常,请重新绑定账号后重试。",
|
|
1999
|
+
data: []
|
|
2000
|
+
};
|
|
1944
2001
|
try {
|
|
2002
|
+
const xt = Date.now().toString();
|
|
2003
|
+
const topicData = {
|
|
2004
|
+
keyword: params.searchValue,
|
|
2005
|
+
suggest_topic_request: {
|
|
2006
|
+
title: "",
|
|
2007
|
+
desc: `#${params.searchValue}`
|
|
2008
|
+
},
|
|
2009
|
+
page: {
|
|
2010
|
+
page_size: 20,
|
|
2011
|
+
page: 1
|
|
2012
|
+
}
|
|
2013
|
+
};
|
|
2014
|
+
const topicDataStr = xsEncrypt.dumps(topicData);
|
|
2015
|
+
const fatchTopic = `/web_api/sns/v1/search/topic${topicDataStr}`;
|
|
2016
|
+
const xs = await xsEncrypt.encryptXs(fatchTopic, a1Cookie, xt);
|
|
1945
2017
|
const result = await http.api({
|
|
1946
2018
|
method: "post",
|
|
1947
2019
|
url: "https://edith.xiaohongshu.com/web_api/sns/v1/search/topic",
|
|
1948
|
-
data:
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
desc: `#${params.searchValue}`
|
|
1953
|
-
},
|
|
1954
|
-
page: {
|
|
1955
|
-
page_size: 20,
|
|
1956
|
-
page: 1
|
|
1957
|
-
}
|
|
2020
|
+
data: topicData,
|
|
2021
|
+
headers: {
|
|
2022
|
+
"x-s": xs,
|
|
2023
|
+
"x-t": xt
|
|
1958
2024
|
},
|
|
1959
2025
|
defaultErrorMsg: "话题搜索异常,请稍后重试。"
|
|
1960
2026
|
});
|
|
@@ -4018,63 +4084,14 @@ const weixinmpPublish = async (task, params)=>{
|
|
|
4018
4084
|
if ("mockApi" === params.actionType) return weixinmpPublish_mock_mockAction(task, params);
|
|
4019
4085
|
return executeAction(weixinmpPublish_mock_mockAction, weixinmpPublish_rpa_rpaAction)(task, params);
|
|
4020
4086
|
};
|
|
4021
|
-
class XsEncrypt {
|
|
4022
|
-
async encryptMD5(url) {
|
|
4023
|
-
return __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__["default"].createHash("md5").update(url, "utf8").digest("hex");
|
|
4024
|
-
}
|
|
4025
|
-
async encryptText(text) {
|
|
4026
|
-
const textEncoded = __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from(text).toString("base64");
|
|
4027
|
-
const cipher = __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__["default"].createCipheriv("aes-128-cbc", new Uint8Array(this.keyBytes), new Uint8Array(this.iv));
|
|
4028
|
-
const ciphertext = cipher.update(textEncoded, "utf8", "base64");
|
|
4029
|
-
return ciphertext + cipher.final("base64");
|
|
4030
|
-
}
|
|
4031
|
-
async base64ToHex(encodedData) {
|
|
4032
|
-
const decodedData = __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from(encodedData, "base64");
|
|
4033
|
-
return decodedData.toString("hex");
|
|
4034
|
-
}
|
|
4035
|
-
async encryptPayload(payload, platform) {
|
|
4036
|
-
const hexPayload = await this.base64ToHex(payload);
|
|
4037
|
-
const obj = {
|
|
4038
|
-
signSvn: "56",
|
|
4039
|
-
signType: "x2",
|
|
4040
|
-
appID: platform,
|
|
4041
|
-
signVersion: "1",
|
|
4042
|
-
payload: hexPayload
|
|
4043
|
-
};
|
|
4044
|
-
const jsonString = JSON.stringify(obj, null, 0);
|
|
4045
|
-
return __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from(jsonString).toString("base64");
|
|
4046
|
-
}
|
|
4047
|
-
async encryptXs(url, a1, ts, platform = "xhs-pc-web") {
|
|
4048
|
-
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};`;
|
|
4049
|
-
return `XYW_${await this.encryptPayload(await this.encryptText(text), platform)}`;
|
|
4050
|
-
}
|
|
4051
|
-
dumps(...rest) {
|
|
4052
|
-
const [data, replacer = null, space = 0] = rest;
|
|
4053
|
-
return JSON.stringify(data, replacer, space).replace(/\n/g, "").replace(/":\s+"/g, '":"');
|
|
4054
|
-
}
|
|
4055
|
-
constructor(){
|
|
4056
|
-
this.words = [
|
|
4057
|
-
929260340,
|
|
4058
|
-
1633971297,
|
|
4059
|
-
895580464,
|
|
4060
|
-
925905270
|
|
4061
|
-
];
|
|
4062
|
-
this.keyBytes = __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.concat(this.words.map((word)=>new Uint8Array(__WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from([
|
|
4063
|
-
word >> 24 & 0xff,
|
|
4064
|
-
word >> 16 & 0xff,
|
|
4065
|
-
word >> 8 & 0xff,
|
|
4066
|
-
0xff & word
|
|
4067
|
-
]))));
|
|
4068
|
-
this.iv = __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from("4uzjr7mbsibcaldp", "utf8");
|
|
4069
|
-
}
|
|
4070
|
-
}
|
|
4071
4087
|
const xiaohongshuPublish_mock_errnoMap = {
|
|
4072
4088
|
915: "所属C端账号手机号被修改,请重新登录",
|
|
4073
4089
|
914: "所属C端账号密码被修改,请重新登录",
|
|
4074
4090
|
903: "账户已登出,需重新登陆重试!",
|
|
4075
|
-
902: "登录已过期,请重新登录!"
|
|
4091
|
+
902: "登录已过期,请重新登录!",
|
|
4092
|
+
906: "账号存在风险,请重新登录"
|
|
4076
4093
|
};
|
|
4077
|
-
const
|
|
4094
|
+
const mock_xsEncrypt = new XsEncrypt();
|
|
4078
4095
|
const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
4079
4096
|
const tmpCachePath = task.getTmpPath();
|
|
4080
4097
|
const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
|
|
@@ -4104,7 +4121,7 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
|
4104
4121
|
});
|
|
4105
4122
|
const fetchCoverUrl = `/api/media/v1/upload/creator/permit?biz_name=spectrum&scene=image&file_count=${params.banners.length}&version=1&source=web`;
|
|
4106
4123
|
const xt = Date.now().toString();
|
|
4107
|
-
const xs = await
|
|
4124
|
+
const xs = await mock_xsEncrypt.encryptXs(fetchCoverUrl, a1Cookie, xt);
|
|
4108
4125
|
const coverIdInfo = await http.api({
|
|
4109
4126
|
method: "get",
|
|
4110
4127
|
baseURL: "https://creator.xiaohongshu.com",
|
|
@@ -4115,41 +4132,71 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
|
4115
4132
|
"x-t": xt
|
|
4116
4133
|
}
|
|
4117
4134
|
});
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4135
|
+
let uploadInfos = [];
|
|
4136
|
+
coverIdInfo.data.uploadTempPermits.map((item)=>{
|
|
4137
|
+
uploadInfos.push({
|
|
4138
|
+
bucket: "",
|
|
4139
|
+
uploadAddr: item.uploadAddr,
|
|
4140
|
+
fileIds: item.fileIds,
|
|
4141
|
+
token: item.token
|
|
4142
|
+
});
|
|
4143
|
+
});
|
|
4144
|
+
if (0 === uploadInfos.length) return {
|
|
4121
4145
|
code: 200,
|
|
4122
4146
|
message: "图片上传失败,请稍后重试!",
|
|
4123
4147
|
data: ""
|
|
4124
4148
|
};
|
|
4125
|
-
const uploadFile = async (url, index)=>{
|
|
4149
|
+
const uploadFile = async (url, index, infoIndex = 0)=>{
|
|
4126
4150
|
const fileName = (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.getFilenameFromUrl)(url);
|
|
4127
4151
|
const localUrl = await (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.downloadImage)(url, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(tmpCachePath, fileName));
|
|
4128
|
-
const ossFileId = coverIds[index];
|
|
4129
4152
|
const fileBuffer = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readFileSync(localUrl);
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4153
|
+
const tryUpload = async (uploadIndex)=>{
|
|
4154
|
+
if (uploadIndex >= uploadInfos.length) {
|
|
4155
|
+
__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].unlinkSync(localUrl);
|
|
4156
|
+
return {
|
|
4157
|
+
ossFileId: "",
|
|
4158
|
+
ossToken: ""
|
|
4159
|
+
};
|
|
4160
|
+
}
|
|
4161
|
+
const currentInfo = uploadInfos[uploadIndex];
|
|
4162
|
+
const ossFileId = currentInfo.fileIds[0];
|
|
4163
|
+
const ossToken = currentInfo.token;
|
|
4164
|
+
const ossDomain = currentInfo.uploadAddr;
|
|
4165
|
+
try {
|
|
4166
|
+
await http.api({
|
|
4167
|
+
method: "put",
|
|
4168
|
+
url: `https://${ossDomain}/${ossFileId}`,
|
|
4169
|
+
data: fileBuffer,
|
|
4170
|
+
headers: {
|
|
4171
|
+
"x-cos-security-token": ossToken
|
|
4172
|
+
},
|
|
4173
|
+
defaultErrorMsg: "图片上传异常,请稍后重试发布。"
|
|
4174
|
+
});
|
|
4175
|
+
return {
|
|
4176
|
+
ossFileId,
|
|
4177
|
+
ossToken
|
|
4178
|
+
};
|
|
4179
|
+
} catch (error) {
|
|
4180
|
+
return tryUpload(uploadIndex + 1);
|
|
4181
|
+
}
|
|
4142
4182
|
};
|
|
4183
|
+
return tryUpload(infoIndex);
|
|
4143
4184
|
};
|
|
4144
4185
|
const coverInfos = await Promise.all(params.banners.map((it, idx)=>uploadFile(it, idx)));
|
|
4186
|
+
const invalidUpload = coverInfos.find((it)=>"" === it.ossToken || "" == it.ossFileId);
|
|
4187
|
+
if (invalidUpload) return {
|
|
4188
|
+
code: 200,
|
|
4189
|
+
message: "图片上传异常,请稍后重试发布。",
|
|
4190
|
+
data: ""
|
|
4191
|
+
};
|
|
4145
4192
|
if (params.topic && params.topic.length > 0) await Promise.all(params.topic.map(async (topic)=>{
|
|
4146
4193
|
if (!topic["id"]) {
|
|
4147
4194
|
const topicData = {
|
|
4148
4195
|
topic_names: topic["name"]
|
|
4149
4196
|
};
|
|
4150
|
-
const topicDataStr =
|
|
4197
|
+
const topicDataStr = mock_xsEncrypt.dumps(topicData);
|
|
4151
4198
|
const publishXt = Date.now().toString();
|
|
4152
|
-
const publishXs = await
|
|
4199
|
+
const publishXs = await mock_xsEncrypt.encryptXs(`/web_api/sns/capa/postgw/topic/batch_customized${topicDataStr}`, a1Cookie, publishXt);
|
|
4153
4200
|
let createTopic = await http.api({
|
|
4154
4201
|
method: "POST",
|
|
4155
4202
|
url: "https://edith.xiaohongshu.com/web_api/sns/capa/postgw/topic/batch_customized",
|
|
@@ -4248,9 +4295,9 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
|
4248
4295
|
} : {}
|
|
4249
4296
|
};
|
|
4250
4297
|
publishData.common.business_binds = JSON.stringify(business_binds);
|
|
4251
|
-
const publishDataStr =
|
|
4298
|
+
const publishDataStr = mock_xsEncrypt.dumps(publishData);
|
|
4252
4299
|
const publishXt = Date.now().toString();
|
|
4253
|
-
const publishXs = await
|
|
4300
|
+
const publishXs = await mock_xsEncrypt.encryptXs(`/web_api/sns/v2/note${publishDataStr}`, a1Cookie, publishXt);
|
|
4254
4301
|
const publishResult = await http.api({
|
|
4255
4302
|
method: "post",
|
|
4256
4303
|
url: "https://edith.xiaohongshu.com/web_api/sns/v2/note",
|
|
@@ -4479,7 +4526,7 @@ const xiaohongshuPublish = async (task, params)=>{
|
|
|
4479
4526
|
return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
|
|
4480
4527
|
};
|
|
4481
4528
|
var package_namespaceObject = {
|
|
4482
|
-
i8: "1.2.
|
|
4529
|
+
i8: "1.2.14"
|
|
4483
4530
|
};
|
|
4484
4531
|
class Action {
|
|
4485
4532
|
constructor(task){
|