@iflyrpa/actions 4.0.0-beta.6 → 5.0.0-beta.1
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 +279 -82
- package/dist/bundle.js.map +1 -1
- package/dist/index.js +278 -81
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +278 -81
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -5434,7 +5434,7 @@ function __webpack_require__(moduleId) {
|
|
|
5434
5434
|
return module;
|
|
5435
5435
|
};
|
|
5436
5436
|
})();
|
|
5437
|
-
var package_namespaceObject = JSON.parse('{"i8":"4.0.
|
|
5437
|
+
var package_namespaceObject = JSON.parse('{"i8":"4.0.1-beta.0"}');
|
|
5438
5438
|
var dist = __webpack_require__("../../node_modules/.pnpm/https-proxy-agent@7.0.6/node_modules/https-proxy-agent/dist/index.js");
|
|
5439
5439
|
async function ProxyAgent(task, ip, adr, accountId, refresh) {
|
|
5440
5440
|
const http = new Http({
|
|
@@ -5520,7 +5520,8 @@ class Http {
|
|
|
5520
5520
|
url: error.config?.url,
|
|
5521
5521
|
isProxyRequest: !!(error.config && (error.config.httpAgent || error.config.httpsAgent)),
|
|
5522
5522
|
params: error.config?.params,
|
|
5523
|
-
data: error.config?.data
|
|
5523
|
+
data: error.config?.data,
|
|
5524
|
+
serverDate: error.response?.headers?.date
|
|
5524
5525
|
}
|
|
5525
5526
|
};
|
|
5526
5527
|
if (foundError) Object.assign(errorResponse, foundError);
|
|
@@ -5598,7 +5599,7 @@ class Http {
|
|
|
5598
5599
|
try {
|
|
5599
5600
|
this.proxyInfo = agent ? `${agent.ip}:${agent.port}` : void 0;
|
|
5600
5601
|
const controller = new AbortController();
|
|
5601
|
-
const timeoutId = setTimeout(()=>controller.abort(), reqTimeout);
|
|
5602
|
+
const timeoutId = setTimeout(()=>controller.abort(), reqTimeout + 500);
|
|
5602
5603
|
const response = await this.apiClient({
|
|
5603
5604
|
...config,
|
|
5604
5605
|
timeout: reqTimeout,
|
|
@@ -5622,7 +5623,7 @@ class Http {
|
|
|
5622
5623
|
599
|
|
5623
5624
|
].includes(handledError.code);
|
|
5624
5625
|
if (Rtimes < retries && isRetry) {
|
|
5625
|
-
this.logger?.info(`进入第${Rtimes + 1}
|
|
5626
|
+
this.logger?.info(`进入第${Rtimes + 1}次重试!错误码: ${handledError.code}`);
|
|
5626
5627
|
await new Promise((resolve)=>setTimeout(resolve, retryDelay));
|
|
5627
5628
|
return sessionRt(Rtimes + 1);
|
|
5628
5629
|
}
|
|
@@ -9837,23 +9838,26 @@ const rpaServer = async (task, params)=>{
|
|
|
9837
9838
|
};
|
|
9838
9839
|
}
|
|
9839
9840
|
case types_ExecutionState.SUCCESS:
|
|
9840
|
-
|
|
9841
|
-
|
|
9842
|
-
|
|
9843
|
-
|
|
9844
|
-
|
|
9845
|
-
|
|
9846
|
-
|
|
9847
|
-
|
|
9848
|
-
|
|
9849
|
-
|
|
9850
|
-
|
|
9851
|
-
|
|
9852
|
-
|
|
9853
|
-
|
|
9854
|
-
|
|
9855
|
-
|
|
9856
|
-
|
|
9841
|
+
{
|
|
9842
|
+
const cookie = JSON.stringify(await task.steelBrowserContext?.cookies());
|
|
9843
|
+
await updateTaskState?.({
|
|
9844
|
+
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.SUCCESS,
|
|
9845
|
+
result: {
|
|
9846
|
+
cookie,
|
|
9847
|
+
token,
|
|
9848
|
+
userInfo: userInfo
|
|
9849
|
+
}
|
|
9850
|
+
});
|
|
9851
|
+
return {
|
|
9852
|
+
code: 0,
|
|
9853
|
+
message: "成功",
|
|
9854
|
+
data: {
|
|
9855
|
+
cookie,
|
|
9856
|
+
token,
|
|
9857
|
+
userInfo
|
|
9858
|
+
}
|
|
9859
|
+
};
|
|
9860
|
+
}
|
|
9857
9861
|
default:
|
|
9858
9862
|
return {
|
|
9859
9863
|
code: 500,
|
|
@@ -10210,20 +10214,11 @@ const mockAction = async (task, params)=>{
|
|
|
10210
10214
|
};
|
|
10211
10215
|
const rpa_rpaAction = async (task, params)=>{
|
|
10212
10216
|
const tmpCachePath = task.getTmpPath();
|
|
10213
|
-
const
|
|
10214
|
-
path: "/",
|
|
10215
|
-
secure: true,
|
|
10216
|
-
domain: "baijiahao.baidu.com",
|
|
10217
|
-
url: "https://baijiahao.baidu.com",
|
|
10218
|
-
httpOnly: true
|
|
10219
|
-
};
|
|
10217
|
+
const validCookies = (params.cookies || []).filter((it)=>it.name && it.value && "undefined" !== it.value);
|
|
10220
10218
|
const page = await task.createPage({
|
|
10221
10219
|
show: task.debug,
|
|
10222
10220
|
url: params.url || "https://baijiahao.baidu.com/builder/rc/edit?type=news&is_from_cms=1",
|
|
10223
|
-
cookies:
|
|
10224
|
-
...it,
|
|
10225
|
-
...commonCookies
|
|
10226
|
-
})) || []
|
|
10221
|
+
cookies: validCookies
|
|
10227
10222
|
});
|
|
10228
10223
|
page.setDefaultTimeout(60000);
|
|
10229
10224
|
page.setDefaultNavigationTimeout(60000);
|
|
@@ -11756,6 +11751,8 @@ class Xhshow {
|
|
|
11756
11751
|
}
|
|
11757
11752
|
new Xhshow();
|
|
11758
11753
|
const sessionCheck_xsEncrypt = new Xhshow();
|
|
11754
|
+
let lastEnvLogTime = 0;
|
|
11755
|
+
const ENV_LOG_INTERVAL_MS = 5000;
|
|
11759
11756
|
const SessionCheckResultSchema = schemas_object({
|
|
11760
11757
|
isValidSession: schemas_boolean()
|
|
11761
11758
|
});
|
|
@@ -11820,6 +11817,23 @@ const WxSessionCheck = async (_task, params)=>{
|
|
|
11820
11817
|
}, "微信账号有效性检测完成!");
|
|
11821
11818
|
};
|
|
11822
11819
|
const XhsSessionCheck = async (_task, params)=>{
|
|
11820
|
+
const now = Date.now();
|
|
11821
|
+
const shouldLogEnv = now - lastEnvLogTime >= ENV_LOG_INTERVAL_MS;
|
|
11822
|
+
if (shouldLogEnv) {
|
|
11823
|
+
lastEnvLogTime = now;
|
|
11824
|
+
_task.logger?.debug("[XhsSessionCheck] 环境信息", {
|
|
11825
|
+
processType: process.type,
|
|
11826
|
+
pid: process.pid,
|
|
11827
|
+
nodeVersion: process.version,
|
|
11828
|
+
platform: process.platform,
|
|
11829
|
+
memoryUsage: {
|
|
11830
|
+
heapUsed: `${Math.round(process.memoryUsage().heapUsed / 1024 / 1024)} MB`,
|
|
11831
|
+
heapTotal: `${Math.round(process.memoryUsage().heapTotal / 1024 / 1024)} MB`
|
|
11832
|
+
},
|
|
11833
|
+
accountId: params.accountId,
|
|
11834
|
+
hasProxy: !!(params.proxyLoc || params.localIP)
|
|
11835
|
+
});
|
|
11836
|
+
}
|
|
11823
11837
|
const check = {
|
|
11824
11838
|
isValidSession: false,
|
|
11825
11839
|
isValidWebSession: false
|
|
@@ -11856,7 +11870,32 @@ const XhsSessionCheck = async (_task, params)=>{
|
|
|
11856
11870
|
if (cookie.name && cookie.value) acc[cookie.name] = cookie.value;
|
|
11857
11871
|
return acc;
|
|
11858
11872
|
}, {});
|
|
11859
|
-
|
|
11873
|
+
let loginBaseXsHeader;
|
|
11874
|
+
try {
|
|
11875
|
+
loginBaseXsHeader = sessionCheck_xsEncrypt.signHeadersGet(loginBasePath, recordCookie, "xhs-pc-web", null);
|
|
11876
|
+
} catch (signError) {
|
|
11877
|
+
_task.logger?.error("[XhsSessionCheck] 签名生成失败 - 环境快照", {
|
|
11878
|
+
accountId: params.accountId,
|
|
11879
|
+
error: signError instanceof Error ? signError.message : String(signError),
|
|
11880
|
+
stack: _task.debug ? signError instanceof Error ? signError.stack : void 0 : void 0,
|
|
11881
|
+
hasA1: !!recordCookie.a1,
|
|
11882
|
+
env: {
|
|
11883
|
+
processType: process.type,
|
|
11884
|
+
memoryUsage: {
|
|
11885
|
+
heapUsed: `${Math.round(process.memoryUsage().heapUsed / 1024 / 1024)} MB`,
|
|
11886
|
+
heapTotal: `${Math.round(process.memoryUsage().heapTotal / 1024 / 1024)} MB`
|
|
11887
|
+
},
|
|
11888
|
+
hasProxy: !!(params.proxyLoc || params.localIP),
|
|
11889
|
+
timeSinceLastLog: Date.now() - lastEnvLogTime
|
|
11890
|
+
}
|
|
11891
|
+
});
|
|
11892
|
+
return {
|
|
11893
|
+
code: 500,
|
|
11894
|
+
message: "账号签名生成失败,请稍后重试。",
|
|
11895
|
+
data: check
|
|
11896
|
+
};
|
|
11897
|
+
}
|
|
11898
|
+
const baseInfoStart = Date.now();
|
|
11860
11899
|
const _baseInfo = http.api({
|
|
11861
11900
|
method: "get",
|
|
11862
11901
|
baseURL: "https://creator.xiaohongshu.com",
|
|
@@ -11865,23 +11904,43 @@ const XhsSessionCheck = async (_task, params)=>{
|
|
|
11865
11904
|
}, {
|
|
11866
11905
|
retries: 3,
|
|
11867
11906
|
retryDelay: 20,
|
|
11868
|
-
timeout:
|
|
11869
|
-
}).catch((e)=>
|
|
11907
|
+
timeout: 5000
|
|
11908
|
+
}).catch((e)=>{
|
|
11909
|
+
const clientTimestamp = Date.now();
|
|
11910
|
+
const serverDate = e?.extra?.serverDate;
|
|
11911
|
+
const serverTimestamp = serverDate ? new Date(serverDate).getTime() : null;
|
|
11912
|
+
const timeDriftMs = serverTimestamp ? clientTimestamp - serverTimestamp : null;
|
|
11913
|
+
_task.logger?.warn("[XhsSessionCheck] creator base 接口请求失败", {
|
|
11914
|
+
accountId: params.accountId,
|
|
11915
|
+
duration: Date.now() - baseInfoStart,
|
|
11916
|
+
code: e?.code,
|
|
11917
|
+
message: e?.message,
|
|
11918
|
+
data: e?.data,
|
|
11919
|
+
extra: e?.extra,
|
|
11920
|
+
proxyInfo: http.proxyInfo,
|
|
11921
|
+
clientTimestamp,
|
|
11922
|
+
serverDate,
|
|
11923
|
+
serverTimestamp,
|
|
11924
|
+
timeDriftMs,
|
|
11925
|
+
isLikelyClockDrift: null !== timeDriftMs && Math.abs(timeDriftMs) > 300000
|
|
11926
|
+
});
|
|
11927
|
+
return e.data;
|
|
11928
|
+
});
|
|
11870
11929
|
const _web_session = http.api({
|
|
11871
11930
|
method: "get",
|
|
11872
11931
|
url: "https://edith.xiaohongshu.com/api/sns/web/unread_count"
|
|
11873
11932
|
}, {
|
|
11874
11933
|
retries: 3,
|
|
11875
11934
|
retryDelay: 20,
|
|
11876
|
-
timeout:
|
|
11935
|
+
timeout: 5000
|
|
11877
11936
|
});
|
|
11878
11937
|
const [baseInfo, web_session] = await Promise.all([
|
|
11879
11938
|
_baseInfo,
|
|
11880
11939
|
_web_session
|
|
11881
11940
|
]);
|
|
11882
11941
|
if (baseInfo?.code === 0) check.isValidSession = true;
|
|
11883
|
-
if (
|
|
11884
|
-
baseInfo?.code, web_session
|
|
11942
|
+
if (web_session?.code === 0) check.isValidWebSession = true;
|
|
11943
|
+
baseInfo?.code, web_session?.code;
|
|
11885
11944
|
const message = `小红书账号有效性检测成功${_task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
11886
11945
|
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(check, message);
|
|
11887
11946
|
};
|
|
@@ -14411,7 +14470,10 @@ const mock_mockAction = async (task, params)=>{
|
|
|
14411
14470
|
task.logger.info(`拦截器收到响应response.data: ${JSON.stringify(response.data)} `);
|
|
14412
14471
|
decision = parseVerifyPassportDecision(response.headers["x-tt-verify-passport-decision"]);
|
|
14413
14472
|
if (needsVerification(decision)) {
|
|
14414
|
-
task.logger.
|
|
14473
|
+
task.logger.warn(`检测到需要验证: ${JSON.stringify(decision)}`);
|
|
14474
|
+
task.logger.warn(`验证类型: ${decision?.verify_ways?.join(", ")}`);
|
|
14475
|
+
task.logger.warn(`验证标题: ${decision?.verify_title}`);
|
|
14476
|
+
task.logger.warn(`验证描述: ${decision?.verify_desc}`);
|
|
14415
14477
|
return;
|
|
14416
14478
|
}
|
|
14417
14479
|
if (!response || !response.data) return;
|
|
@@ -14438,38 +14500,116 @@ const mock_mockAction = async (task, params)=>{
|
|
|
14438
14500
|
});
|
|
14439
14501
|
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(0, message, data);
|
|
14440
14502
|
}
|
|
14441
|
-
|
|
14442
|
-
|
|
14443
|
-
|
|
14444
|
-
|
|
14445
|
-
|
|
14503
|
+
let webProtectData;
|
|
14504
|
+
try {
|
|
14505
|
+
webProtectData = JSON.parse(JSON.parse(params.extraParam["security-sdk/s_sdk_sign_data_key/web_protect"] || "{}").data || "{}");
|
|
14506
|
+
if (!webProtectData.ticket || !webProtectData.ts_sign || !webProtectData.client_cert) {
|
|
14507
|
+
task.logger.error(`webProtectData 关键字段缺失: ${JSON.stringify(webProtectData)}`);
|
|
14508
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 webProtectData 不完整,请重新获取后重试", "");
|
|
14509
|
+
}
|
|
14510
|
+
} catch (error) {
|
|
14511
|
+
task.logger.error(`解析 webProtectData 失败: ${error}`);
|
|
14512
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 webProtectData 解析失败,请重新获取后重试", "");
|
|
14513
|
+
}
|
|
14514
|
+
let ticket = webProtectData.ticket;
|
|
14515
|
+
let ts_sign = webProtectData.ts_sign;
|
|
14516
|
+
const serverDataCookie = params.cookies.find((it)=>"bd_ticket_guard_server_data" === it.name)?.value;
|
|
14517
|
+
if (serverDataCookie) try {
|
|
14518
|
+
const decoded = JSON.parse(Buffer.from(decodeURIComponent(serverDataCookie), "base64").toString("utf8"));
|
|
14519
|
+
if (decoded.ticket && decoded.ts_sign) {
|
|
14520
|
+
if (decoded.ticket !== ticket) task.logger.info("使用 cookie 中的最新 ticket(web_protect 已过期)");
|
|
14521
|
+
ticket = decoded.ticket;
|
|
14522
|
+
ts_sign = decoded.ts_sign;
|
|
14523
|
+
}
|
|
14524
|
+
} catch (error) {
|
|
14525
|
+
task.logger.warn(`解析 bd_ticket_guard_server_data 失败,回退到 web_protect: ${error}`);
|
|
14526
|
+
}
|
|
14527
|
+
let ec_privateKey;
|
|
14528
|
+
try {
|
|
14529
|
+
ec_privateKey = JSON.parse(JSON.parse(params.extraParam["security-sdk/s_sdk_crypt_sdk"] || "{}").data || "{}").ec_privateKey;
|
|
14530
|
+
if (!ec_privateKey) {
|
|
14531
|
+
task.logger.error("ec_privateKey 为空");
|
|
14532
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 ec_privateKey 缺失,请重新获取后重试", "");
|
|
14533
|
+
}
|
|
14534
|
+
} catch (error) {
|
|
14535
|
+
task.logger.error(`解析 ec_privateKey 失败: ${error}`);
|
|
14536
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 ec_privateKey 解析失败,请重新获取后重试", "");
|
|
14537
|
+
}
|
|
14538
|
+
let certificate;
|
|
14539
|
+
try {
|
|
14540
|
+
certificate = JSON.parse(params.extraParam["security-sdk/s_sdk_server_cert_key"] || "{}").cert;
|
|
14541
|
+
if (!certificate) {
|
|
14542
|
+
task.logger.error("certificate 为空");
|
|
14543
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 certificate 缺失,请重新获取后重试", "");
|
|
14544
|
+
}
|
|
14545
|
+
} catch (error) {
|
|
14546
|
+
task.logger.error(`解析 certificate 失败: ${error}`);
|
|
14547
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 certificate 解析失败,请重新获取后重试", "");
|
|
14548
|
+
}
|
|
14446
14549
|
const ree_public_key = webProtectData.client_cert.replace("pub.", "");
|
|
14447
|
-
task.logger.info(`生成 bdTicketGuardClientData 的参数: ticket: ${ticket
|
|
14448
|
-
|
|
14449
|
-
|
|
14450
|
-
|
|
14451
|
-
|
|
14452
|
-
|
|
14453
|
-
|
|
14454
|
-
|
|
14455
|
-
|
|
14456
|
-
|
|
14457
|
-
|
|
14550
|
+
task.logger.info(`生成 bdTicketGuardClientData 的参数: ticket: ${ticket?.substring(0, 20)}..., ts_sign: ${ts_sign}, ree_public_key: ${ree_public_key?.substring(0, 20)}...`);
|
|
14551
|
+
let bdTicketGuardClientData;
|
|
14552
|
+
try {
|
|
14553
|
+
bdTicketGuardClientData = getBdV2({
|
|
14554
|
+
ticket,
|
|
14555
|
+
ts_sign: ts_sign,
|
|
14556
|
+
ec_privateKey: ec_privateKey,
|
|
14557
|
+
certificate: certificate,
|
|
14558
|
+
bd_ticket_guard_ree_public_key: ree_public_key
|
|
14559
|
+
});
|
|
14560
|
+
if (!bdTicketGuardClientData || !bdTicketGuardClientData["headers_bd_ticket_guard_client_data"]) {
|
|
14561
|
+
task.logger.error(`bdTicketGuardClientData 生成失败或不完整: ${JSON.stringify(bdTicketGuardClientData)}`);
|
|
14562
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 bdTicketGuardClientData 生成失败,请重新获取后重试", "");
|
|
14563
|
+
}
|
|
14564
|
+
} catch (error) {
|
|
14565
|
+
task.logger.error(`生成 bdTicketGuardClientData 失败: ${error}`);
|
|
14566
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 bdTicketGuardClientData 生成异常,请重新获取后重试", "");
|
|
14567
|
+
}
|
|
14568
|
+
task.logger.info("bdTicketGuardClientData 生成成功");
|
|
14458
14569
|
const publishQuery = {
|
|
14459
14570
|
...publishParams,
|
|
14460
14571
|
a_bogus: ""
|
|
14461
14572
|
};
|
|
14462
14573
|
const queryString = new URLSearchParams(publishQuery).toString();
|
|
14463
|
-
|
|
14574
|
+
let aBogus;
|
|
14575
|
+
try {
|
|
14576
|
+
aBogus = mock_getABogus(`https://creator.douyin.com/web/api/media/aweme/create_v2/?${queryString}`, publishData, userAgent);
|
|
14577
|
+
if (!aBogus || aBogus.length < 10) {
|
|
14578
|
+
task.logger.error(`a_bogus 生成异常,长度过短: ${aBogus}`);
|
|
14579
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 a_bogus 生成失败,请重试", "");
|
|
14580
|
+
}
|
|
14581
|
+
task.logger.info(`a_bogus 生成成功: ${aBogus.substring(0, 20)}...`);
|
|
14582
|
+
} catch (error) {
|
|
14583
|
+
task.logger.error(`生成 a_bogus 失败: ${error}`);
|
|
14584
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 a_bogus 生成异常,请重试", "");
|
|
14585
|
+
}
|
|
14464
14586
|
publishQuery.a_bogus = aBogus;
|
|
14465
14587
|
const publishQueryParams = new URLSearchParams(publishQuery).toString();
|
|
14466
|
-
|
|
14467
|
-
|
|
14468
|
-
|
|
14469
|
-
|
|
14470
|
-
|
|
14471
|
-
|
|
14472
|
-
|
|
14588
|
+
let csrfToken;
|
|
14589
|
+
try {
|
|
14590
|
+
csrfToken = mock_generateCsrfTokenAdvanced({
|
|
14591
|
+
cookies: params.cookies,
|
|
14592
|
+
url: "https://creator.douyin.com/web/api/media/aweme/create_v2/",
|
|
14593
|
+
method: "POST",
|
|
14594
|
+
userAgent
|
|
14595
|
+
});
|
|
14596
|
+
if (!csrfToken || csrfToken.length < 10) {
|
|
14597
|
+
task.logger.error(`csrfToken 生成异常,长度过短: ${csrfToken}`);
|
|
14598
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 csrfToken 生成失败,请重试", "");
|
|
14599
|
+
}
|
|
14600
|
+
task.logger.info(`csrfToken 生成成功: ${csrfToken.substring(0, 20)}...`);
|
|
14601
|
+
} catch (error) {
|
|
14602
|
+
task.logger.error(`生成 csrfToken 失败: ${error}`);
|
|
14603
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 csrfToken 生成异常,请重试", "");
|
|
14604
|
+
}
|
|
14605
|
+
let sessionDtrait;
|
|
14606
|
+
try {
|
|
14607
|
+
sessionDtrait = mock_generateDtrait("/web/api/media/aweme/create_v2/");
|
|
14608
|
+
task.logger.info(`sessionDtrait 生成成功: ${sessionDtrait || "(空)"}`);
|
|
14609
|
+
} catch (error) {
|
|
14610
|
+
task.logger.error(`生成 sessionDtrait 失败: ${error}`);
|
|
14611
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "安全参数 sessionDtrait 生成异常,请重试", "");
|
|
14612
|
+
}
|
|
14473
14613
|
task.logger.info("发布数据", {
|
|
14474
14614
|
data: JSON.stringify(publishData)
|
|
14475
14615
|
});
|
|
@@ -23072,6 +23212,33 @@ const xiaohongshuLogin_rpa_rpaAction = async (task, _params)=>{
|
|
|
23072
23212
|
const encode_mnsv2 = __webpack_require__("./src/utils/xhs_ob/x_s.encoder.js");
|
|
23073
23213
|
const xiaohongshuLogin_rpa_server_scanRetryMaxCount = 60;
|
|
23074
23214
|
const xiaohongshuLogin_rpa_server_waitQrcodeResultMaxTime = 2000 * xiaohongshuLogin_rpa_server_scanRetryMaxCount;
|
|
23215
|
+
async function collectCookiesWithA1(task) {
|
|
23216
|
+
const hasA1 = (cookies)=>cookies.some((c)=>"a1" === c.name && !!c.value);
|
|
23217
|
+
let cookies = await task.steelBrowserContext?.cookies() ?? [];
|
|
23218
|
+
if (hasA1(cookies)) return cookies;
|
|
23219
|
+
task.logger?.warn("[XhsLogin] 首次抓取缺失 a1,尝试补救……");
|
|
23220
|
+
try {
|
|
23221
|
+
const page = task.steelBrowserContext?.pages?.()[0];
|
|
23222
|
+
if (page) {
|
|
23223
|
+
await page.goto("https://www.xiaohongshu.com", {
|
|
23224
|
+
waitUntil: "domcontentloaded",
|
|
23225
|
+
timeout: 15000
|
|
23226
|
+
});
|
|
23227
|
+
for(let i = 0; i < 10; i++){
|
|
23228
|
+
cookies = await task.steelBrowserContext?.cookies() ?? [];
|
|
23229
|
+
if (hasA1(cookies)) {
|
|
23230
|
+
task.logger?.info(`[XhsLogin] a1 补救成功,第 ${i + 1} 次轮询命中`);
|
|
23231
|
+
return cookies;
|
|
23232
|
+
}
|
|
23233
|
+
await new Promise((resolve)=>setTimeout(resolve, 500));
|
|
23234
|
+
}
|
|
23235
|
+
}
|
|
23236
|
+
} catch (err) {
|
|
23237
|
+
task.logger?.warn("[XhsLogin] a1 补救访问主站失败", err);
|
|
23238
|
+
}
|
|
23239
|
+
cookies = await task.steelBrowserContext?.cookies() ?? [];
|
|
23240
|
+
return cookies;
|
|
23241
|
+
}
|
|
23075
23242
|
const xiaohongshuLogin_rpa_server_rpaServer = async (task, params)=>{
|
|
23076
23243
|
const updateTaskState = task.taskStageStore?.update?.bind(task.taskStageStore, task.taskId || "");
|
|
23077
23244
|
const reporter = task.reportService?.reportLoginStatus ?? (()=>Promise.resolve());
|
|
@@ -23272,21 +23439,29 @@ const xiaohongshuLogin_rpa_server_rpaServer = async (task, params)=>{
|
|
|
23272
23439
|
};
|
|
23273
23440
|
}
|
|
23274
23441
|
case types_ExecutionState.SUCCESS:
|
|
23275
|
-
|
|
23276
|
-
|
|
23277
|
-
|
|
23278
|
-
|
|
23279
|
-
|
|
23280
|
-
}
|
|
23281
|
-
|
|
23282
|
-
|
|
23283
|
-
|
|
23284
|
-
|
|
23285
|
-
|
|
23286
|
-
|
|
23287
|
-
|
|
23288
|
-
}
|
|
23289
|
-
|
|
23442
|
+
{
|
|
23443
|
+
const cookies = await collectCookiesWithA1(task);
|
|
23444
|
+
const hasA1 = cookies.some((c)=>"a1" === c.name && !!c.value);
|
|
23445
|
+
if (!hasA1) task.logger?.warn("[XhsLogin] 登录成功但缺失关键 cookie a1,后续检测可能失败", {
|
|
23446
|
+
cookieNames: cookies.map((c)=>c.name)
|
|
23447
|
+
});
|
|
23448
|
+
const cookieStr = JSON.stringify(cookies);
|
|
23449
|
+
await updateTaskState?.({
|
|
23450
|
+
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.SUCCESS,
|
|
23451
|
+
result: {
|
|
23452
|
+
cookie: cookieStr,
|
|
23453
|
+
userInfo: userInfo
|
|
23454
|
+
}
|
|
23455
|
+
});
|
|
23456
|
+
return {
|
|
23457
|
+
code: 0,
|
|
23458
|
+
message: "成功",
|
|
23459
|
+
data: {
|
|
23460
|
+
cookie: cookieStr,
|
|
23461
|
+
userInfo
|
|
23462
|
+
}
|
|
23463
|
+
};
|
|
23464
|
+
}
|
|
23290
23465
|
default:
|
|
23291
23466
|
return {
|
|
23292
23467
|
code: 500,
|
|
@@ -23487,6 +23662,14 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
|
23487
23662
|
const fileName = (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.getFilenameFromUrl)(url);
|
|
23488
23663
|
const localUrl = await (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.downloadImage)(url, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(tmpCachePath, fileName));
|
|
23489
23664
|
const fileBuffer = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readFileSync(localUrl);
|
|
23665
|
+
let width = 0;
|
|
23666
|
+
let height = 0;
|
|
23667
|
+
try {
|
|
23668
|
+
const dimensions = (0, __WEBPACK_EXTERNAL_MODULE_image_size_bc738ffb__["default"])(fileBuffer);
|
|
23669
|
+
width = dimensions.width ?? 0;
|
|
23670
|
+
height = dimensions.height ?? 0;
|
|
23671
|
+
} catch {}
|
|
23672
|
+
const originSize = fileBuffer.byteLength / 1024;
|
|
23490
23673
|
const MAX_RETRIES = uploadInfos.length;
|
|
23491
23674
|
let attempt = 0;
|
|
23492
23675
|
while(attempt < MAX_RETRIES){
|
|
@@ -23508,7 +23691,10 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
|
23508
23691
|
});
|
|
23509
23692
|
return {
|
|
23510
23693
|
ossFileId,
|
|
23511
|
-
ossToken
|
|
23694
|
+
ossToken,
|
|
23695
|
+
width,
|
|
23696
|
+
height,
|
|
23697
|
+
originSize
|
|
23512
23698
|
};
|
|
23513
23699
|
} catch (error) {
|
|
23514
23700
|
attempt++;
|
|
@@ -23516,7 +23702,10 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
|
23516
23702
|
}
|
|
23517
23703
|
return {
|
|
23518
23704
|
ossFileId: "",
|
|
23519
|
-
ossToken: ""
|
|
23705
|
+
ossToken: "",
|
|
23706
|
+
width,
|
|
23707
|
+
height,
|
|
23708
|
+
originSize
|
|
23520
23709
|
};
|
|
23521
23710
|
};
|
|
23522
23711
|
const coverInfos = await Promise.all(params.banners.map((it, idx)=>uploadFile(it, idx)));
|
|
@@ -23581,8 +23770,16 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
|
23581
23770
|
},
|
|
23582
23771
|
image_info: {
|
|
23583
23772
|
images: coverInfos.map((it)=>({
|
|
23584
|
-
extra_info_json:
|
|
23773
|
+
extra_info_json: JSON.stringify({
|
|
23774
|
+
mimeType: "image/png",
|
|
23775
|
+
image_metadata: {
|
|
23776
|
+
bg_color: "",
|
|
23777
|
+
origin_size: it.originSize
|
|
23778
|
+
}
|
|
23779
|
+
}),
|
|
23585
23780
|
file_id: it.ossFileId,
|
|
23781
|
+
width: it.width,
|
|
23782
|
+
height: it.height,
|
|
23586
23783
|
metadata: {
|
|
23587
23784
|
source: -1
|
|
23588
23785
|
},
|