@iflyrpa/actions 4.0.4-beta.5 → 4.0.4-beta.7
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/searchPublishInfo/types.d.ts +3 -0
- package/dist/bundle.js +132 -122
- package/dist/bundle.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +132 -122
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +132 -122
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -174,6 +174,7 @@ export declare class Action {
|
|
|
174
174
|
postType: string;
|
|
175
175
|
postStatus: number;
|
|
176
176
|
originalData?: unknown;
|
|
177
|
+
effectiveTime?: number | undefined;
|
|
177
178
|
})[] | undefined;
|
|
178
179
|
timerPublish?: ({
|
|
179
180
|
title: string;
|
|
@@ -248,6 +249,7 @@ export declare class Action {
|
|
|
248
249
|
postType: string;
|
|
249
250
|
postStatus: number;
|
|
250
251
|
originalData?: unknown;
|
|
252
|
+
effectiveTime?: number | undefined;
|
|
251
253
|
})[] | undefined;
|
|
252
254
|
pagination?: {
|
|
253
255
|
pageNum: number;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f29f1122-4d79-5247-a4f3-3314fc4310ad")}catch(e){}}();
|
|
3
1
|
var __webpack_modules__ = {
|
|
4
2
|
"./src/utils/XhsXsCommonEnc.js": function(module) {
|
|
5
3
|
var encrypt_lookup = [
|
|
@@ -4402,7 +4400,7 @@ var __webpack_exports__ = {};
|
|
|
4402
4400
|
});
|
|
4403
4401
|
const package_json_namespaceObject = require("@iflyrpa/share/package.json");
|
|
4404
4402
|
var package_json_default = /*#__PURE__*/ __webpack_require__.n(package_json_namespaceObject);
|
|
4405
|
-
var package_namespaceObject = JSON.parse('{"i8":"4.0.4-beta.
|
|
4403
|
+
var package_namespaceObject = JSON.parse('{"i8":"4.0.4-beta.7"}');
|
|
4406
4404
|
const share_namespaceObject = require("@iflyrpa/share");
|
|
4407
4405
|
const external_node_fs_namespaceObject = require("node:fs");
|
|
4408
4406
|
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
@@ -13591,8 +13589,8 @@ var __webpack_exports__ = {};
|
|
|
13591
13589
|
if (!response || !response.data) return;
|
|
13592
13590
|
const responseData = response.data;
|
|
13593
13591
|
if (response && responseData?.status_code && 0 !== responseData.status_code) {
|
|
13594
|
-
const errorCode = 4 === responseData.status_code ?
|
|
13595
|
-
if (4 === responseData.status_code) task.logger.warn(`[douyinPublish]
|
|
13592
|
+
const errorCode = 4 === responseData.status_code ? 590 : responseData.status_code;
|
|
13593
|
+
if (4 === responseData.status_code) task.logger.warn(`[douyinPublish] status_code:4(ticket-guard 伪装拒绝),映射为 590 触发重新签名重试。原始响应: ${JSON.stringify(responseData)}`);
|
|
13596
13594
|
return {
|
|
13597
13595
|
code: errorCode,
|
|
13598
13596
|
message: responseData.status_msg || "文章发布异常,请稍后重试。",
|
|
@@ -13659,132 +13657,141 @@ var __webpack_exports__ = {};
|
|
|
13659
13657
|
return (0, share_namespaceObject.response)(414, "安全参数 certificate 解析失败,请重新获取后重试", "");
|
|
13660
13658
|
}
|
|
13661
13659
|
const ree_public_key = webProtectData.client_cert.replace("pub.", "");
|
|
13662
|
-
|
|
13663
|
-
|
|
13664
|
-
|
|
13665
|
-
|
|
13666
|
-
|
|
13667
|
-
|
|
13668
|
-
|
|
13669
|
-
|
|
13670
|
-
|
|
13671
|
-
|
|
13672
|
-
|
|
13673
|
-
|
|
13660
|
+
const MAX_SIGN_RETRIES = 3;
|
|
13661
|
+
const SIGN_RETRY_DELAY = 2000;
|
|
13662
|
+
const signAndPublish = async ()=>{
|
|
13663
|
+
let bdTicketGuardClientData;
|
|
13664
|
+
try {
|
|
13665
|
+
bdTicketGuardClientData = getBdV2({
|
|
13666
|
+
ticket,
|
|
13667
|
+
ts_sign: ts_sign,
|
|
13668
|
+
ec_privateKey: ec_privateKey,
|
|
13669
|
+
certificate: certificate,
|
|
13670
|
+
bd_ticket_guard_ree_public_key: ree_public_key
|
|
13671
|
+
});
|
|
13672
|
+
if (!bdTicketGuardClientData || !bdTicketGuardClientData["headers_bd_ticket_guard_client_data"]) {
|
|
13673
|
+
task.logger.error(`[douyinPublish] bdTicketGuardClientData 生成失败或不完整: ${JSON.stringify(bdTicketGuardClientData)}`);
|
|
13674
|
+
throw (0, share_namespaceObject.response)(414, "安全参数 bdTicketGuardClientData 生成失败,请重新获取后重试", "");
|
|
13675
|
+
}
|
|
13676
|
+
} catch (error) {
|
|
13677
|
+
if (error && "object" == typeof error && "code" in error) throw error;
|
|
13678
|
+
task.logger.error(`[douyinPublish] 生成 bdTicketGuardClientData 失败: ${error}`);
|
|
13679
|
+
throw (0, share_namespaceObject.response)(414, "安全参数 bdTicketGuardClientData 生成异常,请重新获取后重试", "");
|
|
13674
13680
|
}
|
|
13675
|
-
|
|
13676
|
-
|
|
13677
|
-
|
|
13678
|
-
|
|
13679
|
-
|
|
13680
|
-
|
|
13681
|
-
|
|
13682
|
-
|
|
13683
|
-
|
|
13684
|
-
|
|
13685
|
-
|
|
13686
|
-
|
|
13687
|
-
|
|
13688
|
-
|
|
13689
|
-
|
|
13690
|
-
|
|
13681
|
+
task.logger.info("[douyinPublish] bdTicketGuardClientData 生成成功");
|
|
13682
|
+
const publishQuery = {
|
|
13683
|
+
...publishParams,
|
|
13684
|
+
a_bogus: ""
|
|
13685
|
+
};
|
|
13686
|
+
const queryString = new URLSearchParams(publishQuery).toString();
|
|
13687
|
+
let aBogus;
|
|
13688
|
+
try {
|
|
13689
|
+
aBogus = mock_getABogus(`https://creator.douyin.com/web/api/media/aweme/create_v2/?${queryString}`, publishData, userAgent);
|
|
13690
|
+
if (!aBogus || aBogus.length < 10) {
|
|
13691
|
+
task.logger.error(`[douyinPublish] a_bogus 生成异常,长度过短: ${aBogus}`);
|
|
13692
|
+
throw (0, share_namespaceObject.response)(414, "安全参数 a_bogus 生成失败,请重试", "");
|
|
13693
|
+
}
|
|
13694
|
+
} catch (error) {
|
|
13695
|
+
if (error && "object" == typeof error && "code" in error) throw error;
|
|
13696
|
+
task.logger.error(`[douyinPublish] 生成 a_bogus 失败: ${error}`);
|
|
13697
|
+
throw (0, share_namespaceObject.response)(414, "安全参数 a_bogus 生成异常,请重试", "");
|
|
13691
13698
|
}
|
|
13692
|
-
|
|
13693
|
-
|
|
13694
|
-
|
|
13695
|
-
|
|
13696
|
-
|
|
13697
|
-
|
|
13698
|
-
|
|
13699
|
-
|
|
13700
|
-
|
|
13701
|
-
|
|
13702
|
-
|
|
13703
|
-
|
|
13704
|
-
|
|
13705
|
-
|
|
13706
|
-
|
|
13707
|
-
|
|
13708
|
-
|
|
13699
|
+
publishQuery.a_bogus = aBogus;
|
|
13700
|
+
const publishQueryParams = new URLSearchParams(publishQuery).toString();
|
|
13701
|
+
let csrfToken;
|
|
13702
|
+
try {
|
|
13703
|
+
csrfToken = mock_generateCsrfTokenAdvanced({
|
|
13704
|
+
cookies: params.cookies,
|
|
13705
|
+
url: "https://creator.douyin.com/web/api/media/aweme/create_v2/",
|
|
13706
|
+
method: "POST",
|
|
13707
|
+
userAgent
|
|
13708
|
+
});
|
|
13709
|
+
if (!csrfToken || csrfToken.length < 10) {
|
|
13710
|
+
task.logger.error(`[douyinPublish] csrfToken 生成异常,长度过短: ${csrfToken}`);
|
|
13711
|
+
throw (0, share_namespaceObject.response)(414, "安全参数 csrfToken 生成失败,请重试", "");
|
|
13712
|
+
}
|
|
13713
|
+
task.logger.info(`[douyinPublish] csrfToken 生成成功: ${csrfToken.substring(0, 20)}...`);
|
|
13714
|
+
} catch (error) {
|
|
13715
|
+
if (error && "object" == typeof error && "code" in error) throw error;
|
|
13716
|
+
task.logger.error(`[douyinPublish] 生成 csrfToken 失败: ${error}`);
|
|
13717
|
+
throw (0, share_namespaceObject.response)(414, "安全参数 csrfToken 生成异常,请重试", "");
|
|
13709
13718
|
}
|
|
13710
|
-
|
|
13711
|
-
|
|
13712
|
-
|
|
13713
|
-
|
|
13714
|
-
|
|
13715
|
-
|
|
13716
|
-
|
|
13717
|
-
|
|
13718
|
-
|
|
13719
|
-
|
|
13720
|
-
|
|
13721
|
-
|
|
13722
|
-
|
|
13723
|
-
|
|
13724
|
-
|
|
13725
|
-
|
|
13726
|
-
|
|
13727
|
-
|
|
13728
|
-
|
|
13729
|
-
|
|
13730
|
-
|
|
13731
|
-
|
|
13732
|
-
|
|
13733
|
-
|
|
13734
|
-
"x-tt-session-dtrait": sessionDtrait || ""
|
|
13735
|
-
})}`);
|
|
13736
|
-
task.logger.info(`[douyinPublish] url: https://creator.douyin.com/web/api/media/aweme/create_v2/?${publishQueryParams}`);
|
|
13737
|
-
let publishResult;
|
|
13738
|
-
try {
|
|
13739
|
-
publishResult = await proxyHttp.api({
|
|
13719
|
+
let sessionDtrait;
|
|
13720
|
+
try {
|
|
13721
|
+
sessionDtrait = mock_generateDtrait("/web/api/media/aweme/create_v2/");
|
|
13722
|
+
task.logger.info(`[douyinPublish] sessionDtrait 生成成功: ${sessionDtrait || "(空)"}`);
|
|
13723
|
+
} catch (error) {
|
|
13724
|
+
task.logger.error(`[douyinPublish] 生成 sessionDtrait 失败: ${error}`);
|
|
13725
|
+
throw (0, share_namespaceObject.response)(414, "安全参数 sessionDtrait 生成异常,请重试", "");
|
|
13726
|
+
}
|
|
13727
|
+
const requestHeaders = {
|
|
13728
|
+
...headers,
|
|
13729
|
+
Referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
|
|
13730
|
+
"Content-Type": "application/json",
|
|
13731
|
+
Accept: "application/json, text/plain, */*",
|
|
13732
|
+
"bd-ticket-guard-client-data": bdTicketGuardClientData["headers_bd_ticket_guard_client_data"],
|
|
13733
|
+
"bd-ticket-guard-ree-public-key": bdTicketGuardClientData["headers_bd_ticket_guard_ree_public_key"],
|
|
13734
|
+
"bd-ticket-guard-version": "2",
|
|
13735
|
+
"bd-ticket-guard-web-sign-type": "1",
|
|
13736
|
+
"bd-ticket-guard-web-version": "2",
|
|
13737
|
+
"x-secsdk-csrf-token": csrfToken,
|
|
13738
|
+
"x-tt-session-dtrait": sessionDtrait || ""
|
|
13739
|
+
};
|
|
13740
|
+
task.logger.info(`[douyinPublish] headers: ${JSON.stringify(requestHeaders)}`);
|
|
13741
|
+
task.logger.info(`[douyinPublish] url: https://creator.douyin.com/web/api/media/aweme/create_v2/?${publishQueryParams}`);
|
|
13742
|
+
return proxyHttp.api({
|
|
13740
13743
|
method: "post",
|
|
13741
13744
|
url: `https://creator.douyin.com/web/api/media/aweme/create_v2/?${publishQueryParams}`,
|
|
13742
13745
|
data: publishData,
|
|
13743
13746
|
defaultErrorMsg: "发布异常,请稍后重试。",
|
|
13744
|
-
headers:
|
|
13745
|
-
...headers,
|
|
13746
|
-
Referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
|
|
13747
|
-
"Content-Type": "application/json",
|
|
13748
|
-
Accept: "application/json, text/plain, */*",
|
|
13749
|
-
"bd-ticket-guard-client-data": bdTicketGuardClientData["headers_bd_ticket_guard_client_data"],
|
|
13750
|
-
"bd-ticket-guard-ree-public-key": bdTicketGuardClientData["headers_bd_ticket_guard_ree_public_key"],
|
|
13751
|
-
"bd-ticket-guard-version": "2",
|
|
13752
|
-
"bd-ticket-guard-web-sign-type": "1",
|
|
13753
|
-
"bd-ticket-guard-web-version": "2",
|
|
13754
|
-
"x-secsdk-csrf-token": csrfToken,
|
|
13755
|
-
"x-tt-session-dtrait": sessionDtrait || ""
|
|
13756
|
-
}
|
|
13747
|
+
headers: requestHeaders
|
|
13757
13748
|
}, {
|
|
13758
13749
|
timeout: 60000,
|
|
13759
|
-
retries:
|
|
13760
|
-
retryDelay: 2000
|
|
13750
|
+
retries: 0
|
|
13761
13751
|
});
|
|
13762
|
-
}
|
|
13763
|
-
|
|
13764
|
-
|
|
13765
|
-
|
|
13766
|
-
|
|
13767
|
-
|
|
13768
|
-
|
|
13769
|
-
|
|
13770
|
-
|
|
13771
|
-
|
|
13772
|
-
|
|
13773
|
-
const
|
|
13774
|
-
|
|
13775
|
-
|
|
13776
|
-
|
|
13777
|
-
|
|
13778
|
-
|
|
13779
|
-
|
|
13780
|
-
|
|
13781
|
-
|
|
13782
|
-
|
|
13783
|
-
|
|
13784
|
-
|
|
13752
|
+
};
|
|
13753
|
+
let publishResult;
|
|
13754
|
+
for(let attempt = 0; attempt < MAX_SIGN_RETRIES; attempt++){
|
|
13755
|
+
if (attempt > 0) {
|
|
13756
|
+
task.logger.warn(`[douyinPublish] 第 ${attempt} 次重新签名后重试(上次为 ticket-guard 拒绝)`);
|
|
13757
|
+
await new Promise((resolve)=>setTimeout(resolve, SIGN_RETRY_DELAY));
|
|
13758
|
+
}
|
|
13759
|
+
try {
|
|
13760
|
+
publishResult = await signAndPublish();
|
|
13761
|
+
break;
|
|
13762
|
+
} catch (error) {
|
|
13763
|
+
const handledError = Http.handleApiError(error);
|
|
13764
|
+
if (590 === handledError.code) {
|
|
13765
|
+
if (attempt < MAX_SIGN_RETRIES - 1) continue;
|
|
13766
|
+
task.logger.error(`[douyinPublish] ticket-guard 拒绝重试已用尽(${MAX_SIGN_RETRIES} 次),走兜底`);
|
|
13767
|
+
throw error;
|
|
13768
|
+
}
|
|
13769
|
+
const isProxyOrNetworkError = [
|
|
13770
|
+
599,
|
|
13771
|
+
500,
|
|
13772
|
+
502,
|
|
13773
|
+
503,
|
|
13774
|
+
504
|
|
13775
|
+
].includes(handledError.code);
|
|
13776
|
+
if (isProxyOrNetworkError) {
|
|
13777
|
+
const isProxyRequest = handledError.extra?.isProxyRequest === true;
|
|
13778
|
+
const errorType = 599 === handledError.code || isProxyRequest ? "代理错误" : "网络错误";
|
|
13779
|
+
const message = `图文发布失败,${errorType}:${handledError.message}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
13780
|
+
task.logger.error(`[douyinPublish] ${errorType},直接返回: ${message}`, stringifyError(handledError));
|
|
13781
|
+
await updateTaskState?.({
|
|
13782
|
+
state: share_namespaceObject.TaskState.FAILED,
|
|
13783
|
+
error: message
|
|
13784
|
+
});
|
|
13785
|
+
return {
|
|
13786
|
+
code: 414,
|
|
13787
|
+
data: "",
|
|
13788
|
+
message
|
|
13789
|
+
};
|
|
13790
|
+
}
|
|
13791
|
+
throw error;
|
|
13785
13792
|
}
|
|
13786
|
-
throw error;
|
|
13787
13793
|
}
|
|
13794
|
+
if (!publishResult) throw (0, share_namespaceObject.response)(414, "发布异常,请稍后重试。", "");
|
|
13788
13795
|
task.logger.info(`[douyinPublish] decision值: ${JSON.stringify(decision)}, needsVerification(decision): ${needsVerification(decision)}`);
|
|
13789
13796
|
if (needsVerification(decision)) {
|
|
13790
13797
|
const details = [
|
|
@@ -15931,7 +15938,8 @@ var __webpack_exports__ = {};
|
|
|
15931
15938
|
favNum: schemas_number(),
|
|
15932
15939
|
objectId: schemas_string(),
|
|
15933
15940
|
postType: schemas_string(),
|
|
15934
|
-
postStatus: schemas_number()
|
|
15941
|
+
postStatus: schemas_number(),
|
|
15942
|
+
effectiveTime: schemas_number().optional()
|
|
15935
15943
|
});
|
|
15936
15944
|
const FetchArticlesDataSchema = schemas_object({
|
|
15937
15945
|
articleCell: schemas_array(union([
|
|
@@ -16267,6 +16275,9 @@ var __webpack_exports__ = {};
|
|
|
16267
16275
|
objectId: item.exportId || item.objectId || "",
|
|
16268
16276
|
postType: forcePostType,
|
|
16269
16277
|
postStatus: item.status || item.post_status || 0,
|
|
16278
|
+
...item.effectiveTime ? {
|
|
16279
|
+
effectiveTime: item.effectiveTime
|
|
16280
|
+
} : {},
|
|
16270
16281
|
...showOriginalData ? {
|
|
16271
16282
|
originalData: item
|
|
16272
16283
|
} : {}
|
|
@@ -25675,5 +25686,4 @@ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_targe
|
|
|
25675
25686
|
value: true
|
|
25676
25687
|
});
|
|
25677
25688
|
|
|
25678
|
-
//# sourceMappingURL=index.js.map
|
|
25679
|
-
//# debugId=f29f1122-4d79-5247-a4f3-3314fc4310ad
|
|
25689
|
+
//# sourceMappingURL=index.js.map
|