@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.js
CHANGED
|
@@ -1981,6 +1981,60 @@ var __webpack_exports__ = {};
|
|
|
1981
1981
|
return (0, share_namespaceObject.success)([]);
|
|
1982
1982
|
}
|
|
1983
1983
|
};
|
|
1984
|
+
const external_node_buffer_namespaceObject = require("node:buffer");
|
|
1985
|
+
const external_node_crypto_namespaceObject = require("node:crypto");
|
|
1986
|
+
var external_node_crypto_default = /*#__PURE__*/ __webpack_require__.n(external_node_crypto_namespaceObject);
|
|
1987
|
+
class XsEncrypt {
|
|
1988
|
+
async encryptMD5(url) {
|
|
1989
|
+
return external_node_crypto_default().createHash("md5").update(url, "utf8").digest("hex");
|
|
1990
|
+
}
|
|
1991
|
+
async encryptText(text) {
|
|
1992
|
+
const textEncoded = external_node_buffer_namespaceObject.Buffer.from(text).toString("base64");
|
|
1993
|
+
const cipher = external_node_crypto_default().createCipheriv("aes-128-cbc", new Uint8Array(this.keyBytes), new Uint8Array(this.iv));
|
|
1994
|
+
const ciphertext = cipher.update(textEncoded, "utf8", "base64");
|
|
1995
|
+
return ciphertext + cipher.final("base64");
|
|
1996
|
+
}
|
|
1997
|
+
async base64ToHex(encodedData) {
|
|
1998
|
+
const decodedData = external_node_buffer_namespaceObject.Buffer.from(encodedData, "base64");
|
|
1999
|
+
return decodedData.toString("hex");
|
|
2000
|
+
}
|
|
2001
|
+
async encryptPayload(payload, platform) {
|
|
2002
|
+
const hexPayload = await this.base64ToHex(payload);
|
|
2003
|
+
const obj = {
|
|
2004
|
+
signSvn: "56",
|
|
2005
|
+
signType: "x2",
|
|
2006
|
+
appID: platform,
|
|
2007
|
+
signVersion: "1",
|
|
2008
|
+
payload: hexPayload
|
|
2009
|
+
};
|
|
2010
|
+
const jsonString = JSON.stringify(obj, null, 0);
|
|
2011
|
+
return external_node_buffer_namespaceObject.Buffer.from(jsonString).toString("base64");
|
|
2012
|
+
}
|
|
2013
|
+
async encryptXs(url, a1, ts, platform = "xhs-pc-web") {
|
|
2014
|
+
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};`;
|
|
2015
|
+
return `XYW_${await this.encryptPayload(await this.encryptText(text), platform)}`;
|
|
2016
|
+
}
|
|
2017
|
+
dumps(...rest) {
|
|
2018
|
+
const [data, replacer = null, space = 0] = rest;
|
|
2019
|
+
return JSON.stringify(data, replacer, space).replace(/\n/g, "").replace(/":\s+"/g, '":"');
|
|
2020
|
+
}
|
|
2021
|
+
constructor(){
|
|
2022
|
+
this.words = [
|
|
2023
|
+
929260340,
|
|
2024
|
+
1633971297,
|
|
2025
|
+
895580464,
|
|
2026
|
+
925905270
|
|
2027
|
+
];
|
|
2028
|
+
this.keyBytes = external_node_buffer_namespaceObject.Buffer.concat(this.words.map((word)=>new Uint8Array(external_node_buffer_namespaceObject.Buffer.from([
|
|
2029
|
+
word >> 24 & 0xff,
|
|
2030
|
+
word >> 16 & 0xff,
|
|
2031
|
+
word >> 8 & 0xff,
|
|
2032
|
+
0xff & word
|
|
2033
|
+
]))));
|
|
2034
|
+
this.iv = external_node_buffer_namespaceObject.Buffer.from("4uzjr7mbsibcaldp", "utf8");
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
const xsEncrypt = new XsEncrypt();
|
|
1984
2038
|
const searchXiaohongshuTopicList = async (_task, params)=>{
|
|
1985
2039
|
const http = new Http({
|
|
1986
2040
|
headers: {
|
|
@@ -1989,20 +2043,35 @@ var __webpack_exports__ = {};
|
|
|
1989
2043
|
origin: "https://creator.xiaohongshu.com"
|
|
1990
2044
|
}
|
|
1991
2045
|
});
|
|
2046
|
+
const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
|
|
2047
|
+
if (!a1Cookie) return {
|
|
2048
|
+
code: 200,
|
|
2049
|
+
message: "账号数据异常,请重新绑定账号后重试。",
|
|
2050
|
+
data: []
|
|
2051
|
+
};
|
|
1992
2052
|
try {
|
|
2053
|
+
const xt = Date.now().toString();
|
|
2054
|
+
const topicData = {
|
|
2055
|
+
keyword: params.searchValue,
|
|
2056
|
+
suggest_topic_request: {
|
|
2057
|
+
title: "",
|
|
2058
|
+
desc: `#${params.searchValue}`
|
|
2059
|
+
},
|
|
2060
|
+
page: {
|
|
2061
|
+
page_size: 20,
|
|
2062
|
+
page: 1
|
|
2063
|
+
}
|
|
2064
|
+
};
|
|
2065
|
+
const topicDataStr = xsEncrypt.dumps(topicData);
|
|
2066
|
+
const fatchTopic = `/web_api/sns/v1/search/topic${topicDataStr}`;
|
|
2067
|
+
const xs = await xsEncrypt.encryptXs(fatchTopic, a1Cookie, xt);
|
|
1993
2068
|
const result = await http.api({
|
|
1994
2069
|
method: "post",
|
|
1995
2070
|
url: "https://edith.xiaohongshu.com/web_api/sns/v1/search/topic",
|
|
1996
|
-
data:
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
desc: `#${params.searchValue}`
|
|
2001
|
-
},
|
|
2002
|
-
page: {
|
|
2003
|
-
page_size: 20,
|
|
2004
|
-
page: 1
|
|
2005
|
-
}
|
|
2071
|
+
data: topicData,
|
|
2072
|
+
headers: {
|
|
2073
|
+
"x-s": xs,
|
|
2074
|
+
"x-t": xt
|
|
2006
2075
|
},
|
|
2007
2076
|
defaultErrorMsg: "话题搜索异常,请稍后重试。"
|
|
2008
2077
|
});
|
|
@@ -4066,66 +4135,14 @@ var __webpack_exports__ = {};
|
|
|
4066
4135
|
if ("mockApi" === params.actionType) return weixinmpPublish_mock_mockAction(task, params);
|
|
4067
4136
|
return executeAction(weixinmpPublish_mock_mockAction, weixinmpPublish_rpa_rpaAction)(task, params);
|
|
4068
4137
|
};
|
|
4069
|
-
const external_node_buffer_namespaceObject = require("node:buffer");
|
|
4070
|
-
const external_node_crypto_namespaceObject = require("node:crypto");
|
|
4071
|
-
var external_node_crypto_default = /*#__PURE__*/ __webpack_require__.n(external_node_crypto_namespaceObject);
|
|
4072
|
-
class XsEncrypt {
|
|
4073
|
-
async encryptMD5(url) {
|
|
4074
|
-
return external_node_crypto_default().createHash("md5").update(url, "utf8").digest("hex");
|
|
4075
|
-
}
|
|
4076
|
-
async encryptText(text) {
|
|
4077
|
-
const textEncoded = external_node_buffer_namespaceObject.Buffer.from(text).toString("base64");
|
|
4078
|
-
const cipher = external_node_crypto_default().createCipheriv("aes-128-cbc", new Uint8Array(this.keyBytes), new Uint8Array(this.iv));
|
|
4079
|
-
const ciphertext = cipher.update(textEncoded, "utf8", "base64");
|
|
4080
|
-
return ciphertext + cipher.final("base64");
|
|
4081
|
-
}
|
|
4082
|
-
async base64ToHex(encodedData) {
|
|
4083
|
-
const decodedData = external_node_buffer_namespaceObject.Buffer.from(encodedData, "base64");
|
|
4084
|
-
return decodedData.toString("hex");
|
|
4085
|
-
}
|
|
4086
|
-
async encryptPayload(payload, platform) {
|
|
4087
|
-
const hexPayload = await this.base64ToHex(payload);
|
|
4088
|
-
const obj = {
|
|
4089
|
-
signSvn: "56",
|
|
4090
|
-
signType: "x2",
|
|
4091
|
-
appID: platform,
|
|
4092
|
-
signVersion: "1",
|
|
4093
|
-
payload: hexPayload
|
|
4094
|
-
};
|
|
4095
|
-
const jsonString = JSON.stringify(obj, null, 0);
|
|
4096
|
-
return external_node_buffer_namespaceObject.Buffer.from(jsonString).toString("base64");
|
|
4097
|
-
}
|
|
4098
|
-
async encryptXs(url, a1, ts, platform = "xhs-pc-web") {
|
|
4099
|
-
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};`;
|
|
4100
|
-
return `XYW_${await this.encryptPayload(await this.encryptText(text), platform)}`;
|
|
4101
|
-
}
|
|
4102
|
-
dumps(...rest) {
|
|
4103
|
-
const [data, replacer = null, space = 0] = rest;
|
|
4104
|
-
return JSON.stringify(data, replacer, space).replace(/\n/g, "").replace(/":\s+"/g, '":"');
|
|
4105
|
-
}
|
|
4106
|
-
constructor(){
|
|
4107
|
-
this.words = [
|
|
4108
|
-
929260340,
|
|
4109
|
-
1633971297,
|
|
4110
|
-
895580464,
|
|
4111
|
-
925905270
|
|
4112
|
-
];
|
|
4113
|
-
this.keyBytes = external_node_buffer_namespaceObject.Buffer.concat(this.words.map((word)=>new Uint8Array(external_node_buffer_namespaceObject.Buffer.from([
|
|
4114
|
-
word >> 24 & 0xff,
|
|
4115
|
-
word >> 16 & 0xff,
|
|
4116
|
-
word >> 8 & 0xff,
|
|
4117
|
-
0xff & word
|
|
4118
|
-
]))));
|
|
4119
|
-
this.iv = external_node_buffer_namespaceObject.Buffer.from("4uzjr7mbsibcaldp", "utf8");
|
|
4120
|
-
}
|
|
4121
|
-
}
|
|
4122
4138
|
const xiaohongshuPublish_mock_errnoMap = {
|
|
4123
4139
|
915: "所属C端账号手机号被修改,请重新登录",
|
|
4124
4140
|
914: "所属C端账号密码被修改,请重新登录",
|
|
4125
4141
|
903: "账户已登出,需重新登陆重试!",
|
|
4126
|
-
902: "登录已过期,请重新登录!"
|
|
4142
|
+
902: "登录已过期,请重新登录!",
|
|
4143
|
+
906: "账号存在风险,请重新登录"
|
|
4127
4144
|
};
|
|
4128
|
-
const
|
|
4145
|
+
const mock_xsEncrypt = new XsEncrypt();
|
|
4129
4146
|
const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
4130
4147
|
const tmpCachePath = task.getTmpPath();
|
|
4131
4148
|
const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
|
|
@@ -4155,7 +4172,7 @@ var __webpack_exports__ = {};
|
|
|
4155
4172
|
});
|
|
4156
4173
|
const fetchCoverUrl = `/api/media/v1/upload/creator/permit?biz_name=spectrum&scene=image&file_count=${params.banners.length}&version=1&source=web`;
|
|
4157
4174
|
const xt = Date.now().toString();
|
|
4158
|
-
const xs = await
|
|
4175
|
+
const xs = await mock_xsEncrypt.encryptXs(fetchCoverUrl, a1Cookie, xt);
|
|
4159
4176
|
const coverIdInfo = await http.api({
|
|
4160
4177
|
method: "get",
|
|
4161
4178
|
baseURL: "https://creator.xiaohongshu.com",
|
|
@@ -4166,41 +4183,71 @@ var __webpack_exports__ = {};
|
|
|
4166
4183
|
"x-t": xt
|
|
4167
4184
|
}
|
|
4168
4185
|
});
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4186
|
+
let uploadInfos = [];
|
|
4187
|
+
coverIdInfo.data.uploadTempPermits.map((item)=>{
|
|
4188
|
+
uploadInfos.push({
|
|
4189
|
+
bucket: "",
|
|
4190
|
+
uploadAddr: item.uploadAddr,
|
|
4191
|
+
fileIds: item.fileIds,
|
|
4192
|
+
token: item.token
|
|
4193
|
+
});
|
|
4194
|
+
});
|
|
4195
|
+
if (0 === uploadInfos.length) return {
|
|
4172
4196
|
code: 200,
|
|
4173
4197
|
message: "图片上传失败,请稍后重试!",
|
|
4174
4198
|
data: ""
|
|
4175
4199
|
};
|
|
4176
|
-
const uploadFile = async (url, index)=>{
|
|
4200
|
+
const uploadFile = async (url, index, infoIndex = 0)=>{
|
|
4177
4201
|
const fileName = (0, share_namespaceObject.getFilenameFromUrl)(url);
|
|
4178
4202
|
const localUrl = await (0, share_namespaceObject.downloadImage)(url, external_node_path_default().join(tmpCachePath, fileName));
|
|
4179
|
-
const ossFileId = coverIds[index];
|
|
4180
4203
|
const fileBuffer = external_node_fs_default().readFileSync(localUrl);
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4204
|
+
const tryUpload = async (uploadIndex)=>{
|
|
4205
|
+
if (uploadIndex >= uploadInfos.length) {
|
|
4206
|
+
external_node_fs_default().unlinkSync(localUrl);
|
|
4207
|
+
return {
|
|
4208
|
+
ossFileId: "",
|
|
4209
|
+
ossToken: ""
|
|
4210
|
+
};
|
|
4211
|
+
}
|
|
4212
|
+
const currentInfo = uploadInfos[uploadIndex];
|
|
4213
|
+
const ossFileId = currentInfo.fileIds[0];
|
|
4214
|
+
const ossToken = currentInfo.token;
|
|
4215
|
+
const ossDomain = currentInfo.uploadAddr;
|
|
4216
|
+
try {
|
|
4217
|
+
await http.api({
|
|
4218
|
+
method: "put",
|
|
4219
|
+
url: `https://${ossDomain}/${ossFileId}`,
|
|
4220
|
+
data: fileBuffer,
|
|
4221
|
+
headers: {
|
|
4222
|
+
"x-cos-security-token": ossToken
|
|
4223
|
+
},
|
|
4224
|
+
defaultErrorMsg: "图片上传异常,请稍后重试发布。"
|
|
4225
|
+
});
|
|
4226
|
+
return {
|
|
4227
|
+
ossFileId,
|
|
4228
|
+
ossToken
|
|
4229
|
+
};
|
|
4230
|
+
} catch (error) {
|
|
4231
|
+
return tryUpload(uploadIndex + 1);
|
|
4232
|
+
}
|
|
4193
4233
|
};
|
|
4234
|
+
return tryUpload(infoIndex);
|
|
4194
4235
|
};
|
|
4195
4236
|
const coverInfos = await Promise.all(params.banners.map((it, idx)=>uploadFile(it, idx)));
|
|
4237
|
+
const invalidUpload = coverInfos.find((it)=>"" === it.ossToken || "" == it.ossFileId);
|
|
4238
|
+
if (invalidUpload) return {
|
|
4239
|
+
code: 200,
|
|
4240
|
+
message: "图片上传异常,请稍后重试发布。",
|
|
4241
|
+
data: ""
|
|
4242
|
+
};
|
|
4196
4243
|
if (params.topic && params.topic.length > 0) await Promise.all(params.topic.map(async (topic)=>{
|
|
4197
4244
|
if (!topic["id"]) {
|
|
4198
4245
|
const topicData = {
|
|
4199
4246
|
topic_names: topic["name"]
|
|
4200
4247
|
};
|
|
4201
|
-
const topicDataStr =
|
|
4248
|
+
const topicDataStr = mock_xsEncrypt.dumps(topicData);
|
|
4202
4249
|
const publishXt = Date.now().toString();
|
|
4203
|
-
const publishXs = await
|
|
4250
|
+
const publishXs = await mock_xsEncrypt.encryptXs(`/web_api/sns/capa/postgw/topic/batch_customized${topicDataStr}`, a1Cookie, publishXt);
|
|
4204
4251
|
let createTopic = await http.api({
|
|
4205
4252
|
method: "POST",
|
|
4206
4253
|
url: "https://edith.xiaohongshu.com/web_api/sns/capa/postgw/topic/batch_customized",
|
|
@@ -4299,9 +4346,9 @@ var __webpack_exports__ = {};
|
|
|
4299
4346
|
} : {}
|
|
4300
4347
|
};
|
|
4301
4348
|
publishData.common.business_binds = JSON.stringify(business_binds);
|
|
4302
|
-
const publishDataStr =
|
|
4349
|
+
const publishDataStr = mock_xsEncrypt.dumps(publishData);
|
|
4303
4350
|
const publishXt = Date.now().toString();
|
|
4304
|
-
const publishXs = await
|
|
4351
|
+
const publishXs = await mock_xsEncrypt.encryptXs(`/web_api/sns/v2/note${publishDataStr}`, a1Cookie, publishXt);
|
|
4305
4352
|
const publishResult = await http.api({
|
|
4306
4353
|
method: "post",
|
|
4307
4354
|
url: "https://edith.xiaohongshu.com/web_api/sns/v2/note",
|
|
@@ -4530,7 +4577,7 @@ var __webpack_exports__ = {};
|
|
|
4530
4577
|
return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
|
|
4531
4578
|
};
|
|
4532
4579
|
var package_namespaceObject = {
|
|
4533
|
-
i8: "1.2.
|
|
4580
|
+
i8: "1.2.14"
|
|
4534
4581
|
};
|
|
4535
4582
|
class Action {
|
|
4536
4583
|
constructor(task){
|