@iflyrpa/actions 4.1.1-beta.0 → 4.1.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  /*! For license information please see bundle.js.LICENSE.txt */
2
2
 
3
- !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]="fb6eb3b8-9fcc-53e7-9e60-cd649507d5fa")}catch(e){}}();
3
+ !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]="999100f4-e52b-5a9b-a84f-9134dd77b21a")}catch(e){}}();
4
4
  var __webpack_modules__ = {
5
5
  "../../node_modules/.pnpm/agent-base@7.1.4/node_modules/agent-base/dist/helpers.js": function(__unused_webpack_module, exports1, __webpack_require__) {
6
6
  "use strict";
@@ -12493,7 +12493,9 @@ var __webpack_exports__ = {};
12493
12493
  var package_namespaceObject = {
12494
12494
  i8: "0.2.0"
12495
12495
  };
12496
- var package_namespaceObject_0 = JSON.parse('{"i8":"4.1.1-beta.0"}');
12496
+ var package_namespaceObject_0 = {
12497
+ i8: "4.1.1"
12498
+ };
12497
12499
  const external_node_fs_namespaceObject = require("node:fs");
12498
12500
  var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
12499
12501
  const external_node_http_namespaceObject = require("node:http");
@@ -33752,1066 +33754,493 @@ var __webpack_exports__ = {};
33752
33754
  if (0 === desc.errno) fans.description = desc.data.user.wishes;
33753
33755
  return success(fans, "获取粉丝数成功!");
33754
33756
  };
33755
- class CryptoConfig {
33756
- static{
33757
- this.MAX_32BIT = 0xFFFFFFFF;
33758
- }
33759
- static{
33760
- this.MAX_SIGNED_32BIT = 0x7FFFFFFF;
33761
- }
33762
- static{
33763
- this.MAX_BYTE = 255;
33764
- }
33765
- static{
33766
- this.STANDARD_BASE64_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
33767
- }
33768
- static{
33769
- this.CUSTOM_BASE64_ALPHABET = "ZmserbBoHQtNP+wOcza/LpngG8yJq42KWYj0DSfdikx3VT16IlUAFM97hECvuRX5";
33770
- }
33771
- static{
33772
- this.X3_BASE64_ALPHABET = "MfgqrsbcyzPQRStuvC7mn501HIJBo2DEFTKdeNOwxWXYZap89+/A4UVLhijkl63G";
33773
- }
33774
- static{
33775
- this.HEX_KEY = "71a302257793271ddd273bcee3e4b98d9d7935e1da33f5765e2ea8afb6dc77a51a499d23b67c20660025860cbf13d4540d92497f58686c574e508f46e1956344f39139bf4faf22a3eef120b79258145b2feb5193b6478669961298e79bedca646e1a693a926154a5a7a1bd1cf0dedb742f917a747a1e388b234f2277";
33776
- }
33777
- static{
33778
- this.EXPECTED_HEX_LENGTH = 32;
33779
- }
33780
- static{
33781
- this.OUTPUT_BYTE_COUNT = 8;
33782
- }
33783
- static{
33784
- this.HEX_CHUNK_SIZE = 2;
33785
- }
33786
- static{
33787
- this.VERSION_BYTES = [
33788
- 119,
33789
- 104,
33790
- 96,
33791
- 41
33792
- ];
33793
- }
33794
- static{
33795
- this.SEQUENCE_VALUE_MIN = 15;
33796
- }
33797
- static{
33798
- this.SEQUENCE_VALUE_MAX = 50;
33799
- }
33800
- static{
33801
- this.WINDOW_PROPS_LENGTH_MIN = 900;
33802
- }
33803
- static{
33804
- this.WINDOW_PROPS_LENGTH_MAX = 1200;
33805
- }
33806
- static{
33807
- this.CHECKSUM_VERSION = 1;
33808
- }
33809
- static{
33810
- this.CHECKSUM_XOR_KEY = 115;
33811
- }
33812
- static{
33813
- this.CHECKSUM_FIXED_TAIL = [
33814
- 249,
33815
- 65,
33816
- 103,
33817
- 103,
33818
- 201,
33819
- 181,
33820
- 131,
33821
- 99,
33822
- 94,
33823
- 7,
33824
- 68,
33825
- 250,
33826
- 132,
33827
- 21
33828
- ];
33829
- }
33830
- static{
33831
- this.ENV_FINGERPRINT_XOR_KEY = 41;
33832
- }
33833
- static{
33834
- this.ENV_FINGERPRINT_TIME_OFFSET_MIN = 10;
33835
- }
33836
- static{
33837
- this.ENV_FINGERPRINT_TIME_OFFSET_MAX = 50;
33838
- }
33839
- static{
33840
- this.SIGNATURE_DATA_TEMPLATE = {
33841
- x0: "4.2.6",
33842
- x1: "xhs-pc-web",
33843
- x2: "Windows",
33844
- x3: "",
33845
- x4: ""
33846
- };
33847
- }
33848
- static{
33849
- this.X3_PREFIX = "mns0301_";
33850
- }
33851
- static{
33852
- this.XYS_PREFIX = "XYS_";
33853
- }
33854
- static{
33855
- this.HEX_CHARS = "abcdef0123456789";
33856
- }
33857
- static{
33858
- this.XRAY_TRACE_ID_SEQ_MAX = 8388607;
33859
- }
33860
- static{
33861
- this.XRAY_TRACE_ID_TIMESTAMP_SHIFT = 23;
33862
- }
33863
- static{
33864
- this.B3_TRACE_ID_LENGTH = 16;
33865
- }
33866
- static{
33867
- this.PUBLIC_USERAGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 Edg/142.0.0.0";
33868
- }
33869
- static{
33870
- this.SIGNATURE_XSCOMMON_TEMPLATE = {
33871
- s0: 5,
33872
- s1: "",
33873
- x0: "1",
33874
- x1: "4.2.6",
33875
- x2: "Windows",
33876
- x3: "xhs-pc-web",
33877
- x4: "4.86.0",
33878
- x5: "",
33879
- x6: "",
33880
- x7: "",
33881
- x8: "",
33882
- x9: -596800761,
33883
- x10: 0,
33884
- x11: "normal"
33885
- };
33886
- }
33887
- }
33888
- class BitOperations {
33889
- normalizeTo32bit(value) {
33890
- return value & this.config.MAX_32BIT;
33891
- }
33892
- xorTransformArray(inputArray) {
33893
- const keyBytes = this.hexStringToBytes(this.config.HEX_KEY);
33894
- const result = new Uint8Array(inputArray.length);
33895
- for(let i = 0; i < inputArray.length; i++)result[i] = inputArray[i] ^ keyBytes[i % keyBytes.length];
33896
- return result;
33897
- }
33898
- hexStringToBytes(hexString) {
33899
- const bytes = [];
33900
- for(let i = 0; i < hexString.length; i += 2)bytes.push(parseInt(hexString.substr(i, 2), 16));
33901
- return bytes;
33902
- }
33903
- constructor(){
33904
- this.config = CryptoConfig;
33905
- }
33906
- }
33907
- class RandomGenerator {
33908
- generateRandomBytes(byteCount) {
33909
- const result = [];
33910
- for(let i = 0; i < byteCount; i++)result.push(Math.floor(Math.random() * (this.config.MAX_BYTE + 1)));
33911
- return result;
33912
- }
33913
- generateRandomByteInRange(minVal, maxVal) {
33914
- return Math.floor(Math.random() * (maxVal - minVal + 1)) + minVal;
33915
- }
33916
- generateRandomInt() {
33917
- return Math.floor(Math.random() * (this.config.MAX_32BIT + 1));
33918
- }
33919
- generateB3TraceId() {
33920
- let result = '';
33921
- for(let i = 0; i < this.config.B3_TRACE_ID_LENGTH; i++)result += this.config.HEX_CHARS[Math.floor(Math.random() * this.config.HEX_CHARS.length)];
33922
- return result;
33923
- }
33924
- generateXrayTraceId(timestamp, seq) {
33925
- if (void 0 === timestamp) timestamp = Date.now();
33926
- if (void 0 === seq) seq = Math.floor(Math.random() * (this.config.XRAY_TRACE_ID_SEQ_MAX + 1));
33927
- const part1 = (timestamp << this.config.XRAY_TRACE_ID_TIMESTAMP_SHIFT | seq).toString(16).padStart(16, '0');
33928
- let part2 = '';
33929
- for(let i = 0; i < 16; i++)part2 += this.config.HEX_CHARS[Math.floor(Math.random() * this.config.HEX_CHARS.length)];
33930
- return part1 + part2;
33931
- }
33932
- constructor(){
33933
- this.config = CryptoConfig;
33934
- }
33935
- }
33936
- class Base64Encoder {
33937
- encode(dataToEncode) {
33938
- const dataBytes = Buffer.from(dataToEncode, 'utf-8');
33939
- const standardEncodedString = dataBytes.toString('base64');
33940
- let result = '';
33941
- for (const char of standardEncodedString){
33942
- const index = this.config.STANDARD_BASE64_ALPHABET.indexOf(char);
33943
- if (-1 !== index) result += this.config.CUSTOM_BASE64_ALPHABET[index];
33944
- else result += char;
33757
+ let lastEnvLogTime = 0;
33758
+ const ENV_LOG_INTERVAL_MS = 5000;
33759
+ const SessionCheckResultSchema = classic_schemas_object({
33760
+ isValidSession: classic_schemas_boolean()
33761
+ });
33762
+ const WxBjhSessionParamsSchema = ActionCommonParamsSchema.extend({
33763
+ token: schemas_union([
33764
+ classic_schemas_string(),
33765
+ classic_schemas_number()
33766
+ ])
33767
+ });
33768
+ const TTSessionCheck = async (_task, params)=>{
33769
+ const http = new Http({
33770
+ headers: {
33771
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
33772
+ referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
33945
33773
  }
33946
- return result;
33947
- }
33948
- decode(encodedString) {
33949
- let standardString = '';
33950
- for (const char of encodedString){
33951
- const index = this.config.CUSTOM_BASE64_ALPHABET.indexOf(char);
33952
- if (-1 !== index) standardString += this.config.STANDARD_BASE64_ALPHABET[index];
33953
- else standardString += char;
33774
+ });
33775
+ const res = await http.api({
33776
+ method: "get",
33777
+ url: "https://mp.toutiao.com/mp/agw/creator_center/user_info",
33778
+ defaultErrorMsg: "头条号登录状态失效。"
33779
+ });
33780
+ const isSuccess = 0 === res.code;
33781
+ const message = "头条账号有效性检测成功";
33782
+ const data = isSuccess ? {
33783
+ isValidSession: true
33784
+ } : {
33785
+ isValidSession: false
33786
+ };
33787
+ return success(data, message);
33788
+ };
33789
+ const WxSessionCheck = async (_task, params)=>{
33790
+ const http = new Http({
33791
+ headers: {
33792
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";")
33954
33793
  }
33955
- return Buffer.from(standardString, 'base64').toString('utf-8');
33956
- }
33957
- encodeX3(dataBytes) {
33958
- const base64String = Buffer.from(dataBytes).toString('base64');
33959
- let result = '';
33960
- for (const char of base64String){
33961
- const index = this.config.STANDARD_BASE64_ALPHABET.indexOf(char);
33962
- if (-1 !== index) result += this.config.X3_BASE64_ALPHABET[index];
33963
- else result += char;
33794
+ });
33795
+ const fingerprint = "4695500bc93ab4ce8fb2692da6564e04";
33796
+ const res = await http.api({
33797
+ method: "get",
33798
+ url: "https://mp.weixin.qq.com/cgi-bin/appmsgpublish",
33799
+ params: {
33800
+ fingerprint,
33801
+ sub: "list",
33802
+ begin: 0,
33803
+ count: 10,
33804
+ query: "",
33805
+ type: 1011102103,
33806
+ show_type: "",
33807
+ free_publish_type: 1102103,
33808
+ sub_action: "list_ex",
33809
+ search_card: 0,
33810
+ token: params.token,
33811
+ lang: "zh_CN",
33812
+ f: "json",
33813
+ ajax: 1
33964
33814
  }
33965
- return result;
33815
+ });
33816
+ return success(0 === res.base_resp.ret ? {
33817
+ isValidSession: true
33818
+ } : {
33819
+ isValidSession: false
33820
+ }, "微信账号有效性检测完成!");
33821
+ };
33822
+ const XhsSessionCheck = async (_task, params)=>{
33823
+ const now = Date.now();
33824
+ const shouldLogEnv = now - lastEnvLogTime >= ENV_LOG_INTERVAL_MS;
33825
+ if (shouldLogEnv) {
33826
+ lastEnvLogTime = now;
33827
+ _task.logger?.debug("[XhsSessionCheck] 环境信息", {
33828
+ processType: process.type,
33829
+ pid: process.pid,
33830
+ nodeVersion: process.version,
33831
+ platform: process.platform,
33832
+ memoryUsage: {
33833
+ heapUsed: `${Math.round(process.memoryUsage().heapUsed / 1024 / 1024)} MB`,
33834
+ heapTotal: `${Math.round(process.memoryUsage().heapTotal / 1024 / 1024)} MB`
33835
+ },
33836
+ accountId: params.accountId,
33837
+ hasProxy: !!params.proxyLoc
33838
+ });
33966
33839
  }
33967
- decodeX3(encodedString) {
33968
- let standardString = '';
33969
- for (const char of encodedString){
33970
- const index = this.config.X3_BASE64_ALPHABET.indexOf(char);
33971
- if (-1 !== index) standardString += this.config.STANDARD_BASE64_ALPHABET[index];
33972
- else standardString += char;
33840
+ const check = {
33841
+ isValidSession: false,
33842
+ isValidWebSession: false
33843
+ };
33844
+ const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
33845
+ if (!a1Cookie) return {
33846
+ code: 414,
33847
+ message: "账号数据异常,请重新绑定账号后重试。",
33848
+ data: check
33849
+ };
33850
+ const headers = {
33851
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
33852
+ referer: "https://creator.xiaohongshu.com/new/home?source=official"
33853
+ };
33854
+ const args = [
33855
+ {
33856
+ headers
33857
+ },
33858
+ _task.logger,
33859
+ params.proxyLoc,
33860
+ params.accountId,
33861
+ "xiaohongshu"
33862
+ ];
33863
+ const http = new Http(...args);
33864
+ http.addResponseInterceptor((response)=>{
33865
+ if (response?.status === 401) return {
33866
+ code: response.data.code,
33867
+ message: response.data.msg,
33868
+ data: response.data.data
33869
+ };
33870
+ });
33871
+ const loginBasePath = "/api/galaxy/creator/home/personal_info";
33872
+ const baseInfoStart = Date.now();
33873
+ const baseInfo = await http.api({
33874
+ method: "get",
33875
+ baseURL: "https://creator.xiaohongshu.com",
33876
+ url: loginBasePath
33877
+ }, {
33878
+ retries: 3,
33879
+ retryDelay: 300,
33880
+ timeout: 30000
33881
+ }).catch((e)=>{
33882
+ const clientTimestamp = Date.now();
33883
+ const serverDate = e?.extra?.serverDate;
33884
+ const serverTimestamp = serverDate ? new Date(serverDate).getTime() : null;
33885
+ const timeDriftMs = serverTimestamp ? clientTimestamp - serverTimestamp : null;
33886
+ _task.logger?.warn("[XhsSessionCheck] creator personal_info 接口请求失败", {
33887
+ accountId: params.accountId,
33888
+ duration: Date.now() - baseInfoStart,
33889
+ code: e?.code,
33890
+ message: e?.message,
33891
+ data: e?.data,
33892
+ extra: e?.extra,
33893
+ proxyInfo: http.proxyInfo,
33894
+ clientTimestamp,
33895
+ serverDate,
33896
+ serverTimestamp,
33897
+ timeDriftMs,
33898
+ isLikelyClockDrift: null !== timeDriftMs && Math.abs(timeDriftMs) > 300000
33899
+ });
33900
+ return e.data;
33901
+ });
33902
+ const isValid = baseInfo?.code === 0;
33903
+ check.isValidSession = isValid;
33904
+ check.isValidWebSession = isValid;
33905
+ const message = `小红书账号有效性检测成功${_task.debug ? ` ${http.proxyInfo}` : ""}`;
33906
+ return success(check, message);
33907
+ };
33908
+ const BjhSessionCheck = async (_task, params)=>{
33909
+ const http = new Http({
33910
+ headers: {
33911
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
33912
+ token: params.token,
33913
+ referer: "https://baijiahao.baidu.com/builder/rc/home"
33973
33914
  }
33974
- return new Uint8Array(Buffer.from(standardString, 'base64'));
33975
- }
33976
- constructor(){
33977
- this.config = CryptoConfig;
33978
- }
33979
- }
33980
- class RequestSignatureValidator {
33981
- static validateMethod(method) {
33982
- if ('string' != typeof method) throw new TypeError(`method must be str, got ${typeof method}`);
33983
- const normalizedMethod = method.trim().toUpperCase();
33984
- if (![
33985
- 'GET',
33986
- 'POST'
33987
- ].includes(normalizedMethod)) throw new Error(`method must be 'GET' or 'POST', got '${method}'`);
33988
- return normalizedMethod;
33989
- }
33990
- static validateUri(uri) {
33991
- if ('string' != typeof uri) throw new TypeError(`uri must be str, got ${typeof uri}`);
33992
- if (!uri.trim()) throw new Error('uri cannot be empty');
33993
- return uri.trim();
33994
- }
33995
- static validateA1Value(a1Value) {
33996
- if ('string' != typeof a1Value) throw new TypeError(`a1_value must be str, got ${typeof a1Value}`);
33997
- if (!a1Value.trim()) throw new Error('a1_value cannot be empty');
33998
- return a1Value.trim();
33999
- }
34000
- static validateXsecAppid(xsecAppid) {
34001
- if ('string' != typeof xsecAppid) throw new TypeError(`xsec_appid must be str, got ${typeof xsecAppid}`);
34002
- if (!xsecAppid.trim()) throw new Error('xsec_appid cannot be empty');
34003
- return xsecAppid.trim();
34004
- }
34005
- static validatePayload(payload) {
34006
- if (null !== payload && ('object' != typeof payload || Array.isArray(payload))) throw new TypeError(`payload must be dict or None, got ${typeof payload}`);
34007
- if (null !== payload) {
34008
- for(const key in payload)if ('string' != typeof key) throw new TypeError(`payload keys must be str, got ${typeof key} for key '${key}'`);
33915
+ });
33916
+ const res = await http.api({
33917
+ method: "get",
33918
+ url: "https://baijiahao.baidu.com/user-ui/cms/settingInfo",
33919
+ defaultErrorMsg: "百家号登录状态失效。"
33920
+ });
33921
+ const isSuccess = 0 === res.errno;
33922
+ const message = "百家号账号有效性检测成功";
33923
+ const data = isSuccess ? {
33924
+ isValidSession: true
33925
+ } : {
33926
+ isValidSession: false
33927
+ };
33928
+ return success(data, message);
33929
+ };
33930
+ const DySessionCheck = async (_task, params)=>{
33931
+ const http = new Http({
33932
+ headers: {
33933
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
33934
+ referer: "https://creator.douyin.com/"
34009
33935
  }
34010
- return payload;
34011
- }
34012
- }
34013
- class CryptoProcessor {
34014
- intToLeBytes(val, length = 4) {
34015
- const arr = [];
34016
- for(let i = 0; i < length; i++){
34017
- arr.push(0xFF & val);
34018
- val >>>= 8;
33936
+ });
33937
+ const res = await http.api({
33938
+ method: "get",
33939
+ url: "https://creator.douyin.com/aweme/v1/creator/user/info/",
33940
+ params: {
33941
+ _ts: Date.now()
33942
+ },
33943
+ defaultErrorMsg: "抖音登录状态失效。"
33944
+ });
33945
+ const isSuccess = 0 === res.status_code;
33946
+ const message = "抖音账号有效性检测成功";
33947
+ const data = isSuccess ? {
33948
+ isValidSession: true
33949
+ } : {
33950
+ isValidSession: false
33951
+ };
33952
+ return success(data, message);
33953
+ };
33954
+ const ShipinhaoSessionCheck = async (_task, params)=>{
33955
+ const http = new Http({
33956
+ headers: {
33957
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
33958
+ referer: "https://channels.weixin.qq.com",
33959
+ "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
33960
+ "Content-Type": "application/json"
34019
33961
  }
34020
- return arr;
34021
- }
34022
- envFingerprintA(ts, xorKey) {
34023
- const data = [];
34024
- for(let i = 0; i < 8; i++)data.push(ts >>> 8 * i & 0xFF);
34025
- const sum1 = data.slice(1, 5).reduce((a, b)=>a + b, 0);
34026
- const sum2 = data.slice(5, 8).reduce((a, b)=>a + b, 0);
34027
- const mark = (0xFF & sum1) + sum2 & 0xFF;
34028
- data[0] = mark;
34029
- return data.map((b)=>b ^ xorKey);
34030
- }
34031
- envFingerprintB(ts) {
34032
- const data = [];
34033
- for(let i = 0; i < 8; i++)data.push(ts >>> 8 * i & 0xFF);
34034
- return data;
34035
- }
34036
- buildPayloadArray(hexParameter, a1Value, appIdentifier = "xhs-pc-web", stringParam = "", timestamp) {
34037
- const payload = [];
34038
- payload.push(...this.config.VERSION_BYTES);
34039
- const seed = this.randomGen.generateRandomInt();
34040
- const seedBytes = this.intToLeBytes(seed, 4);
34041
- payload.push(...seedBytes);
34042
- const seedByte0 = seedBytes[0];
34043
- if (void 0 === timestamp) timestamp = Date.now() / 1000;
34044
- const tsMs = Math.floor(1000 * timestamp);
34045
- payload.push(...this.envFingerprintA(tsMs, this.config.ENV_FINGERPRINT_XOR_KEY));
34046
- const timeOffset = this.randomGen.generateRandomByteInRange(this.config.ENV_FINGERPRINT_TIME_OFFSET_MIN, this.config.ENV_FINGERPRINT_TIME_OFFSET_MAX);
34047
- payload.push(...this.envFingerprintB(tsMs - 1000 * timeOffset));
34048
- const sequenceValue = this.randomGen.generateRandomByteInRange(this.config.SEQUENCE_VALUE_MIN, this.config.SEQUENCE_VALUE_MAX);
34049
- payload.push(...this.intToLeBytes(sequenceValue, 4));
34050
- const windowPropsLength = this.randomGen.generateRandomByteInRange(this.config.WINDOW_PROPS_LENGTH_MIN, this.config.WINDOW_PROPS_LENGTH_MAX);
34051
- payload.push(...this.intToLeBytes(windowPropsLength, 4));
34052
- const uriLength = Buffer.from(stringParam, 'utf-8').length;
34053
- payload.push(...this.intToLeBytes(uriLength, 4));
34054
- const md5Bytes = Buffer.from(hexParameter, 'hex');
34055
- for(let i = 0; i < 8; i++)payload.push(md5Bytes[i] ^ seedByte0);
34056
- payload.push(52);
34057
- const a1Bytes = Buffer.from(a1Value, 'utf-8');
34058
- for(let i = 0; i < 52; i++)payload.push(i < a1Bytes.length ? a1Bytes[i] : 0);
34059
- payload.push(10);
34060
- const sourceBytes = Buffer.from(appIdentifier, 'utf-8');
34061
- for(let i = 0; i < 10; i++)payload.push(i < sourceBytes.length ? sourceBytes[i] : 0);
34062
- payload.push(1);
34063
- payload.push(this.config.CHECKSUM_VERSION);
34064
- payload.push(seedByte0 ^ this.config.CHECKSUM_XOR_KEY);
34065
- payload.push(...this.config.CHECKSUM_FIXED_TAIL);
34066
- return payload;
34067
- }
34068
- constructor(){
34069
- this.config = CryptoConfig;
34070
- this.bitOps = new BitOperations();
34071
- this.b64encoder = new Base64Encoder();
34072
- this.randomGen = new RandomGenerator();
34073
- }
34074
- }
34075
- class CRC32 {
34076
- static{
34077
- this.CRC32_TABLE = (()=>{
34078
- const table = [];
34079
- for(let i = 0; i < 256; i++){
34080
- let crc = i;
34081
- for(let j = 0; j < 8; j++)crc = 1 & crc ? 0xEDB88320 ^ crc >>> 1 : crc >>> 1;
34082
- table.push(crc >>> 0);
34083
- }
34084
- return table;
34085
- })();
34086
- }
34087
- static crc32JsInt(input, signed = true) {
34088
- let crc = 0xFFFFFFFF;
34089
- const data = 'string' == typeof input ? this.stringToBytes(input) : input;
34090
- for (const byte of data){
34091
- const index = (crc ^ byte) & 0xFF;
34092
- crc = (this.CRC32_TABLE[index] ^ crc >>> 8) >>> 0;
34093
- }
34094
- crc = (0xFFFFFFFF ^ crc) >>> 0;
34095
- if (signed) return crc > 0x7FFFFFFF ? crc - 0x100000000 : crc;
34096
- return crc;
34097
- }
34098
- static stringToBytes(str) {
34099
- const bytes = [];
34100
- for(let i = 0; i < str.length; i++){
34101
- const code = str.charCodeAt(i);
34102
- if (code <= 0xFF) bytes.push(code);
34103
- else bytes.push(0xFF & code);
33962
+ });
33963
+ const getTimeStamp = (length)=>Date.now().toString().substring(0, length);
33964
+ const requestBody = {
33965
+ timestamp: getTimeStamp(13),
33966
+ _log_finder_uin: "",
33967
+ _log_finder_id: "",
33968
+ rawKeyBuff: null,
33969
+ pluginSessionId: null,
33970
+ scene: 7,
33971
+ reqScene: 7
33972
+ };
33973
+ const res = await http.api({
33974
+ method: "post",
33975
+ url: "https://channels.weixin.qq.com/cgi-bin/mmfinderassistant-bin/auth/auth_data",
33976
+ data: requestBody,
33977
+ defaultErrorMsg: "视频号登录状态失效。"
33978
+ });
33979
+ const isSuccess = 0 === res.errCode && res.data?.finderUser !== void 0;
33980
+ const message = isSuccess ? "视频号账号有效性检测成功" : 300333 === res.errCode || 300334 === res.errCode ? "视频号登录已失效,请重新登录" : "视频号账号有效性检测失败";
33981
+ const data = isSuccess ? {
33982
+ isValidSession: true
33983
+ } : {
33984
+ isValidSession: false
33985
+ };
33986
+ return success(data, message);
33987
+ };
33988
+ const extractEncFileKey = (downloadUrl)=>{
33989
+ if (!downloadUrl) return "";
33990
+ return downloadUrl.split("encfilekey=")[1]?.split("&")[0] || "";
33991
+ };
33992
+ const rid = ()=>`${Math.floor(Date.now() / 1e3).toString(16)}-${[
33993
+ ...Array(8)
33994
+ ].map(()=>Math.floor(16 * Math.random()).toString(16)).join("")}`;
33995
+ new Uint8Array(16);
33996
+ const hexTable = [];
33997
+ for(let i = 0; i < 256; i++)hexTable.push((i + 256).toString(16).substr(1));
33998
+ const createShipinhaoComment = async (_task, params)=>{
33999
+ if (!params.content || "" === params.content.trim()) return utils_response(400, "评论内容不能为空", void 0);
34000
+ if (!params.exportId) return utils_response(400, "exportId 不能为空", void 0);
34001
+ if (!params.extraParam) return utils_response(400, "缺少 extraParam 参数", void 0);
34002
+ if (!params.extraParam.fingerPrintDeviceId || !params.extraParam.aId || !params.extraParam.uin) return utils_response(400, "fingerPrintDeviceId、aId和uin不能为空", void 0);
34003
+ const headers = {
34004
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
34005
+ referer: "https://channels.weixin.qq.com/micro/interaction/comment",
34006
+ origin: "https://channels.weixin.qq.com",
34007
+ "content-type": "application/json",
34008
+ "finger-print-device-id": params.extraParam.fingerPrintDeviceId,
34009
+ "x-wechat-uin": params.extraParam.uin
34010
+ };
34011
+ const http = new Http({
34012
+ headers
34013
+ });
34014
+ const urlParams = new URLSearchParams({
34015
+ _aid: params.extraParam.aId,
34016
+ _rid: rid(),
34017
+ _pageUrl: "https://channels.weixin.qq.com/micro/interaction/comment"
34018
+ }).toString();
34019
+ const requestData = {
34020
+ replyCommentId: params.replyCommentId || "",
34021
+ content: params.content,
34022
+ clientId: `${Date.now()}-${Math.random().toString(36).substring(2, 15)}`,
34023
+ rootCommentId: params.rootCommentId || "",
34024
+ comment: {},
34025
+ exportId: params.exportId,
34026
+ timestamp: Date.now().toString(),
34027
+ _log_finder_uin: "",
34028
+ _log_finder_id: params.extraParam.finderUserName || "",
34029
+ rawKeyBuff: null,
34030
+ pluginSessionId: null,
34031
+ scene: 7,
34032
+ reqScene: 7
34033
+ };
34034
+ if (params.rootCommentId) requestData.rootCommentId = params.rootCommentId;
34035
+ if (params.replyCommentId) requestData.replyCommentId = params.replyCommentId;
34036
+ const res = await http.api({
34037
+ method: "post",
34038
+ url: `https://channels.weixin.qq.com/micro/interaction/cgi-bin/mmfinderassistant-bin/comment/create_comment?${urlParams}`,
34039
+ data: requestData
34040
+ });
34041
+ console.log(res, "----create comment res");
34042
+ const isSuccess = res?.errCode === 0;
34043
+ return utils_response(isSuccess ? 0 : 414, res?.errMsg || "添加评论失败", res.data);
34044
+ };
34045
+ const { generateCsrfTokenAdvanced } = __webpack_require__("./src/utils/douyin/douyinSafe/csrfToken.js");
34046
+ const { getABogus } = __webpack_require__("./src/utils/douyin/douyinSafe/a_bogus.js");
34047
+ const { generateDtrait } = __webpack_require__("./src/utils/douyin/douyinSafe/dtrait.js");
34048
+ const DouyinCheckVerifyQrCodeParamsSchema = ActionCommonParamsSchema.extend({
34049
+ token: classic_schemas_string(),
34050
+ encrypt_uid: classic_schemas_string(),
34051
+ verify_scene: classic_schemas_string().optional(),
34052
+ verify_reason: classic_schemas_string().optional(),
34053
+ extraParam: classic_schemas_object({
34054
+ browserInfo: classic_schemas_object({
34055
+ screen_width: classic_schemas_string().optional(),
34056
+ screen_height: classic_schemas_string().optional(),
34057
+ browser_language: classic_schemas_string().optional(),
34058
+ browser_platform: classic_schemas_string().optional(),
34059
+ browser_name: classic_schemas_string().optional(),
34060
+ "sec-ch-ua-platform": classic_schemas_string().optional(),
34061
+ "sec-ch-ua": classic_schemas_string().optional(),
34062
+ userAgent: classic_schemas_string().optional()
34063
+ })
34064
+ }).optional()
34065
+ });
34066
+ function mergeSetCookies(oldCookies, setCookieHeader) {
34067
+ if (!setCookieHeader) return oldCookies;
34068
+ const setCookies = Array.isArray(setCookieHeader) ? setCookieHeader : [
34069
+ setCookieHeader
34070
+ ];
34071
+ const cookieMap = new Map(oldCookies.map((c)=>[
34072
+ c.name,
34073
+ c
34074
+ ]));
34075
+ for (const raw of setCookies){
34076
+ const parts = raw.split(";");
34077
+ const [nameValue] = parts;
34078
+ if (!nameValue) continue;
34079
+ const eqIdx = nameValue.indexOf("=");
34080
+ if (-1 === eqIdx) continue;
34081
+ const name = nameValue.slice(0, eqIdx).trim();
34082
+ const value = nameValue.slice(eqIdx + 1).trim();
34083
+ if (!name) continue;
34084
+ const attrs = {};
34085
+ for(let i = 1; i < parts.length; i++){
34086
+ const part = parts[i].trim();
34087
+ const attrEq = part.indexOf("=");
34088
+ if (-1 === attrEq) attrs[part.toLowerCase()] = true;
34089
+ else attrs[part.slice(0, attrEq).trim().toLowerCase()] = part.slice(attrEq + 1).trim();
34104
34090
  }
34105
- return bytes;
34091
+ const existing = cookieMap.get(name);
34092
+ cookieMap.set(name, {
34093
+ ...existing || {},
34094
+ ...attrs,
34095
+ name,
34096
+ value
34097
+ });
34106
34098
  }
34099
+ return Array.from(cookieMap.values());
34107
34100
  }
34108
- class FingerprintData {
34109
- static{
34110
- this.GPU_VENDORS = [
34111
- "Google Inc. (Intel)|ANGLE (Intel, Intel(R) HD Graphics 400 (0x00000166) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34112
- "Google Inc. (Intel)|ANGLE (Intel, Intel(R) HD Graphics 4400 (0x00001112) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34113
- "Google Inc. (Intel)|ANGLE (Intel, Intel(R) HD Graphics 4600 (0x00000412) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34114
- "Google Inc. (Intel)|ANGLE (Intel, Intel(R) HD Graphics 520 (0x1912) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34115
- "Google Inc. (Intel)|ANGLE (Intel, Intel(R) HD Graphics 530 (0x00001912) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34116
- "Google Inc. (Intel)|ANGLE (Intel, Intel(R) HD Graphics 550 (0x00001512) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34117
- "Google Inc. (Intel)|ANGLE (Intel, Intel(R) HD Graphics 6000 (0x1606) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34118
- "Google Inc. (Intel)|ANGLE (Intel, Intel(R) Iris(TM) Graphics 540 (0x1912) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34119
- "Google Inc. (Intel)|ANGLE (Intel, Intel(R) Iris(TM) Graphics 550 (0x1913) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34120
- "Google Inc. (Intel)|ANGLE (Intel, Intel(R) Iris(TM) Plus Graphics 640 (0x161C) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34121
- "Google Inc. (Intel)|ANGLE (Intel, Intel(R) UHD Graphics 600 (0x3E80) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34122
- "Google Inc. (Intel)|ANGLE (Intel, Intel(R) UHD Graphics 620 (0x00003EA0) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34123
- "Google Inc. (Intel)|ANGLE (Intel, Intel(R) UHD Graphics 630 (0x00003E9B) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34124
- "Google Inc. (Intel)|ANGLE (Intel, Intel(R) UHD Graphics 655 (0x00009BC8) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34125
- "Google Inc. (Intel)|ANGLE (Intel, Intel(R) Iris(R) Xe Graphics (0x000046A8) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34126
- "Google Inc. (Intel)|ANGLE (Intel, Intel(R) Iris(R) Xe Graphics (0x00009A49) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34127
- "Google Inc. (Intel)|ANGLE (Intel, Intel(R) Iris(R) Xe MAX Graphics (0x00009BC0) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34128
- "Google Inc. (Intel)|ANGLE (Intel, Intel Arc A370M (0x0000AF51) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34129
- "Google Inc. (Intel)|ANGLE (Intel, Intel Arc A380 (0x0000AF41) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34130
- "Google Inc. (Intel)|ANGLE (Intel, Intel Arc A380M (0x0000AF5E) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34131
- "Google Inc. (Intel)|ANGLE (Intel, Intel Arc A550 (0x0000AF42) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34132
- "Google Inc. (Intel)|ANGLE (Intel, Intel Arc A770 (0x0000AF43) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34133
- "Google Inc. (Intel)|ANGLE (Intel, Intel Arc A770M (0x0000AF50) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34134
- "Google Inc. (Intel)|ANGLE (Intel, Mesa Intel(R) Graphics (RPL‑P GT1) (0x0000A702) OpenGL 4.6)",
34135
- "Google Inc. (Intel)|ANGLE (Intel, Mesa Intel(R) UHD Graphics 770 (0x00004680) OpenGL 4.6)",
34136
- "Google Inc. (Intel)|ANGLE (Intel, Mesa Intel(R) HD Graphics 4400 (0x00001122) OpenGL 4.6)",
34137
- "Google Inc. (Intel)|ANGLE (Intel, Mesa Intel(R) Graphics (ADL‑S GT1) (0x0000A0A1) OpenGL 4.6)",
34138
- "Google Inc. (Intel)|ANGLE (Intel, Mesa Intel(R) Graphics (RKL GT1) (0x0000A9A1) OpenGL 4.6)",
34139
- "Google Inc. (Intel)|ANGLE (Intel, Mesa Intel(R) UHD Graphics (CML GT2) (0x00009A14) OpenGL 4.6)",
34140
- "Google Inc. (Intel)|ANGLE (Intel, Intel(R) HD Graphics 3000 (0x00001022) Direct3D9Ex vs_3_0 ps_3_0, igdumd64.dll)",
34141
- "Google Inc. (Intel)|ANGLE (Intel, Intel(R) HD Graphics Family (0x00000A16) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34142
- "Google Inc. (Intel)|ANGLE (Intel, Intel(R) Iris Pro OpenGL Engine, OpenGL 4.1)",
34143
- "Google Inc. (Intel)|ANGLE (Intel, Intel(R) Iris(TM) Plus Graphics 645 (0x1616) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34144
- "Google Inc. (Intel)|ANGLE (Intel, Intel(R) Iris(TM) Plus Graphics 655 (0x161E) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34145
- "Google Inc. (Intel)|ANGLE (Intel, Intel(R) UHD Graphics 730 (0x0000A100) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34146
- "Google Inc. (Intel)|ANGLE (Intel, Intel(R) UHD Graphics 805 (0x0000B0A0) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34147
- "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon Vega 3 Graphics (0x000015E0) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34148
- "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon Vega 8 Graphics (0x000015D8) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34149
- "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon Vega 11 Graphics (0x000015DD) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34150
- "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon Graphics (0x00001636) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34151
- "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon RX 5500 XT Direct3D11 vs_5_0 ps_5_0, D3D11)",
34152
- "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon RX 560 (0x000067EF) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34153
- "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon RX 570 (0x000067DF) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34154
- "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon RX 580 2048SP (0x00006FDF) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34155
- "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon RX 590 (0x000067FF) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34156
- "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon RX 6600 (0x000073FF) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34157
- "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon RX 6600 XT (0x000073FF) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34158
- "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon RX 6650 XT Direct3D11 vs_5_0 ps_5_0, D3D11)",
34159
- "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon RX 6700 XT (0x000073DF) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34160
- "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon RX 6800 (0x000073BF) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34161
- "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon RX 6900 XT (0x000073C2) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34162
- "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon RX 7700 XT Direct3D11 vs_5_0 ps_5_0, D3D11)",
34163
- "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon Pro 5300M OpenGL Engine, OpenGL 4.1)",
34164
- "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon Pro 5500 XT OpenGL Engine, OpenGL 4.1)",
34165
- "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon R7 370 Series (0x00006811) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34166
- "Google Inc. (AMD)|ANGLE (AMD, ATI Technologies Inc. AMD Radeon RX Vega 64 OpenGL Engine, OpenGL 4.1)",
34167
- "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce GTX 1050 (0x00001C81) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34168
- "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce GTX 1050 Ti (0x00001C8C) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34169
- "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce GTX 1060 6GB (0x000010DE) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34170
- "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce GTX 1070 (0x00001B81) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34171
- "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce GTX 1080 (0x00001B80) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34172
- "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce RTX 2060 (0x00001F06) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34173
- "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce RTX 2060 SUPER (0x00001F06) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34174
- "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce RTX 2070 (0x00001F10) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34175
- "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce RTX 2070 SUPER (0x00001F10) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34176
- "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce RTX 3060 (0x0000250F) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34177
- "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce RTX 3060 Ti (0x00002489) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34178
- "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce RTX 3070 (0x00002488) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34179
- "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce RTX 3070 Ti (0x000028A5) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34180
- "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce RTX 3080 (0x00002206) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34181
- "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce RTX 3080 Ti (0x00002208) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34182
- "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce RTX 3090 (0x00002204) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34183
- "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce RTX 4060 (0x00002882) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34184
- "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce RTX 4060 Ti (0x00002803) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34185
- "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce RTX 4070 (0x00002786) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34186
- "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce RTX 4070 Ti (0x00002857) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34187
- "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce RTX 4080 (0x00002819) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34188
- "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce RTX 4090 (0x00002684) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34189
- "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA Quadro RTX 5000 Ada Generation (0x000026B2) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34190
- "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA Quadro P400 (0x00001CB3) Direct3D11 vs_5_0 ps_5_0, D3D11)",
34191
- "Google Inc. (Google)|ANGLE (Google, Vulkan 1.3.0 (SwiftShader Device (Subzero) (0x0000C0DE)), SwiftShader driver)",
34192
- "Google Inc. (Google)|ANGLE (Google, Vulkan 1.3.0 (SwiftShader Device (Subzero)), SwiftShader driver)",
34193
- "Google Inc. (Google)|ANGLE (Google, Vulkan 1.3.0 (SwiftShader Device), SwiftShader driver)"
34194
- ];
34195
- }
34196
- static{
34197
- this.SCREEN_RESOLUTIONS = {
34198
- resolutions: [
34199
- "1366;768",
34200
- "1600;900",
34201
- "1920;1080",
34202
- "2560;1440",
34203
- "3840;2160",
34204
- "7680;4320"
34205
- ],
34206
- weights: [
34207
- 0.25,
34208
- 0.15,
34209
- 0.35,
34210
- 0.15,
34211
- 0.08,
34212
- 0.02
34213
- ]
34214
- };
34215
- }
34216
- static{
34217
- this.COLOR_DEPTH_OPTIONS = {
34218
- values: [
34219
- 16,
34220
- 24,
34221
- 30,
34222
- 32
34223
- ],
34224
- weights: [
34225
- 0.05,
34226
- 0.6,
34227
- 0.05,
34228
- 0.3
34229
- ]
34230
- };
34231
- }
34232
- static{
34233
- this.DEVICE_MEMORY_OPTIONS = {
34234
- values: [
34235
- 1,
34236
- 2,
34237
- 4,
34238
- 8,
34239
- 12,
34240
- 16
34241
- ],
34242
- weights: [
34243
- 0.10,
34244
- 0.25,
34245
- 0.4,
34246
- 0.2,
34247
- 0.03,
34248
- 0.01
34249
- ]
34250
- };
34251
- }
34252
- static{
34253
- this.CORE_OPTIONS = {
34254
- values: [
34255
- 2,
34256
- 4,
34257
- 6,
34258
- 8,
34259
- 12,
34260
- 16,
34261
- 24,
34262
- 32
34263
- ],
34264
- weights: [
34265
- 0.1,
34266
- 0.4,
34267
- 0.2,
34268
- 0.15,
34269
- 0.08,
34270
- 0.04,
34271
- 0.02,
34272
- 0.01
34273
- ]
34101
+ const douyinCheckVerifyQrCode = async (task, params)=>{
34102
+ const userAgent = params.userAgent || "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.38";
34103
+ const bizTraceId = params.cookies.find((e)=>"biz_trace_id" === e.name)?.value || "00000000";
34104
+ const msToken = params.cookies.find((e)=>"msToken" === e.name)?.value || "";
34105
+ const passportCsrfToken = params.cookies.find((e)=>"passport_csrf_token" === e.name)?.value || "";
34106
+ try {
34107
+ task.logger.info(`[douyinCheckVerifyQrCode] 开始轮询二维码状态, token=${params.token}`);
34108
+ const headers = {
34109
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
34110
+ origin: "https://creator.douyin.com",
34111
+ referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
34112
+ Accept: "application/json, text/plain, */*",
34113
+ "Accept-Encoding": "gzip, deflate, br, zstd",
34114
+ "sec-ch-ua-platform": params.extraParam?.browserInfo?.["sec-ch-ua-platform"] || "",
34115
+ "sec-ch-ua": params.extraParam?.browserInfo?.["sec-ch-ua"] || "",
34116
+ "sec-ch-ua-mobile": "?0",
34117
+ "user-agent": userAgent,
34118
+ "sec-fetch-site": "same-origin",
34119
+ "sec-fetch-mode": "cors",
34120
+ "sec-fetch-dest": "empty",
34121
+ "accept-language": "zh-CN,zh;q=0.9",
34122
+ priority: "u=1, i"
34274
34123
  };
34275
- }
34276
- static{
34277
- this.BROWSER_PLUGINS = "PDF Viewer,Chrome PDF Viewer,Chromium PDF Viewer,Microsoft Edge PDF Viewer,WebKit built-in PDF";
34278
- }
34279
- static{
34280
- this.CANVAS_HASH = "742cc32c";
34281
- }
34282
- static{
34283
- this.VOICE_HASH_OPTIONS = "10311144241322244122";
34284
- }
34285
- static{
34286
- this.FONTS = 'system-ui, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif, BlinkMacSystemFont, "Helvetica Neue", Arial, "PingFang SC", "PingFang TC", "PingFang HK", "Microsoft Yahei", "Microsoft JhengHei"';
34287
- }
34288
- }
34289
- class FingerprintHelpers {
34290
- static weightedRandomChoice(options, weights) {
34291
- const totalWeight = weights.reduce((sum, weight)=>sum + weight, 0);
34292
- let random = Math.random() * totalWeight;
34293
- for(let i = 0; i < options.length; i++){
34294
- random -= weights[i];
34295
- if (random <= 0) return options[i];
34296
- }
34297
- return options[options.length - 1];
34298
- }
34299
- static getRendererInfo() {
34300
- const rendererStr = FingerprintData.GPU_VENDORS[Math.floor(Math.random() * FingerprintData.GPU_VENDORS.length)];
34301
- const [vendor, renderer] = rendererStr.split('|');
34302
- return {
34303
- vendor,
34304
- renderer
34124
+ const checkBody = {
34125
+ encrypt_uid: params.encrypt_uid || "",
34126
+ verify_ticket: "",
34127
+ copywriting_key: "creator",
34128
+ new_verify_flow: "",
34129
+ aid: "2906",
34130
+ token: params.token,
34131
+ verify_type: "",
34132
+ need_record: "1",
34133
+ scene: "secondary_verify",
34134
+ verify_scene: params.verify_scene || "creator",
34135
+ verify_reason: params.verify_reason || "gateway_web_authlv_check",
34136
+ std_verify_way: "qr_code_verify",
34137
+ new_authn_sdk_version: "1.0.0.404-web"
34305
34138
  };
34306
- }
34307
- static getScreenConfig() {
34308
- const resolutionStr = this.weightedRandomChoice(FingerprintData.SCREEN_RESOLUTIONS.resolutions, FingerprintData.SCREEN_RESOLUTIONS.weights);
34309
- const [widthStr, heightStr] = resolutionStr.split(';');
34310
- const width = parseInt(widthStr);
34311
- const height = parseInt(heightStr);
34312
- let availWidth, availHeight;
34313
- if (Math.random() > 0.5) {
34314
- availWidth = width - parseInt(String(this.weightedRandomChoice([
34315
- 0,
34316
- 30,
34317
- 60,
34318
- 80
34319
- ], [
34320
- 0.1,
34321
- 0.4,
34322
- 0.3,
34323
- 0.2
34324
- ])));
34325
- availHeight = height;
34326
- } else {
34327
- availWidth = width;
34328
- availHeight = height - parseInt(String(this.weightedRandomChoice([
34329
- 30,
34330
- 60,
34331
- 80,
34332
- 100
34333
- ], [
34334
- 0.2,
34335
- 0.5,
34336
- 0.2,
34337
- 0.1
34338
- ])));
34339
- }
34340
- return {
34341
- width,
34342
- height,
34343
- availWidth,
34344
- availHeight
34139
+ const checkBodyStr = new URLSearchParams(checkBody).toString();
34140
+ const checkQueryParams = {
34141
+ passport_jssdk_version: "5.1.2",
34142
+ passport_jssdk_type: "lite",
34143
+ is_from_ttaccountsdk: "1",
34144
+ aid: "2906",
34145
+ language: "zh",
34146
+ account_app_language: "zh-CN",
34147
+ new_authn_sdk_version: "1.0.0.404-web",
34148
+ is_vcd: "1",
34149
+ biz_trace_id: bizTraceId,
34150
+ msToken,
34151
+ a_bogus: ""
34345
34152
  };
34153
+ const checkQueryStr = new URLSearchParams(checkQueryParams).toString();
34154
+ const checkUrl = `https://creator.douyin.com/passport/mobile/validate_by_qrcode/?${checkQueryStr}`;
34155
+ const aBogus = getABogus(checkUrl, checkBodyStr, userAgent);
34156
+ checkQueryParams.a_bogus = aBogus;
34157
+ const finalQueryStr = new URLSearchParams(checkQueryParams).toString();
34158
+ const csrfToken = generateCsrfTokenAdvanced({
34159
+ cookies: params.cookies,
34160
+ url: "https://creator.douyin.com/passport/mobile/validate_by_qrcode/",
34161
+ method: "POST",
34162
+ userAgent
34163
+ });
34164
+ const sessionDtrait = generateDtrait("/passport/mobile/validate_by_qrcode/");
34165
+ let rawSetCookie;
34166
+ const checkHttp = new Http({
34167
+ headers: {
34168
+ ...headers,
34169
+ "Content-Type": "application/x-www-form-urlencoded",
34170
+ "x-secsdk-csrf-token": csrfToken,
34171
+ "x-tt-passport-csrf-token": passportCsrfToken,
34172
+ "x-tt-passport-trace-id": bizTraceId,
34173
+ "x-tt-passport-verify-portrait": "",
34174
+ "x-tt-session-dtrait": sessionDtrait || ""
34175
+ }
34176
+ });
34177
+ checkHttp.addResponseInterceptor((res)=>{
34178
+ task.logger.info(`[douyinCheckVerifyQrCode] 原始响应 status=${res.status} data=${JSON.stringify(res.data)}`);
34179
+ console.log("[douyinCheckVerifyQrCode] 原始响应:", JSON.stringify(res.data));
34180
+ rawSetCookie = res.headers["set-cookie"];
34181
+ });
34182
+ const checkResponse = await checkHttp.api({
34183
+ method: "post",
34184
+ url: `https://creator.douyin.com/passport/mobile/validate_by_qrcode/?${finalQueryStr}`,
34185
+ data: checkBodyStr
34186
+ }, {
34187
+ timeout: 10000
34188
+ });
34189
+ const data = checkResponse?.data;
34190
+ const status = data?.status;
34191
+ task.logger.info(`[douyinCheckVerifyQrCode] status=${status}`);
34192
+ const updatedCookies = mergeSetCookies(params.cookies, rawSetCookie);
34193
+ if ("new" === status) return utils_response(0, "二维码等待扫描", data);
34194
+ if ("scanned" === status) return utils_response(0, "二维码已扫码,待确认扫描", data);
34195
+ if ("confirmed" === status) return utils_response(0, "扫码验证成功", {
34196
+ status: "confirmed",
34197
+ redirect_url: data.redirect_url || "",
34198
+ ticket: data.ticket || "",
34199
+ cookies: updatedCookies
34200
+ });
34201
+ if ("expired" === status) return utils_response(0, "二维码已过期", {
34202
+ status: "expired",
34203
+ token: data.token || "",
34204
+ qrcode: data.qrcode || "",
34205
+ qrcode_index_url: data.qrcode_index_url || "",
34206
+ expire_time: data.expire_time || 0,
34207
+ app_name: data.app_name || "",
34208
+ web_name: data.web_name || ""
34209
+ });
34210
+ return utils_response(414, `未知二维码状态: ${status}`, "");
34211
+ } catch (err) {
34212
+ const msg = err instanceof Error ? err.message : String(err);
34213
+ task.logger.warn(`[douyinCheckVerifyQrCode] 请求失败: ${msg}`);
34214
+ return utils_response(500, `校验二维码失败: ${msg}`, "");
34346
34215
  }
34347
- static generateCanvasHash() {
34348
- return FingerprintData.CANVAS_HASH;
34349
- }
34350
- static generateWebglHash() {
34351
- return external_node_crypto_namespaceObject.createHash('md5').update(external_node_crypto_namespaceObject.randomBytes(32)).digest('hex');
34352
- }
34353
- }
34354
- class ARC4 {
34355
- constructor(key){
34356
- this.s = [];
34357
- for(let i = 0; i < 256; i++)this.s[i] = i;
34358
- let j = 0;
34359
- for(let i = 0; i < 256; i++){
34360
- j = (j + this.s[i] + key[i % key.length]) % 256;
34361
- [this.s[i], this.s[j]] = [
34362
- this.s[j],
34363
- this.s[i]
34364
- ];
34365
- }
34366
- }
34367
- encrypt(data) {
34368
- const result = new Uint8Array(data.length);
34369
- let i = 0, j = 0;
34370
- for(let k = 0; k < data.length; k++){
34371
- i = (i + 1) % 256;
34372
- j = (j + this.s[i]) % 256;
34373
- [this.s[i], this.s[j]] = [
34374
- this.s[j],
34375
- this.s[i]
34376
- ];
34377
- const keyByte = this.s[(this.s[i] + this.s[j]) % 256];
34378
- result[k] = data[k] ^ keyByte;
34379
- }
34380
- return result;
34381
- }
34382
- }
34383
- class FingerprintGenerator {
34384
- constructor(){
34385
- this.config = CryptoConfig;
34386
- this.b1Key = new TextEncoder().encode("xhswebmplfbt");
34387
- this.encoder = new Base64Encoder();
34388
- }
34389
- generate(cookies, userAgent) {
34390
- const cookieString = Object.entries(cookies).map(([k, v])=>`${k}=${v}`).join('; ');
34391
- const screenConfig = FingerprintHelpers.getScreenConfig();
34392
- const isIncognitoMode = FingerprintHelpers.weightedRandomChoice([
34393
- "true",
34394
- "false"
34395
- ], [
34396
- 0.95,
34397
- 0.05
34398
- ]);
34399
- const { vendor, renderer } = FingerprintHelpers.getRendererInfo();
34400
- const x78Y = Math.floor(101 * Math.random()) + 2350;
34401
- const fp = {
34402
- x1: userAgent,
34403
- x2: "false",
34404
- x3: "zh-CN",
34405
- x4: String(FingerprintHelpers.weightedRandomChoice(FingerprintData.COLOR_DEPTH_OPTIONS.values, FingerprintData.COLOR_DEPTH_OPTIONS.weights)),
34406
- x5: String(FingerprintHelpers.weightedRandomChoice(FingerprintData.DEVICE_MEMORY_OPTIONS.values, FingerprintData.DEVICE_MEMORY_OPTIONS.weights)),
34407
- x6: "24",
34408
- x7: `${vendor},${renderer}`,
34409
- x8: String(FingerprintHelpers.weightedRandomChoice(FingerprintData.CORE_OPTIONS.values, FingerprintData.CORE_OPTIONS.weights)),
34410
- x9: `${screenConfig.width};${screenConfig.height}`,
34411
- x10: `${screenConfig.availWidth};${screenConfig.availHeight}`,
34412
- x11: "-480",
34413
- x12: "Asia/Shanghai",
34414
- x13: isIncognitoMode,
34415
- x14: isIncognitoMode,
34416
- x15: isIncognitoMode,
34417
- x16: "false",
34418
- x17: "false",
34419
- x18: "un",
34420
- x19: "Win32",
34421
- x20: "",
34422
- x21: FingerprintData.BROWSER_PLUGINS,
34423
- x22: FingerprintHelpers.generateWebglHash(),
34424
- x23: "false",
34425
- x24: "false",
34426
- x25: "false",
34427
- x26: "false",
34428
- x27: "false",
34429
- x28: "0,false,false",
34430
- x29: "4,7,8",
34431
- x30: "swf object not loaded",
34432
- x33: "0",
34433
- x34: "0",
34434
- x35: "0",
34435
- x36: String(Math.floor(20 * Math.random()) + 1),
34436
- x37: "0|0|0|0|0|0|0|0|0|1|0|0|0|0|0|0|0|0|1|0|0|0|0|0",
34437
- x38: "0|0|1|0|1|0|0|0|0|0|1|0|1|0|1|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0",
34438
- x39: 0,
34439
- x40: "0",
34440
- x41: "0",
34441
- x42: "3.4.4",
34442
- x43: FingerprintHelpers.generateCanvasHash(),
34443
- x44: String(Math.floor(Date.now())),
34444
- x45: "__SEC_CAV__1-1-1-1-1|__SEC_WSA__|",
34445
- x46: "false",
34446
- x47: "1|0|0|0|0|0",
34447
- x48: "",
34448
- x49: "{list:[],type:}",
34449
- x50: "",
34450
- x51: "",
34451
- x52: "",
34452
- x53: external_node_crypto_namespaceObject.createHash('md5').update(external_node_crypto_namespaceObject.randomBytes(32)).digest('hex'),
34453
- x54: FingerprintData.VOICE_HASH_OPTIONS,
34454
- x55: "380,380,360,400,380,400,420,380,400,400,360,360,440,420",
34455
- x56: `${vendor}|${renderer}|${FingerprintHelpers.generateWebglHash()}|35`,
34456
- x57: cookieString,
34457
- x58: "180",
34458
- x59: "2",
34459
- x60: "63",
34460
- x61: "1291",
34461
- x62: "2047",
34462
- x63: "0",
34463
- x64: "0",
34464
- x65: "0",
34465
- x66: {
34466
- referer: "",
34467
- location: "https://www.xiaohongshu.com/explore",
34468
- frame: 0
34469
- },
34470
- x67: "1|0",
34471
- x68: "0",
34472
- x69: "326|1292|30",
34473
- x70: [
34474
- "location"
34475
- ],
34476
- x71: "true",
34477
- x72: "complete",
34478
- x73: "1191",
34479
- x74: "0|0|0",
34480
- x75: "Google Inc.",
34481
- x76: "true",
34482
- x77: "1|1|1|1|1|1|1|1|1|1",
34483
- x78: {
34484
- x: 0,
34485
- y: x78Y,
34486
- left: 0,
34487
- right: 290.828125,
34488
- bottom: x78Y + 18,
34489
- height: 18,
34490
- top: x78Y,
34491
- width: 290.828125,
34492
- font: FingerprintData.FONTS
34493
- },
34494
- x79: "144|599565058866",
34495
- x80: "1|[object FileSystemDirectoryHandle]",
34496
- x31: "124.04347527516074",
34497
- x82: "_0x17a2|_0x1954"
34498
- };
34499
- return fp;
34500
- }
34501
- generateB1(fp) {
34502
- const b1Fp = {
34503
- x33: fp.x33,
34504
- x34: fp.x34,
34505
- x35: fp.x35,
34506
- x36: fp.x36,
34507
- x37: fp.x37,
34508
- x38: fp.x38,
34509
- x39: fp.x39,
34510
- x42: fp.x42,
34511
- x43: fp.x43,
34512
- x44: fp.x44,
34513
- x45: fp.x45,
34514
- x46: fp.x46,
34515
- x48: fp.x48,
34516
- x49: fp.x49,
34517
- x50: fp.x50,
34518
- x51: fp.x51,
34519
- x52: fp.x52,
34520
- x82: fp.x82
34521
- };
34522
- const b1Json = JSON.stringify(b1Fp, null, 0).replace(/\s+/g, '');
34523
- const cipher = new ARC4(this.b1Key);
34524
- const ciphertext = cipher.encrypt(new TextEncoder().encode(b1Json));
34525
- let latin1String = '';
34526
- for(let i = 0; i < ciphertext.length; i++)latin1String += String.fromCharCode(ciphertext[i]);
34527
- const encodedUrl = encodeURIComponent(latin1String).replace(/[!'()*~_-]/g, (c)=>c);
34528
- const b = [];
34529
- const parts = encodedUrl.split('%').slice(1);
34530
- for (const part of parts){
34531
- const chars = part.split('');
34532
- if (chars.length >= 2) {
34533
- b.push(parseInt(chars.slice(0, 2).join(''), 16));
34534
- for(let i = 2; i < chars.length; i++)b.push(chars[i].charCodeAt(0));
34535
- }
34536
- }
34537
- const b1 = this.encoder.encode(JSON.stringify(b));
34538
- return b1;
34539
- }
34540
- update(fp, cookies, url) {
34541
- const cookieString = Object.entries(cookies).map(([k, v])=>`${k}=${v}`).join('; ');
34542
- fp.x39 = 0;
34543
- fp.x44 = String(Math.floor(Date.now()));
34544
- fp.x57 = cookieString;
34545
- fp.x66 = {
34546
- referer: "https://www.xiaohongshu.com/explore",
34547
- location: url,
34548
- frame: 0
34549
- };
34550
- }
34551
- }
34552
- class XsCommonSigner {
34553
- constructor(){
34554
- this.config = CryptoConfig;
34555
- this.fpGenerator = new FingerprintGenerator();
34556
- this.encoder = new Base64Encoder();
34557
- }
34558
- sign(cookieDict) {
34559
- if (!cookieDict.a1) throw new Error("Missing 'a1' in cookies");
34560
- const a1Value = cookieDict.a1;
34561
- const fingerprint = this.fpGenerator.generate(cookieDict, this.config.PUBLIC_USERAGENT);
34562
- const b1 = this.fpGenerator.generateB1(fingerprint);
34563
- const x9 = CRC32.crc32JsInt(b1, true);
34564
- const signStruct = {
34565
- s0: 5,
34566
- s1: "",
34567
- x0: "1",
34568
- x1: "4.2.6",
34569
- x2: "Windows",
34570
- x3: "xhs-pc-web",
34571
- x4: "4.86.0",
34572
- x5: a1Value,
34573
- x6: "",
34574
- x7: "",
34575
- x8: b1,
34576
- x9: x9,
34577
- x10: 0,
34578
- x11: "normal"
34579
- };
34580
- const signJson = JSON.stringify(signStruct);
34581
- return this.encoder.encode(signJson);
34582
- }
34583
- }
34584
- class Xhshow {
34585
- buildContentString(method, uri, payload = null) {
34586
- payload = payload || {};
34587
- if ('POST' === method.toUpperCase()) return uri + JSON.stringify(payload);
34588
- if (0 === Object.keys(payload).length) return uri;
34589
- {
34590
- const params = Object.entries(payload).map(([key, value])=>{
34591
- let valueStr;
34592
- valueStr = Array.isArray(value) ? value.map((v)=>String(v)).join(',') : null !== value ? String(value) : '';
34593
- valueStr = valueStr.replace(/=/g, '%3D');
34594
- return `${key}=${valueStr}`;
34595
- });
34596
- return `${uri}?${params.join('&')}`;
34597
- }
34598
- }
34599
- generateDValue(content) {
34600
- return external_node_crypto_namespaceObject.createHash('md5').update(content, 'utf-8').digest('hex');
34601
- }
34602
- buildSignature(dValue, a1Value, xsecAppid = "xhs-pc-web", stringParam = "", timestamp) {
34603
- const payloadArray = this.cryptoProcessor.buildPayloadArray(dValue, a1Value, xsecAppid, stringParam, timestamp);
34604
- const xorResult = this.cryptoProcessor.bitOps.xorTransformArray(payloadArray);
34605
- return this.cryptoProcessor.b64encoder.encodeX3(xorResult.slice(0, 124));
34606
- }
34607
- signXs(method, uri, a1Value, xsecAppid = "xhs-pc-web", payload = null, timestamp) {
34608
- const validatedMethod = RequestSignatureValidator.validateMethod(method);
34609
- const validatedUri = RequestSignatureValidator.validateUri(uri);
34610
- const validatedA1Value = RequestSignatureValidator.validateA1Value(a1Value);
34611
- const validatedXsecAppid = RequestSignatureValidator.validateXsecAppid(xsecAppid);
34612
- const validatedPayload = RequestSignatureValidator.validatePayload(payload);
34613
- const signatureData = JSON.parse(JSON.stringify(this.cryptoProcessor.config.SIGNATURE_DATA_TEMPLATE));
34614
- const content = this.buildContentString(validatedMethod, validatedUri, validatedPayload);
34615
- const dValue = this.generateDValue(content);
34616
- signatureData.x3 = this.cryptoProcessor.config.X3_PREFIX + this.buildSignature(dValue, validatedA1Value, validatedXsecAppid, content, timestamp);
34617
- const signatureJson = JSON.stringify(signatureData);
34618
- return this.cryptoProcessor.config.XYS_PREFIX + this.cryptoProcessor.b64encoder.encode(signatureJson);
34619
- }
34620
- signXsGet(uri, a1Value, xsecAppid = "xhs-pc-web", params = null, timestamp) {
34621
- return this.signXs('GET', uri, a1Value, xsecAppid, params, timestamp);
34622
- }
34623
- signXsPost(uri, a1Value, xsecAppid = "xhs-pc-web", payload = null, timestamp) {
34624
- return this.signXs('POST', uri, a1Value, xsecAppid, payload, timestamp);
34625
- }
34626
- signXsCommon(cookieDict) {
34627
- const cookies = this.parseCookies(cookieDict);
34628
- return this.xsCommonSigner.sign(cookies);
34629
- }
34630
- signXsc(cookieDict) {
34631
- return this.signXsCommon(cookieDict);
34632
- }
34633
- parseCookies(cookies) {
34634
- if ('string' == typeof cookies) {
34635
- const cookieObj = {};
34636
- cookies.split(';').forEach((item)=>{
34637
- const [key, value] = item.trim().split('=');
34638
- if (key && value) cookieObj[key] = value;
34639
- });
34640
- return cookieObj;
34641
- }
34642
- return cookies;
34643
- }
34644
- signHeaders(method, uri, cookies, xsecAppid = "xhs-pc-web", params, payload, timestamp) {
34645
- if (void 0 === timestamp) timestamp = Date.now() / 1000;
34646
- const methodUpper = method.toUpperCase();
34647
- let requestData = null;
34648
- if ('GET' === methodUpper) {
34649
- if (null != payload) throw new Error("GET requests must use 'params', not 'payload'");
34650
- requestData = params || null;
34651
- } else if ('POST' === methodUpper) {
34652
- if (null != params) throw new Error("POST requests must use 'payload', not 'params'");
34653
- requestData = payload || null;
34654
- } else throw new Error(`Unsupported method: ${method}`);
34655
- const cookieDict = this.parseCookies(cookies);
34656
- const a1Value = cookieDict.a1;
34657
- if (!a1Value) throw new Error("Missing 'a1' in cookies");
34658
- const xS = this.signXs(methodUpper, uri, a1Value, xsecAppid, requestData, timestamp);
34659
- const xSCommon = this.signXsCommon(cookieDict);
34660
- const xT = this.getXT(timestamp);
34661
- const xB3Traceid = this.getB3TraceId();
34662
- const xXrayTraceid = this.getXrayTraceId(Math.floor(1000 * timestamp));
34663
- return {
34664
- 'x-s': xS,
34665
- 'x-s-common': xSCommon,
34666
- 'x-t': xT.toString(),
34667
- 'x-b3-traceid': xB3Traceid,
34668
- 'x-xray-traceid': xXrayTraceid
34669
- };
34670
- }
34671
- signHeadersGet(uri, cookies, xsecAppid = "xhs-pc-web", params, timestamp) {
34672
- return this.signHeaders('GET', uri, cookies, xsecAppid, params, void 0, timestamp);
34673
- }
34674
- signHeadersPost(uri, cookies, xsecAppid = "xhs-pc-web", payload, timestamp) {
34675
- return this.signHeaders('POST', uri, cookies, xsecAppid, void 0, payload, timestamp);
34676
- }
34677
- decodeX3(x3Signature) {
34678
- if (x3Signature.startsWith(this.cryptoProcessor.config.X3_PREFIX)) x3Signature = x3Signature.substring(this.cryptoProcessor.config.X3_PREFIX.length);
34679
- const decodedBytes = this.cryptoProcessor.b64encoder.decodeX3(x3Signature);
34680
- return this.cryptoProcessor.bitOps.xorTransformArray(Array.from(decodedBytes));
34681
- }
34682
- decodeXs(xsSignature) {
34683
- if (xsSignature.startsWith(this.cryptoProcessor.config.XYS_PREFIX)) xsSignature = xsSignature.substring(this.cryptoProcessor.config.XYS_PREFIX.length);
34684
- const jsonString = this.cryptoProcessor.b64encoder.decode(xsSignature);
34685
- try {
34686
- return JSON.parse(jsonString);
34687
- } catch (e) {
34688
- throw new Error(`Invalid signature: JSON decode failed - ${e}`);
34689
- }
34690
- }
34691
- getB3TraceId() {
34692
- return this.cryptoProcessor.randomGen.generateB3TraceId();
34693
- }
34694
- getXrayTraceId(timestamp, seq) {
34695
- return this.cryptoProcessor.randomGen.generateXrayTraceId(timestamp, seq);
34696
- }
34697
- getXT(timestamp) {
34698
- if (void 0 === timestamp) timestamp = Date.now() / 1000;
34699
- return Math.floor(1000 * timestamp);
34700
- }
34701
- buildUrl(baseUrl, params) {
34702
- if (!params || 0 === Object.keys(params).length) return baseUrl;
34703
- const queryString = Object.entries(params).map(([key, value])=>{
34704
- const valueStr = Array.isArray(value) ? value.join(',') : String(value);
34705
- return `${key}=${encodeURIComponent(valueStr)}`;
34706
- }).join('&');
34707
- return `${baseUrl}?${queryString}`;
34708
- }
34709
- buildJsonBody(payload) {
34710
- return JSON.stringify(payload);
34711
- }
34712
- constructor(){
34713
- this.cryptoProcessor = new CryptoProcessor();
34714
- this.xsCommonSigner = new XsCommonSigner();
34715
- }
34716
- }
34717
- new Xhshow();
34718
- const sessionCheck_xsEncrypt = new Xhshow();
34719
- let lastEnvLogTime = 0;
34720
- const ENV_LOG_INTERVAL_MS = 5000;
34721
- const SessionCheckResultSchema = classic_schemas_object({
34722
- isValidSession: classic_schemas_boolean()
34723
- });
34724
- const WxBjhSessionParamsSchema = ActionCommonParamsSchema.extend({
34725
- token: schemas_union([
34726
- classic_schemas_string(),
34727
- classic_schemas_number()
34728
- ])
34729
- });
34730
- const TTSessionCheck = async (_task, params)=>{
34731
- const http = new Http({
34732
- headers: {
34733
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
34734
- referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
34735
- }
34736
- });
34737
- const res = await http.api({
34738
- method: "get",
34739
- url: "https://mp.toutiao.com/mp/agw/creator_center/user_info",
34740
- defaultErrorMsg: "头条号登录状态失效。"
34741
- });
34742
- const isSuccess = 0 === res.code;
34743
- const message = "头条账号有效性检测成功";
34744
- const data = isSuccess ? {
34745
- isValidSession: true
34746
- } : {
34747
- isValidSession: false
34748
- };
34749
- return success(data, message);
34750
- };
34751
- const WxSessionCheck = async (_task, params)=>{
34752
- const http = new Http({
34753
- headers: {
34754
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";")
34755
- }
34756
- });
34757
- const fingerprint = "4695500bc93ab4ce8fb2692da6564e04";
34758
- const res = await http.api({
34759
- method: "get",
34760
- url: "https://mp.weixin.qq.com/cgi-bin/appmsgpublish",
34761
- params: {
34762
- fingerprint,
34763
- sub: "list",
34764
- begin: 0,
34765
- count: 10,
34766
- query: "",
34767
- type: 1011102103,
34768
- show_type: "",
34769
- free_publish_type: 1102103,
34770
- sub_action: "list_ex",
34771
- search_card: 0,
34772
- token: params.token,
34773
- lang: "zh_CN",
34774
- f: "json",
34775
- ajax: 1
34776
- }
34777
- });
34778
- return success(0 === res.base_resp.ret ? {
34779
- isValidSession: true
34780
- } : {
34781
- isValidSession: false
34782
- }, "微信账号有效性检测完成!");
34783
34216
  };
34784
- const XhsSessionCheck = async (_task, params)=>{
34785
- const now = Date.now();
34786
- const shouldLogEnv = now - lastEnvLogTime >= ENV_LOG_INTERVAL_MS;
34787
- if (shouldLogEnv) {
34788
- lastEnvLogTime = now;
34789
- _task.logger?.debug("[XhsSessionCheck] 环境信息", {
34790
- processType: process.type,
34791
- pid: process.pid,
34792
- nodeVersion: process.version,
34793
- platform: process.platform,
34794
- memoryUsage: {
34795
- heapUsed: `${Math.round(process.memoryUsage().heapUsed / 1024 / 1024)} MB`,
34796
- heapTotal: `${Math.round(process.memoryUsage().heapTotal / 1024 / 1024)} MB`
34797
- },
34798
- accountId: params.accountId,
34799
- hasProxy: !!params.proxyLoc
34800
- });
34801
- }
34802
- const check = {
34803
- isValidSession: false,
34804
- isValidWebSession: false
34805
- };
34806
- const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
34807
- if (!a1Cookie) return {
34808
- code: 414,
34809
- message: "账号数据异常,请重新绑定账号后重试。",
34810
- data: check
34811
- };
34217
+ const DouyinCreateCommentReplyParamsSchema = ActionCommonParamsSchema.extend({
34218
+ itemId: classic_schemas_string(),
34219
+ commentId: classic_schemas_string(),
34220
+ text: classic_schemas_string()
34221
+ });
34222
+ const { getABogus: douyinCreateCommentReply_getABogus } = __webpack_require__("./src/utils/douyin/douyinSafe/a_bogus.js");
34223
+ const { generateCsrfTokenAdvanced: douyinCreateCommentReply_generateCsrfTokenAdvanced } = __webpack_require__("./src/utils/douyin/douyinSafe/csrfToken.js");
34224
+ const douyinCreateCommentReply = async (_task, params)=>{
34225
+ const userAgent = params.userAgent || "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.38";
34812
34226
  const headers = {
34813
34227
  cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
34814
- referer: "https://creator.xiaohongshu.com/new/home?source=official"
34228
+ origin: "https://creator.douyin.com",
34229
+ referer: "https://creator.douyin.com/",
34230
+ Accept: "application/json, text/plain, */*",
34231
+ "Accept-Encoding": "gzip, deflate, br, zstd",
34232
+ "Content-Type": "application/json",
34233
+ pragma: "no-cache",
34234
+ "cache-control": "no-cache",
34235
+ "sec-ch-ua-platform": params.extraParam?.browserInfo?.["sec-ch-ua-platform"] || "",
34236
+ "sec-ch-ua": params.extraParam?.browserInfo?.["sec-ch-ua"] || "",
34237
+ "sec-ch-ua-mobile": "?0",
34238
+ "user-agent": userAgent,
34239
+ "sec-fetch-site": "same-origin",
34240
+ "sec-fetch-mode": "cors",
34241
+ "sec-fetch-dest": "empty",
34242
+ "accept-language": "zh-CN,zh;q=0.9",
34243
+ priority: "u=1, i"
34815
34244
  };
34816
34245
  const args = [
34817
34246
  {
@@ -34819,450 +34248,14 @@ var __webpack_exports__ = {};
34819
34248
  },
34820
34249
  _task.logger,
34821
34250
  params.proxyLoc,
34822
- params.accountId,
34823
- "xiaohongshu"
34251
+ params.accountId
34824
34252
  ];
34825
34253
  const http = new Http(...args);
34826
- http.addResponseInterceptor((response)=>{
34827
- if (response?.status === 401) return {
34828
- code: response.data.code,
34829
- message: response.data.msg,
34830
- data: response.data.data
34831
- };
34832
- });
34833
- const loginBasePath = "/api/galaxy/creator/home/personal_info";
34834
- const recordCookie = params.cookies.reduce((acc, cookie)=>{
34835
- if (cookie.name && cookie.value) acc[cookie.name] = cookie.value;
34836
- return acc;
34837
- }, {});
34838
- const baseInfoStart = Date.now();
34839
- const _baseInfo = http.api({
34840
- method: "get",
34841
- baseURL: "https://creator.xiaohongshu.com",
34842
- url: loginBasePath
34843
- }, {
34844
- retries: 3,
34845
- retryDelay: 300,
34846
- timeout: 30000
34847
- }).catch((e)=>{
34848
- const clientTimestamp = Date.now();
34849
- const serverDate = e?.extra?.serverDate;
34850
- const serverTimestamp = serverDate ? new Date(serverDate).getTime() : null;
34851
- const timeDriftMs = serverTimestamp ? clientTimestamp - serverTimestamp : null;
34852
- _task.logger?.warn("[XhsSessionCheck] creator personal_info 接口请求失败", {
34853
- accountId: params.accountId,
34854
- duration: Date.now() - baseInfoStart,
34855
- code: e?.code,
34856
- message: e?.message,
34857
- data: e?.data,
34858
- extra: e?.extra,
34859
- proxyInfo: http.proxyInfo,
34860
- clientTimestamp,
34861
- serverDate,
34862
- serverTimestamp,
34863
- timeDriftMs,
34864
- isLikelyClockDrift: null !== timeDriftMs && Math.abs(timeDriftMs) > 300000
34865
- });
34866
- return e.data;
34867
- });
34868
- const webSessionPath = "/api/sns/web/unread_count";
34869
- const webSessionData = {};
34870
- let webSessionXsHeader;
34871
- try {
34872
- webSessionXsHeader = sessionCheck_xsEncrypt.signHeadersPost(webSessionPath, recordCookie, "xhs-pc-web", webSessionData);
34873
- } catch (signError) {
34874
- _task.logger?.error("[XhsSessionCheck] 签名生成失败 - 环境快照", {
34875
- accountId: params.accountId,
34876
- error: signError instanceof Error ? signError.message : String(signError),
34877
- stack: _task.debug ? signError instanceof Error ? signError.stack : void 0 : void 0,
34878
- hasA1: !!recordCookie.a1,
34879
- env: {
34880
- processType: process.type,
34881
- memoryUsage: {
34882
- heapUsed: `${Math.round(process.memoryUsage().heapUsed / 1024 / 1024)} MB`,
34883
- heapTotal: `${Math.round(process.memoryUsage().heapTotal / 1024 / 1024)} MB`
34884
- },
34885
- hasProxy: !!params.proxyLoc,
34886
- timeSinceLastLog: Date.now() - lastEnvLogTime
34887
- }
34888
- });
34889
- return {
34890
- code: 500,
34891
- message: "账号签名生成失败,请稍后重试。",
34892
- data: check
34893
- };
34894
- }
34895
- const _web_session = http.api({
34896
- method: "GET",
34897
- url: "https://edith.xiaohongshu.com/api/sns/web/unread_count",
34898
- data: webSessionData,
34899
- headers: webSessionXsHeader
34900
- }, {
34901
- retries: 3,
34902
- retryDelay: 300,
34903
- timeout: 30000
34904
- });
34905
- const [baseInfo, web_session] = await Promise.all([
34906
- _baseInfo,
34907
- _web_session
34908
- ]);
34909
- if (baseInfo?.code === 0) check.isValidSession = true;
34910
- if (web_session?.code === 0) check.isValidWebSession = true;
34911
- baseInfo?.code, web_session?.code;
34912
- const message = `小红书账号有效性检测成功${_task.debug ? ` ${http.proxyInfo}` : ""}`;
34913
- return success(check, message);
34914
- };
34915
- const BjhSessionCheck = async (_task, params)=>{
34916
- const http = new Http({
34917
- headers: {
34918
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
34919
- token: params.token,
34920
- referer: "https://baijiahao.baidu.com/builder/rc/home"
34921
- }
34922
- });
34923
- const res = await http.api({
34924
- method: "get",
34925
- url: "https://baijiahao.baidu.com/user-ui/cms/settingInfo",
34926
- defaultErrorMsg: "百家号登录状态失效。"
34927
- });
34928
- const isSuccess = 0 === res.errno;
34929
- const message = "百家号账号有效性检测成功";
34930
- const data = isSuccess ? {
34931
- isValidSession: true
34932
- } : {
34933
- isValidSession: false
34934
- };
34935
- return success(data, message);
34936
- };
34937
- const DySessionCheck = async (_task, params)=>{
34938
- const http = new Http({
34939
- headers: {
34940
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
34941
- referer: "https://creator.douyin.com/"
34942
- }
34943
- });
34944
- const res = await http.api({
34945
- method: "get",
34946
- url: "https://creator.douyin.com/aweme/v1/creator/user/info/",
34947
- params: {
34948
- _ts: Date.now()
34949
- },
34950
- defaultErrorMsg: "抖音登录状态失效。"
34951
- });
34952
- const isSuccess = 0 === res.status_code;
34953
- const message = "抖音账号有效性检测成功";
34954
- const data = isSuccess ? {
34955
- isValidSession: true
34956
- } : {
34957
- isValidSession: false
34958
- };
34959
- return success(data, message);
34960
- };
34961
- const ShipinhaoSessionCheck = async (_task, params)=>{
34962
- const http = new Http({
34963
- headers: {
34964
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
34965
- referer: "https://channels.weixin.qq.com",
34966
- "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
34967
- "Content-Type": "application/json"
34968
- }
34969
- });
34970
- const getTimeStamp = (length)=>Date.now().toString().substring(0, length);
34971
- const requestBody = {
34972
- timestamp: getTimeStamp(13),
34973
- _log_finder_uin: "",
34974
- _log_finder_id: "",
34975
- rawKeyBuff: null,
34976
- pluginSessionId: null,
34977
- scene: 7,
34978
- reqScene: 7
34979
- };
34980
- const res = await http.api({
34981
- method: "post",
34982
- url: "https://channels.weixin.qq.com/cgi-bin/mmfinderassistant-bin/auth/auth_data",
34983
- data: requestBody,
34984
- defaultErrorMsg: "视频号登录状态失效。"
34985
- });
34986
- const isSuccess = 0 === res.errCode && res.data?.finderUser !== void 0;
34987
- const message = isSuccess ? "视频号账号有效性检测成功" : 300333 === res.errCode || 300334 === res.errCode ? "视频号登录已失效,请重新登录" : "视频号账号有效性检测失败";
34988
- const data = isSuccess ? {
34989
- isValidSession: true
34990
- } : {
34991
- isValidSession: false
34992
- };
34993
- return success(data, message);
34994
- };
34995
- const extractEncFileKey = (downloadUrl)=>{
34996
- if (!downloadUrl) return "";
34997
- return downloadUrl.split("encfilekey=")[1]?.split("&")[0] || "";
34998
- };
34999
- const rid = ()=>`${Math.floor(Date.now() / 1e3).toString(16)}-${[
35000
- ...Array(8)
35001
- ].map(()=>Math.floor(16 * Math.random()).toString(16)).join("")}`;
35002
- new Uint8Array(16);
35003
- const hexTable = [];
35004
- for(let i = 0; i < 256; i++)hexTable.push((i + 256).toString(16).substr(1));
35005
- const createShipinhaoComment = async (_task, params)=>{
35006
- if (!params.content || "" === params.content.trim()) return utils_response(400, "评论内容不能为空", void 0);
35007
- if (!params.exportId) return utils_response(400, "exportId 不能为空", void 0);
35008
- if (!params.extraParam) return utils_response(400, "缺少 extraParam 参数", void 0);
35009
- if (!params.extraParam.fingerPrintDeviceId || !params.extraParam.aId || !params.extraParam.uin) return utils_response(400, "fingerPrintDeviceId、aId和uin不能为空", void 0);
35010
- const headers = {
35011
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
35012
- referer: "https://channels.weixin.qq.com/micro/interaction/comment",
35013
- origin: "https://channels.weixin.qq.com",
35014
- "content-type": "application/json",
35015
- "finger-print-device-id": params.extraParam.fingerPrintDeviceId,
35016
- "x-wechat-uin": params.extraParam.uin
35017
- };
35018
- const http = new Http({
35019
- headers
35020
- });
35021
- const urlParams = new URLSearchParams({
35022
- _aid: params.extraParam.aId,
35023
- _rid: rid(),
35024
- _pageUrl: "https://channels.weixin.qq.com/micro/interaction/comment"
35025
- }).toString();
35026
- const requestData = {
35027
- replyCommentId: params.replyCommentId || "",
35028
- content: params.content,
35029
- clientId: `${Date.now()}-${Math.random().toString(36).substring(2, 15)}`,
35030
- rootCommentId: params.rootCommentId || "",
35031
- comment: {},
35032
- exportId: params.exportId,
35033
- timestamp: Date.now().toString(),
35034
- _log_finder_uin: "",
35035
- _log_finder_id: params.extraParam.finderUserName || "",
35036
- rawKeyBuff: null,
35037
- pluginSessionId: null,
35038
- scene: 7,
35039
- reqScene: 7
35040
- };
35041
- if (params.rootCommentId) requestData.rootCommentId = params.rootCommentId;
35042
- if (params.replyCommentId) requestData.replyCommentId = params.replyCommentId;
35043
- const res = await http.api({
35044
- method: "post",
35045
- url: `https://channels.weixin.qq.com/micro/interaction/cgi-bin/mmfinderassistant-bin/comment/create_comment?${urlParams}`,
35046
- data: requestData
35047
- });
35048
- console.log(res, "----create comment res");
35049
- const isSuccess = res?.errCode === 0;
35050
- return utils_response(isSuccess ? 0 : 414, res?.errMsg || "添加评论失败", res.data);
35051
- };
35052
- const { generateCsrfTokenAdvanced } = __webpack_require__("./src/utils/douyin/douyinSafe/csrfToken.js");
35053
- const { getABogus } = __webpack_require__("./src/utils/douyin/douyinSafe/a_bogus.js");
35054
- const { generateDtrait } = __webpack_require__("./src/utils/douyin/douyinSafe/dtrait.js");
35055
- const DouyinCheckVerifyQrCodeParamsSchema = ActionCommonParamsSchema.extend({
35056
- token: classic_schemas_string(),
35057
- encrypt_uid: classic_schemas_string(),
35058
- verify_scene: classic_schemas_string().optional(),
35059
- verify_reason: classic_schemas_string().optional(),
35060
- extraParam: classic_schemas_object({
35061
- browserInfo: classic_schemas_object({
35062
- screen_width: classic_schemas_string().optional(),
35063
- screen_height: classic_schemas_string().optional(),
35064
- browser_language: classic_schemas_string().optional(),
35065
- browser_platform: classic_schemas_string().optional(),
35066
- browser_name: classic_schemas_string().optional(),
35067
- "sec-ch-ua-platform": classic_schemas_string().optional(),
35068
- "sec-ch-ua": classic_schemas_string().optional(),
35069
- userAgent: classic_schemas_string().optional()
35070
- })
35071
- }).optional()
35072
- });
35073
- function mergeSetCookies(oldCookies, setCookieHeader) {
35074
- if (!setCookieHeader) return oldCookies;
35075
- const setCookies = Array.isArray(setCookieHeader) ? setCookieHeader : [
35076
- setCookieHeader
35077
- ];
35078
- const cookieMap = new Map(oldCookies.map((c)=>[
35079
- c.name,
35080
- c
35081
- ]));
35082
- for (const raw of setCookies){
35083
- const parts = raw.split(";");
35084
- const [nameValue] = parts;
35085
- if (!nameValue) continue;
35086
- const eqIdx = nameValue.indexOf("=");
35087
- if (-1 === eqIdx) continue;
35088
- const name = nameValue.slice(0, eqIdx).trim();
35089
- const value = nameValue.slice(eqIdx + 1).trim();
35090
- if (!name) continue;
35091
- const attrs = {};
35092
- for(let i = 1; i < parts.length; i++){
35093
- const part = parts[i].trim();
35094
- const attrEq = part.indexOf("=");
35095
- if (-1 === attrEq) attrs[part.toLowerCase()] = true;
35096
- else attrs[part.slice(0, attrEq).trim().toLowerCase()] = part.slice(attrEq + 1).trim();
35097
- }
35098
- const existing = cookieMap.get(name);
35099
- cookieMap.set(name, {
35100
- ...existing || {},
35101
- ...attrs,
35102
- name,
35103
- value
35104
- });
35105
- }
35106
- return Array.from(cookieMap.values());
35107
- }
35108
- const douyinCheckVerifyQrCode = async (task, params)=>{
35109
- const userAgent = params.userAgent || "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.38";
35110
- const bizTraceId = params.cookies.find((e)=>"biz_trace_id" === e.name)?.value || "00000000";
35111
- const msToken = params.cookies.find((e)=>"msToken" === e.name)?.value || "";
35112
- const passportCsrfToken = params.cookies.find((e)=>"passport_csrf_token" === e.name)?.value || "";
35113
- try {
35114
- task.logger.info(`[douyinCheckVerifyQrCode] 开始轮询二维码状态, token=${params.token}`);
35115
- const headers = {
35116
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
35117
- origin: "https://creator.douyin.com",
35118
- referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
35119
- Accept: "application/json, text/plain, */*",
35120
- "Accept-Encoding": "gzip, deflate, br, zstd",
35121
- "sec-ch-ua-platform": params.extraParam?.browserInfo?.["sec-ch-ua-platform"] || "",
35122
- "sec-ch-ua": params.extraParam?.browserInfo?.["sec-ch-ua"] || "",
35123
- "sec-ch-ua-mobile": "?0",
35124
- "user-agent": userAgent,
35125
- "sec-fetch-site": "same-origin",
35126
- "sec-fetch-mode": "cors",
35127
- "sec-fetch-dest": "empty",
35128
- "accept-language": "zh-CN,zh;q=0.9",
35129
- priority: "u=1, i"
35130
- };
35131
- const checkBody = {
35132
- encrypt_uid: params.encrypt_uid || "",
35133
- verify_ticket: "",
35134
- copywriting_key: "creator",
35135
- new_verify_flow: "",
35136
- aid: "2906",
35137
- token: params.token,
35138
- verify_type: "",
35139
- need_record: "1",
35140
- scene: "secondary_verify",
35141
- verify_scene: params.verify_scene || "creator",
35142
- verify_reason: params.verify_reason || "gateway_web_authlv_check",
35143
- std_verify_way: "qr_code_verify",
35144
- new_authn_sdk_version: "1.0.0.404-web"
35145
- };
35146
- const checkBodyStr = new URLSearchParams(checkBody).toString();
35147
- const checkQueryParams = {
35148
- passport_jssdk_version: "5.1.2",
35149
- passport_jssdk_type: "lite",
35150
- is_from_ttaccountsdk: "1",
35151
- aid: "2906",
35152
- language: "zh",
35153
- account_app_language: "zh-CN",
35154
- new_authn_sdk_version: "1.0.0.404-web",
35155
- is_vcd: "1",
35156
- biz_trace_id: bizTraceId,
35157
- msToken,
35158
- a_bogus: ""
35159
- };
35160
- const checkQueryStr = new URLSearchParams(checkQueryParams).toString();
35161
- const checkUrl = `https://creator.douyin.com/passport/mobile/validate_by_qrcode/?${checkQueryStr}`;
35162
- const aBogus = getABogus(checkUrl, checkBodyStr, userAgent);
35163
- checkQueryParams.a_bogus = aBogus;
35164
- const finalQueryStr = new URLSearchParams(checkQueryParams).toString();
35165
- const csrfToken = generateCsrfTokenAdvanced({
35166
- cookies: params.cookies,
35167
- url: "https://creator.douyin.com/passport/mobile/validate_by_qrcode/",
35168
- method: "POST",
35169
- userAgent
35170
- });
35171
- const sessionDtrait = generateDtrait("/passport/mobile/validate_by_qrcode/");
35172
- let rawSetCookie;
35173
- const checkHttp = new Http({
35174
- headers: {
35175
- ...headers,
35176
- "Content-Type": "application/x-www-form-urlencoded",
35177
- "x-secsdk-csrf-token": csrfToken,
35178
- "x-tt-passport-csrf-token": passportCsrfToken,
35179
- "x-tt-passport-trace-id": bizTraceId,
35180
- "x-tt-passport-verify-portrait": "",
35181
- "x-tt-session-dtrait": sessionDtrait || ""
35182
- }
35183
- });
35184
- checkHttp.addResponseInterceptor((res)=>{
35185
- task.logger.info(`[douyinCheckVerifyQrCode] 原始响应 status=${res.status} data=${JSON.stringify(res.data)}`);
35186
- console.log("[douyinCheckVerifyQrCode] 原始响应:", JSON.stringify(res.data));
35187
- rawSetCookie = res.headers["set-cookie"];
35188
- });
35189
- const checkResponse = await checkHttp.api({
35190
- method: "post",
35191
- url: `https://creator.douyin.com/passport/mobile/validate_by_qrcode/?${finalQueryStr}`,
35192
- data: checkBodyStr
35193
- }, {
35194
- timeout: 10000
35195
- });
35196
- const data = checkResponse?.data;
35197
- const status = data?.status;
35198
- task.logger.info(`[douyinCheckVerifyQrCode] status=${status}`);
35199
- const updatedCookies = mergeSetCookies(params.cookies, rawSetCookie);
35200
- if ("new" === status) return utils_response(0, "二维码等待扫描", data);
35201
- if ("scanned" === status) return utils_response(0, "二维码已扫码,待确认扫描", data);
35202
- if ("confirmed" === status) return utils_response(0, "扫码验证成功", {
35203
- status: "confirmed",
35204
- redirect_url: data.redirect_url || "",
35205
- ticket: data.ticket || "",
35206
- cookies: updatedCookies
35207
- });
35208
- if ("expired" === status) return utils_response(0, "二维码已过期", {
35209
- status: "expired",
35210
- token: data.token || "",
35211
- qrcode: data.qrcode || "",
35212
- qrcode_index_url: data.qrcode_index_url || "",
35213
- expire_time: data.expire_time || 0,
35214
- app_name: data.app_name || "",
35215
- web_name: data.web_name || ""
35216
- });
35217
- return utils_response(414, `未知二维码状态: ${status}`, "");
35218
- } catch (err) {
35219
- const msg = err instanceof Error ? err.message : String(err);
35220
- task.logger.warn(`[douyinCheckVerifyQrCode] 请求失败: ${msg}`);
35221
- return utils_response(500, `校验二维码失败: ${msg}`, "");
35222
- }
35223
- };
35224
- const DouyinCreateCommentReplyParamsSchema = ActionCommonParamsSchema.extend({
35225
- itemId: classic_schemas_string(),
35226
- commentId: classic_schemas_string(),
35227
- text: classic_schemas_string()
35228
- });
35229
- const { getABogus: douyinCreateCommentReply_getABogus } = __webpack_require__("./src/utils/douyin/douyinSafe/a_bogus.js");
35230
- const { generateCsrfTokenAdvanced: douyinCreateCommentReply_generateCsrfTokenAdvanced } = __webpack_require__("./src/utils/douyin/douyinSafe/csrfToken.js");
35231
- const douyinCreateCommentReply = async (_task, params)=>{
35232
- const userAgent = params.userAgent || "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.38";
35233
- const headers = {
35234
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
35235
- origin: "https://creator.douyin.com",
35236
- referer: "https://creator.douyin.com/",
35237
- Accept: "application/json, text/plain, */*",
35238
- "Accept-Encoding": "gzip, deflate, br, zstd",
35239
- "Content-Type": "application/json",
35240
- pragma: "no-cache",
35241
- "cache-control": "no-cache",
35242
- "sec-ch-ua-platform": params.extraParam?.browserInfo?.["sec-ch-ua-platform"] || "",
35243
- "sec-ch-ua": params.extraParam?.browserInfo?.["sec-ch-ua"] || "",
35244
- "sec-ch-ua-mobile": "?0",
35245
- "user-agent": userAgent,
35246
- "sec-fetch-site": "same-origin",
35247
- "sec-fetch-mode": "cors",
35248
- "sec-fetch-dest": "empty",
35249
- "accept-language": "zh-CN,zh;q=0.9",
35250
- priority: "u=1, i"
35251
- };
35252
- const args = [
35253
- {
35254
- headers
35255
- },
35256
- _task.logger,
35257
- params.proxyLoc,
35258
- params.accountId
35259
- ];
35260
- const http = new Http(...args);
35261
- const csrfToken = douyinCreateCommentReply_generateCsrfTokenAdvanced({
35262
- cookies: params.cookies,
35263
- url: "https://creator.douyin.com/aweme/v1/creator/comment/reply/",
35264
- method: "POST",
35265
- userAgent
34254
+ const csrfToken = douyinCreateCommentReply_generateCsrfTokenAdvanced({
34255
+ cookies: params.cookies,
34256
+ url: "https://creator.douyin.com/aweme/v1/creator/comment/reply/",
34257
+ method: "POST",
34258
+ userAgent
35266
34259
  });
35267
34260
  const queryParams = {
35268
34261
  read_aid: "2906",
@@ -40332,125 +39325,1088 @@ var __webpack_exports__ = {};
40332
39325
  cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
40333
39326
  referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
40334
39327
  }
40335
- });
40336
- const res = await http.api({
40337
- method: "get",
40338
- url: "https://mp.toutiao.com/mp/fe_api/collection/list",
40339
- params: {
40340
- page_num: 0,
40341
- page_size: 100,
40342
- need_sub_item_count: true
39328
+ });
39329
+ const res = await http.api({
39330
+ method: "get",
39331
+ url: "https://mp.toutiao.com/mp/fe_api/collection/list",
39332
+ params: {
39333
+ page_num: 0,
39334
+ page_size: 100,
39335
+ need_sub_item_count: true
39336
+ }
39337
+ });
39338
+ return success(0 === res.code ? res.data : [], 0 === res.code ? "获取头条号合集成功!" : "获取头条号合集失败!");
39339
+ };
39340
+ const getToutiaoConfig = async (_task, params)=>{
39341
+ const cookies = params.cookies ?? [];
39342
+ const http = new Http({
39343
+ headers: {
39344
+ cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
39345
+ referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
39346
+ }
39347
+ });
39348
+ const getSuggestWords = async ()=>{
39349
+ try {
39350
+ const res = await http.api({
39351
+ method: "get",
39352
+ url: "https://mp.toutiao.com/mp/agw/creator_helper/suggest_words",
39353
+ params: {
39354
+ type: 2,
39355
+ words: ""
39356
+ }
39357
+ });
39358
+ return 0 === res.code ? res.hots : [];
39359
+ } catch (_error) {
39360
+ return [];
39361
+ }
39362
+ };
39363
+ const getCityDistrict = async ()=>{
39364
+ try {
39365
+ const res = await http.api({
39366
+ method: "get",
39367
+ url: "https://mp.toutiao.com/toutiao/normandy/mp/city_district/"
39368
+ });
39369
+ return 0 === res.status ? res.data : null;
39370
+ } catch (_error) {
39371
+ return null;
39372
+ }
39373
+ };
39374
+ const getUserRights = async ()=>{
39375
+ try {
39376
+ const res = await http.api({
39377
+ method: "get",
39378
+ url: "https://mp.toutiao.com/mp/agw/creator_project/get_benefit_page_info"
39379
+ });
39380
+ return 0 === res.code ? res.data.benefit_level_info_list : [];
39381
+ } catch (_error) {
39382
+ return [];
39383
+ }
39384
+ };
39385
+ const [suggestWords, cityDistrict, userRights] = await Promise.all([
39386
+ getSuggestWords(),
39387
+ getCityDistrict(),
39388
+ getUserRights()
39389
+ ]);
39390
+ return success({
39391
+ suggestWords,
39392
+ cityDistrict,
39393
+ userRights
39394
+ });
39395
+ };
39396
+ const getWeixinCollection = async (_task, params)=>{
39397
+ const http = new Http({
39398
+ headers: {
39399
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";")
39400
+ }
39401
+ });
39402
+ const fingerprint = "4695500bc93ab4ce8fb2692da6564e04";
39403
+ const res = await http.api({
39404
+ method: "get",
39405
+ url: "https://mp.weixin.qq.com/cgi-bin/appmsgalbummgr",
39406
+ params: {
39407
+ action: "list",
39408
+ begin: 0,
39409
+ count: 100,
39410
+ sub_title: "",
39411
+ type: 0,
39412
+ latest: 1,
39413
+ need_pay: 0,
39414
+ fingerprint,
39415
+ token: params.token,
39416
+ lang: "zh_CN",
39417
+ f: "json",
39418
+ ajax: 1
39419
+ }
39420
+ });
39421
+ return success(res.list_resp?.items ?? [], 0 === res.base_resp.ret ? "微信合计信息获取成功!" : "微信合集信息获取失败!");
39422
+ };
39423
+ const getWeixinConfig = async (_task, params)=>{
39424
+ const http = new Http({
39425
+ headers: {
39426
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";")
39427
+ }
39428
+ });
39429
+ const fingerprint = "4695500bc93ab4ce8fb2692da6564e04";
39430
+ const res = await http.api({
39431
+ method: "get",
39432
+ url: "https://mp.weixin.qq.com/cgi-bin/masssendpage",
39433
+ params: {
39434
+ f: "json",
39435
+ token: params.token,
39436
+ lang: "zh_CN",
39437
+ ajax: 1,
39438
+ fingerprint: fingerprint,
39439
+ random: Math.random().toString()
39440
+ }
39441
+ });
39442
+ const filtered = {
39443
+ publishQuota: 0 === res.base_resp.ret ? res.quota_detail_list.filter((item)=>"kQuotaTypeMassSendNormal" === item.quota_type).map((item)=>item.quota_item_list) : []
39444
+ };
39445
+ return success(filtered, 0 === res.base_resp.ret ? "微信配置信息获取成功!" : "微信配置信息获取失败!");
39446
+ };
39447
+ class CryptoConfig {
39448
+ static{
39449
+ this.MAX_32BIT = 0xFFFFFFFF;
39450
+ }
39451
+ static{
39452
+ this.MAX_SIGNED_32BIT = 0x7FFFFFFF;
39453
+ }
39454
+ static{
39455
+ this.MAX_BYTE = 255;
39456
+ }
39457
+ static{
39458
+ this.STANDARD_BASE64_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
39459
+ }
39460
+ static{
39461
+ this.CUSTOM_BASE64_ALPHABET = "ZmserbBoHQtNP+wOcza/LpngG8yJq42KWYj0DSfdikx3VT16IlUAFM97hECvuRX5";
39462
+ }
39463
+ static{
39464
+ this.X3_BASE64_ALPHABET = "MfgqrsbcyzPQRStuvC7mn501HIJBo2DEFTKdeNOwxWXYZap89+/A4UVLhijkl63G";
39465
+ }
39466
+ static{
39467
+ this.HEX_KEY = "71a302257793271ddd273bcee3e4b98d9d7935e1da33f5765e2ea8afb6dc77a51a499d23b67c20660025860cbf13d4540d92497f58686c574e508f46e1956344f39139bf4faf22a3eef120b79258145b2feb5193b6478669961298e79bedca646e1a693a926154a5a7a1bd1cf0dedb742f917a747a1e388b234f2277";
39468
+ }
39469
+ static{
39470
+ this.EXPECTED_HEX_LENGTH = 32;
39471
+ }
39472
+ static{
39473
+ this.OUTPUT_BYTE_COUNT = 8;
39474
+ }
39475
+ static{
39476
+ this.HEX_CHUNK_SIZE = 2;
39477
+ }
39478
+ static{
39479
+ this.VERSION_BYTES = [
39480
+ 119,
39481
+ 104,
39482
+ 96,
39483
+ 41
39484
+ ];
39485
+ }
39486
+ static{
39487
+ this.SEQUENCE_VALUE_MIN = 15;
39488
+ }
39489
+ static{
39490
+ this.SEQUENCE_VALUE_MAX = 50;
39491
+ }
39492
+ static{
39493
+ this.WINDOW_PROPS_LENGTH_MIN = 900;
39494
+ }
39495
+ static{
39496
+ this.WINDOW_PROPS_LENGTH_MAX = 1200;
39497
+ }
39498
+ static{
39499
+ this.CHECKSUM_VERSION = 1;
39500
+ }
39501
+ static{
39502
+ this.CHECKSUM_XOR_KEY = 115;
39503
+ }
39504
+ static{
39505
+ this.CHECKSUM_FIXED_TAIL = [
39506
+ 249,
39507
+ 65,
39508
+ 103,
39509
+ 103,
39510
+ 201,
39511
+ 181,
39512
+ 131,
39513
+ 99,
39514
+ 94,
39515
+ 7,
39516
+ 68,
39517
+ 250,
39518
+ 132,
39519
+ 21
39520
+ ];
39521
+ }
39522
+ static{
39523
+ this.ENV_FINGERPRINT_XOR_KEY = 41;
39524
+ }
39525
+ static{
39526
+ this.ENV_FINGERPRINT_TIME_OFFSET_MIN = 10;
39527
+ }
39528
+ static{
39529
+ this.ENV_FINGERPRINT_TIME_OFFSET_MAX = 50;
39530
+ }
39531
+ static{
39532
+ this.SIGNATURE_DATA_TEMPLATE = {
39533
+ x0: "4.2.6",
39534
+ x1: "xhs-pc-web",
39535
+ x2: "Windows",
39536
+ x3: "",
39537
+ x4: ""
39538
+ };
39539
+ }
39540
+ static{
39541
+ this.X3_PREFIX = "mns0301_";
39542
+ }
39543
+ static{
39544
+ this.XYS_PREFIX = "XYS_";
39545
+ }
39546
+ static{
39547
+ this.HEX_CHARS = "abcdef0123456789";
39548
+ }
39549
+ static{
39550
+ this.XRAY_TRACE_ID_SEQ_MAX = 8388607;
39551
+ }
39552
+ static{
39553
+ this.XRAY_TRACE_ID_TIMESTAMP_SHIFT = 23;
39554
+ }
39555
+ static{
39556
+ this.B3_TRACE_ID_LENGTH = 16;
39557
+ }
39558
+ static{
39559
+ this.PUBLIC_USERAGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 Edg/142.0.0.0";
39560
+ }
39561
+ static{
39562
+ this.SIGNATURE_XSCOMMON_TEMPLATE = {
39563
+ s0: 5,
39564
+ s1: "",
39565
+ x0: "1",
39566
+ x1: "4.2.6",
39567
+ x2: "Windows",
39568
+ x3: "xhs-pc-web",
39569
+ x4: "4.86.0",
39570
+ x5: "",
39571
+ x6: "",
39572
+ x7: "",
39573
+ x8: "",
39574
+ x9: -596800761,
39575
+ x10: 0,
39576
+ x11: "normal"
39577
+ };
39578
+ }
39579
+ }
39580
+ class BitOperations {
39581
+ normalizeTo32bit(value) {
39582
+ return value & this.config.MAX_32BIT;
39583
+ }
39584
+ xorTransformArray(inputArray) {
39585
+ const keyBytes = this.hexStringToBytes(this.config.HEX_KEY);
39586
+ const result = new Uint8Array(inputArray.length);
39587
+ for(let i = 0; i < inputArray.length; i++)result[i] = inputArray[i] ^ keyBytes[i % keyBytes.length];
39588
+ return result;
39589
+ }
39590
+ hexStringToBytes(hexString) {
39591
+ const bytes = [];
39592
+ for(let i = 0; i < hexString.length; i += 2)bytes.push(parseInt(hexString.substr(i, 2), 16));
39593
+ return bytes;
39594
+ }
39595
+ constructor(){
39596
+ this.config = CryptoConfig;
39597
+ }
39598
+ }
39599
+ class RandomGenerator {
39600
+ generateRandomBytes(byteCount) {
39601
+ const result = [];
39602
+ for(let i = 0; i < byteCount; i++)result.push(Math.floor(Math.random() * (this.config.MAX_BYTE + 1)));
39603
+ return result;
39604
+ }
39605
+ generateRandomByteInRange(minVal, maxVal) {
39606
+ return Math.floor(Math.random() * (maxVal - minVal + 1)) + minVal;
39607
+ }
39608
+ generateRandomInt() {
39609
+ return Math.floor(Math.random() * (this.config.MAX_32BIT + 1));
39610
+ }
39611
+ generateB3TraceId() {
39612
+ let result = '';
39613
+ for(let i = 0; i < this.config.B3_TRACE_ID_LENGTH; i++)result += this.config.HEX_CHARS[Math.floor(Math.random() * this.config.HEX_CHARS.length)];
39614
+ return result;
39615
+ }
39616
+ generateXrayTraceId(timestamp, seq) {
39617
+ if (void 0 === timestamp) timestamp = Date.now();
39618
+ if (void 0 === seq) seq = Math.floor(Math.random() * (this.config.XRAY_TRACE_ID_SEQ_MAX + 1));
39619
+ const part1 = (timestamp << this.config.XRAY_TRACE_ID_TIMESTAMP_SHIFT | seq).toString(16).padStart(16, '0');
39620
+ let part2 = '';
39621
+ for(let i = 0; i < 16; i++)part2 += this.config.HEX_CHARS[Math.floor(Math.random() * this.config.HEX_CHARS.length)];
39622
+ return part1 + part2;
39623
+ }
39624
+ constructor(){
39625
+ this.config = CryptoConfig;
39626
+ }
39627
+ }
39628
+ class Base64Encoder {
39629
+ encode(dataToEncode) {
39630
+ const dataBytes = Buffer.from(dataToEncode, 'utf-8');
39631
+ const standardEncodedString = dataBytes.toString('base64');
39632
+ let result = '';
39633
+ for (const char of standardEncodedString){
39634
+ const index = this.config.STANDARD_BASE64_ALPHABET.indexOf(char);
39635
+ if (-1 !== index) result += this.config.CUSTOM_BASE64_ALPHABET[index];
39636
+ else result += char;
39637
+ }
39638
+ return result;
39639
+ }
39640
+ decode(encodedString) {
39641
+ let standardString = '';
39642
+ for (const char of encodedString){
39643
+ const index = this.config.CUSTOM_BASE64_ALPHABET.indexOf(char);
39644
+ if (-1 !== index) standardString += this.config.STANDARD_BASE64_ALPHABET[index];
39645
+ else standardString += char;
39646
+ }
39647
+ return Buffer.from(standardString, 'base64').toString('utf-8');
39648
+ }
39649
+ encodeX3(dataBytes) {
39650
+ const base64String = Buffer.from(dataBytes).toString('base64');
39651
+ let result = '';
39652
+ for (const char of base64String){
39653
+ const index = this.config.STANDARD_BASE64_ALPHABET.indexOf(char);
39654
+ if (-1 !== index) result += this.config.X3_BASE64_ALPHABET[index];
39655
+ else result += char;
39656
+ }
39657
+ return result;
39658
+ }
39659
+ decodeX3(encodedString) {
39660
+ let standardString = '';
39661
+ for (const char of encodedString){
39662
+ const index = this.config.X3_BASE64_ALPHABET.indexOf(char);
39663
+ if (-1 !== index) standardString += this.config.STANDARD_BASE64_ALPHABET[index];
39664
+ else standardString += char;
39665
+ }
39666
+ return new Uint8Array(Buffer.from(standardString, 'base64'));
39667
+ }
39668
+ constructor(){
39669
+ this.config = CryptoConfig;
39670
+ }
39671
+ }
39672
+ class RequestSignatureValidator {
39673
+ static validateMethod(method) {
39674
+ if ('string' != typeof method) throw new TypeError(`method must be str, got ${typeof method}`);
39675
+ const normalizedMethod = method.trim().toUpperCase();
39676
+ if (![
39677
+ 'GET',
39678
+ 'POST'
39679
+ ].includes(normalizedMethod)) throw new Error(`method must be 'GET' or 'POST', got '${method}'`);
39680
+ return normalizedMethod;
39681
+ }
39682
+ static validateUri(uri) {
39683
+ if ('string' != typeof uri) throw new TypeError(`uri must be str, got ${typeof uri}`);
39684
+ if (!uri.trim()) throw new Error('uri cannot be empty');
39685
+ return uri.trim();
39686
+ }
39687
+ static validateA1Value(a1Value) {
39688
+ if ('string' != typeof a1Value) throw new TypeError(`a1_value must be str, got ${typeof a1Value}`);
39689
+ if (!a1Value.trim()) throw new Error('a1_value cannot be empty');
39690
+ return a1Value.trim();
39691
+ }
39692
+ static validateXsecAppid(xsecAppid) {
39693
+ if ('string' != typeof xsecAppid) throw new TypeError(`xsec_appid must be str, got ${typeof xsecAppid}`);
39694
+ if (!xsecAppid.trim()) throw new Error('xsec_appid cannot be empty');
39695
+ return xsecAppid.trim();
39696
+ }
39697
+ static validatePayload(payload) {
39698
+ if (null !== payload && ('object' != typeof payload || Array.isArray(payload))) throw new TypeError(`payload must be dict or None, got ${typeof payload}`);
39699
+ if (null !== payload) {
39700
+ for(const key in payload)if ('string' != typeof key) throw new TypeError(`payload keys must be str, got ${typeof key} for key '${key}'`);
39701
+ }
39702
+ return payload;
39703
+ }
39704
+ }
39705
+ class CryptoProcessor {
39706
+ intToLeBytes(val, length = 4) {
39707
+ const arr = [];
39708
+ for(let i = 0; i < length; i++){
39709
+ arr.push(0xFF & val);
39710
+ val >>>= 8;
39711
+ }
39712
+ return arr;
39713
+ }
39714
+ envFingerprintA(ts, xorKey) {
39715
+ const data = [];
39716
+ for(let i = 0; i < 8; i++)data.push(ts >>> 8 * i & 0xFF);
39717
+ const sum1 = data.slice(1, 5).reduce((a, b)=>a + b, 0);
39718
+ const sum2 = data.slice(5, 8).reduce((a, b)=>a + b, 0);
39719
+ const mark = (0xFF & sum1) + sum2 & 0xFF;
39720
+ data[0] = mark;
39721
+ return data.map((b)=>b ^ xorKey);
39722
+ }
39723
+ envFingerprintB(ts) {
39724
+ const data = [];
39725
+ for(let i = 0; i < 8; i++)data.push(ts >>> 8 * i & 0xFF);
39726
+ return data;
39727
+ }
39728
+ buildPayloadArray(hexParameter, a1Value, appIdentifier = "xhs-pc-web", stringParam = "", timestamp) {
39729
+ const payload = [];
39730
+ payload.push(...this.config.VERSION_BYTES);
39731
+ const seed = this.randomGen.generateRandomInt();
39732
+ const seedBytes = this.intToLeBytes(seed, 4);
39733
+ payload.push(...seedBytes);
39734
+ const seedByte0 = seedBytes[0];
39735
+ if (void 0 === timestamp) timestamp = Date.now() / 1000;
39736
+ const tsMs = Math.floor(1000 * timestamp);
39737
+ payload.push(...this.envFingerprintA(tsMs, this.config.ENV_FINGERPRINT_XOR_KEY));
39738
+ const timeOffset = this.randomGen.generateRandomByteInRange(this.config.ENV_FINGERPRINT_TIME_OFFSET_MIN, this.config.ENV_FINGERPRINT_TIME_OFFSET_MAX);
39739
+ payload.push(...this.envFingerprintB(tsMs - 1000 * timeOffset));
39740
+ const sequenceValue = this.randomGen.generateRandomByteInRange(this.config.SEQUENCE_VALUE_MIN, this.config.SEQUENCE_VALUE_MAX);
39741
+ payload.push(...this.intToLeBytes(sequenceValue, 4));
39742
+ const windowPropsLength = this.randomGen.generateRandomByteInRange(this.config.WINDOW_PROPS_LENGTH_MIN, this.config.WINDOW_PROPS_LENGTH_MAX);
39743
+ payload.push(...this.intToLeBytes(windowPropsLength, 4));
39744
+ const uriLength = Buffer.from(stringParam, 'utf-8').length;
39745
+ payload.push(...this.intToLeBytes(uriLength, 4));
39746
+ const md5Bytes = Buffer.from(hexParameter, 'hex');
39747
+ for(let i = 0; i < 8; i++)payload.push(md5Bytes[i] ^ seedByte0);
39748
+ payload.push(52);
39749
+ const a1Bytes = Buffer.from(a1Value, 'utf-8');
39750
+ for(let i = 0; i < 52; i++)payload.push(i < a1Bytes.length ? a1Bytes[i] : 0);
39751
+ payload.push(10);
39752
+ const sourceBytes = Buffer.from(appIdentifier, 'utf-8');
39753
+ for(let i = 0; i < 10; i++)payload.push(i < sourceBytes.length ? sourceBytes[i] : 0);
39754
+ payload.push(1);
39755
+ payload.push(this.config.CHECKSUM_VERSION);
39756
+ payload.push(seedByte0 ^ this.config.CHECKSUM_XOR_KEY);
39757
+ payload.push(...this.config.CHECKSUM_FIXED_TAIL);
39758
+ return payload;
39759
+ }
39760
+ constructor(){
39761
+ this.config = CryptoConfig;
39762
+ this.bitOps = new BitOperations();
39763
+ this.b64encoder = new Base64Encoder();
39764
+ this.randomGen = new RandomGenerator();
39765
+ }
39766
+ }
39767
+ class CRC32 {
39768
+ static{
39769
+ this.CRC32_TABLE = (()=>{
39770
+ const table = [];
39771
+ for(let i = 0; i < 256; i++){
39772
+ let crc = i;
39773
+ for(let j = 0; j < 8; j++)crc = 1 & crc ? 0xEDB88320 ^ crc >>> 1 : crc >>> 1;
39774
+ table.push(crc >>> 0);
39775
+ }
39776
+ return table;
39777
+ })();
39778
+ }
39779
+ static crc32JsInt(input, signed = true) {
39780
+ let crc = 0xFFFFFFFF;
39781
+ const data = 'string' == typeof input ? this.stringToBytes(input) : input;
39782
+ for (const byte of data){
39783
+ const index = (crc ^ byte) & 0xFF;
39784
+ crc = (this.CRC32_TABLE[index] ^ crc >>> 8) >>> 0;
39785
+ }
39786
+ crc = (0xFFFFFFFF ^ crc) >>> 0;
39787
+ if (signed) return crc > 0x7FFFFFFF ? crc - 0x100000000 : crc;
39788
+ return crc;
39789
+ }
39790
+ static stringToBytes(str) {
39791
+ const bytes = [];
39792
+ for(let i = 0; i < str.length; i++){
39793
+ const code = str.charCodeAt(i);
39794
+ if (code <= 0xFF) bytes.push(code);
39795
+ else bytes.push(0xFF & code);
39796
+ }
39797
+ return bytes;
39798
+ }
39799
+ }
39800
+ class FingerprintData {
39801
+ static{
39802
+ this.GPU_VENDORS = [
39803
+ "Google Inc. (Intel)|ANGLE (Intel, Intel(R) HD Graphics 400 (0x00000166) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39804
+ "Google Inc. (Intel)|ANGLE (Intel, Intel(R) HD Graphics 4400 (0x00001112) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39805
+ "Google Inc. (Intel)|ANGLE (Intel, Intel(R) HD Graphics 4600 (0x00000412) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39806
+ "Google Inc. (Intel)|ANGLE (Intel, Intel(R) HD Graphics 520 (0x1912) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39807
+ "Google Inc. (Intel)|ANGLE (Intel, Intel(R) HD Graphics 530 (0x00001912) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39808
+ "Google Inc. (Intel)|ANGLE (Intel, Intel(R) HD Graphics 550 (0x00001512) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39809
+ "Google Inc. (Intel)|ANGLE (Intel, Intel(R) HD Graphics 6000 (0x1606) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39810
+ "Google Inc. (Intel)|ANGLE (Intel, Intel(R) Iris(TM) Graphics 540 (0x1912) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39811
+ "Google Inc. (Intel)|ANGLE (Intel, Intel(R) Iris(TM) Graphics 550 (0x1913) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39812
+ "Google Inc. (Intel)|ANGLE (Intel, Intel(R) Iris(TM) Plus Graphics 640 (0x161C) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39813
+ "Google Inc. (Intel)|ANGLE (Intel, Intel(R) UHD Graphics 600 (0x3E80) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39814
+ "Google Inc. (Intel)|ANGLE (Intel, Intel(R) UHD Graphics 620 (0x00003EA0) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39815
+ "Google Inc. (Intel)|ANGLE (Intel, Intel(R) UHD Graphics 630 (0x00003E9B) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39816
+ "Google Inc. (Intel)|ANGLE (Intel, Intel(R) UHD Graphics 655 (0x00009BC8) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39817
+ "Google Inc. (Intel)|ANGLE (Intel, Intel(R) Iris(R) Xe Graphics (0x000046A8) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39818
+ "Google Inc. (Intel)|ANGLE (Intel, Intel(R) Iris(R) Xe Graphics (0x00009A49) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39819
+ "Google Inc. (Intel)|ANGLE (Intel, Intel(R) Iris(R) Xe MAX Graphics (0x00009BC0) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39820
+ "Google Inc. (Intel)|ANGLE (Intel, Intel Arc A370M (0x0000AF51) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39821
+ "Google Inc. (Intel)|ANGLE (Intel, Intel Arc A380 (0x0000AF41) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39822
+ "Google Inc. (Intel)|ANGLE (Intel, Intel Arc A380M (0x0000AF5E) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39823
+ "Google Inc. (Intel)|ANGLE (Intel, Intel Arc A550 (0x0000AF42) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39824
+ "Google Inc. (Intel)|ANGLE (Intel, Intel Arc A770 (0x0000AF43) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39825
+ "Google Inc. (Intel)|ANGLE (Intel, Intel Arc A770M (0x0000AF50) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39826
+ "Google Inc. (Intel)|ANGLE (Intel, Mesa Intel(R) Graphics (RPL‑P GT1) (0x0000A702) OpenGL 4.6)",
39827
+ "Google Inc. (Intel)|ANGLE (Intel, Mesa Intel(R) UHD Graphics 770 (0x00004680) OpenGL 4.6)",
39828
+ "Google Inc. (Intel)|ANGLE (Intel, Mesa Intel(R) HD Graphics 4400 (0x00001122) OpenGL 4.6)",
39829
+ "Google Inc. (Intel)|ANGLE (Intel, Mesa Intel(R) Graphics (ADL‑S GT1) (0x0000A0A1) OpenGL 4.6)",
39830
+ "Google Inc. (Intel)|ANGLE (Intel, Mesa Intel(R) Graphics (RKL GT1) (0x0000A9A1) OpenGL 4.6)",
39831
+ "Google Inc. (Intel)|ANGLE (Intel, Mesa Intel(R) UHD Graphics (CML GT2) (0x00009A14) OpenGL 4.6)",
39832
+ "Google Inc. (Intel)|ANGLE (Intel, Intel(R) HD Graphics 3000 (0x00001022) Direct3D9Ex vs_3_0 ps_3_0, igdumd64.dll)",
39833
+ "Google Inc. (Intel)|ANGLE (Intel, Intel(R) HD Graphics Family (0x00000A16) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39834
+ "Google Inc. (Intel)|ANGLE (Intel, Intel(R) Iris Pro OpenGL Engine, OpenGL 4.1)",
39835
+ "Google Inc. (Intel)|ANGLE (Intel, Intel(R) Iris(TM) Plus Graphics 645 (0x1616) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39836
+ "Google Inc. (Intel)|ANGLE (Intel, Intel(R) Iris(TM) Plus Graphics 655 (0x161E) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39837
+ "Google Inc. (Intel)|ANGLE (Intel, Intel(R) UHD Graphics 730 (0x0000A100) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39838
+ "Google Inc. (Intel)|ANGLE (Intel, Intel(R) UHD Graphics 805 (0x0000B0A0) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39839
+ "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon Vega 3 Graphics (0x000015E0) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39840
+ "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon Vega 8 Graphics (0x000015D8) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39841
+ "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon Vega 11 Graphics (0x000015DD) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39842
+ "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon Graphics (0x00001636) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39843
+ "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon RX 5500 XT Direct3D11 vs_5_0 ps_5_0, D3D11)",
39844
+ "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon RX 560 (0x000067EF) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39845
+ "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon RX 570 (0x000067DF) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39846
+ "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon RX 580 2048SP (0x00006FDF) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39847
+ "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon RX 590 (0x000067FF) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39848
+ "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon RX 6600 (0x000073FF) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39849
+ "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon RX 6600 XT (0x000073FF) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39850
+ "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon RX 6650 XT Direct3D11 vs_5_0 ps_5_0, D3D11)",
39851
+ "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon RX 6700 XT (0x000073DF) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39852
+ "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon RX 6800 (0x000073BF) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39853
+ "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon RX 6900 XT (0x000073C2) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39854
+ "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon RX 7700 XT Direct3D11 vs_5_0 ps_5_0, D3D11)",
39855
+ "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon Pro 5300M OpenGL Engine, OpenGL 4.1)",
39856
+ "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon Pro 5500 XT OpenGL Engine, OpenGL 4.1)",
39857
+ "Google Inc. (AMD)|ANGLE (AMD, AMD Radeon R7 370 Series (0x00006811) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39858
+ "Google Inc. (AMD)|ANGLE (AMD, ATI Technologies Inc. AMD Radeon RX Vega 64 OpenGL Engine, OpenGL 4.1)",
39859
+ "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce GTX 1050 (0x00001C81) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39860
+ "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce GTX 1050 Ti (0x00001C8C) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39861
+ "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce GTX 1060 6GB (0x000010DE) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39862
+ "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce GTX 1070 (0x00001B81) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39863
+ "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce GTX 1080 (0x00001B80) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39864
+ "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce RTX 2060 (0x00001F06) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39865
+ "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce RTX 2060 SUPER (0x00001F06) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39866
+ "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce RTX 2070 (0x00001F10) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39867
+ "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce RTX 2070 SUPER (0x00001F10) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39868
+ "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce RTX 3060 (0x0000250F) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39869
+ "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce RTX 3060 Ti (0x00002489) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39870
+ "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce RTX 3070 (0x00002488) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39871
+ "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce RTX 3070 Ti (0x000028A5) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39872
+ "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce RTX 3080 (0x00002206) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39873
+ "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce RTX 3080 Ti (0x00002208) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39874
+ "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce RTX 3090 (0x00002204) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39875
+ "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce RTX 4060 (0x00002882) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39876
+ "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce RTX 4060 Ti (0x00002803) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39877
+ "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce RTX 4070 (0x00002786) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39878
+ "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce RTX 4070 Ti (0x00002857) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39879
+ "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce RTX 4080 (0x00002819) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39880
+ "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA GeForce RTX 4090 (0x00002684) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39881
+ "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA Quadro RTX 5000 Ada Generation (0x000026B2) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39882
+ "Google Inc. (NVIDIA)|ANGLE (NVIDIA, NVIDIA Quadro P400 (0x00001CB3) Direct3D11 vs_5_0 ps_5_0, D3D11)",
39883
+ "Google Inc. (Google)|ANGLE (Google, Vulkan 1.3.0 (SwiftShader Device (Subzero) (0x0000C0DE)), SwiftShader driver)",
39884
+ "Google Inc. (Google)|ANGLE (Google, Vulkan 1.3.0 (SwiftShader Device (Subzero)), SwiftShader driver)",
39885
+ "Google Inc. (Google)|ANGLE (Google, Vulkan 1.3.0 (SwiftShader Device), SwiftShader driver)"
39886
+ ];
39887
+ }
39888
+ static{
39889
+ this.SCREEN_RESOLUTIONS = {
39890
+ resolutions: [
39891
+ "1366;768",
39892
+ "1600;900",
39893
+ "1920;1080",
39894
+ "2560;1440",
39895
+ "3840;2160",
39896
+ "7680;4320"
39897
+ ],
39898
+ weights: [
39899
+ 0.25,
39900
+ 0.15,
39901
+ 0.35,
39902
+ 0.15,
39903
+ 0.08,
39904
+ 0.02
39905
+ ]
39906
+ };
39907
+ }
39908
+ static{
39909
+ this.COLOR_DEPTH_OPTIONS = {
39910
+ values: [
39911
+ 16,
39912
+ 24,
39913
+ 30,
39914
+ 32
39915
+ ],
39916
+ weights: [
39917
+ 0.05,
39918
+ 0.6,
39919
+ 0.05,
39920
+ 0.3
39921
+ ]
39922
+ };
39923
+ }
39924
+ static{
39925
+ this.DEVICE_MEMORY_OPTIONS = {
39926
+ values: [
39927
+ 1,
39928
+ 2,
39929
+ 4,
39930
+ 8,
39931
+ 12,
39932
+ 16
39933
+ ],
39934
+ weights: [
39935
+ 0.10,
39936
+ 0.25,
39937
+ 0.4,
39938
+ 0.2,
39939
+ 0.03,
39940
+ 0.01
39941
+ ]
39942
+ };
39943
+ }
39944
+ static{
39945
+ this.CORE_OPTIONS = {
39946
+ values: [
39947
+ 2,
39948
+ 4,
39949
+ 6,
39950
+ 8,
39951
+ 12,
39952
+ 16,
39953
+ 24,
39954
+ 32
39955
+ ],
39956
+ weights: [
39957
+ 0.1,
39958
+ 0.4,
39959
+ 0.2,
39960
+ 0.15,
39961
+ 0.08,
39962
+ 0.04,
39963
+ 0.02,
39964
+ 0.01
39965
+ ]
39966
+ };
39967
+ }
39968
+ static{
39969
+ this.BROWSER_PLUGINS = "PDF Viewer,Chrome PDF Viewer,Chromium PDF Viewer,Microsoft Edge PDF Viewer,WebKit built-in PDF";
39970
+ }
39971
+ static{
39972
+ this.CANVAS_HASH = "742cc32c";
39973
+ }
39974
+ static{
39975
+ this.VOICE_HASH_OPTIONS = "10311144241322244122";
39976
+ }
39977
+ static{
39978
+ this.FONTS = 'system-ui, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif, BlinkMacSystemFont, "Helvetica Neue", Arial, "PingFang SC", "PingFang TC", "PingFang HK", "Microsoft Yahei", "Microsoft JhengHei"';
39979
+ }
39980
+ }
39981
+ class FingerprintHelpers {
39982
+ static weightedRandomChoice(options, weights) {
39983
+ const totalWeight = weights.reduce((sum, weight)=>sum + weight, 0);
39984
+ let random = Math.random() * totalWeight;
39985
+ for(let i = 0; i < options.length; i++){
39986
+ random -= weights[i];
39987
+ if (random <= 0) return options[i];
39988
+ }
39989
+ return options[options.length - 1];
39990
+ }
39991
+ static getRendererInfo() {
39992
+ const rendererStr = FingerprintData.GPU_VENDORS[Math.floor(Math.random() * FingerprintData.GPU_VENDORS.length)];
39993
+ const [vendor, renderer] = rendererStr.split('|');
39994
+ return {
39995
+ vendor,
39996
+ renderer
39997
+ };
39998
+ }
39999
+ static getScreenConfig() {
40000
+ const resolutionStr = this.weightedRandomChoice(FingerprintData.SCREEN_RESOLUTIONS.resolutions, FingerprintData.SCREEN_RESOLUTIONS.weights);
40001
+ const [widthStr, heightStr] = resolutionStr.split(';');
40002
+ const width = parseInt(widthStr);
40003
+ const height = parseInt(heightStr);
40004
+ let availWidth, availHeight;
40005
+ if (Math.random() > 0.5) {
40006
+ availWidth = width - parseInt(String(this.weightedRandomChoice([
40007
+ 0,
40008
+ 30,
40009
+ 60,
40010
+ 80
40011
+ ], [
40012
+ 0.1,
40013
+ 0.4,
40014
+ 0.3,
40015
+ 0.2
40016
+ ])));
40017
+ availHeight = height;
40018
+ } else {
40019
+ availWidth = width;
40020
+ availHeight = height - parseInt(String(this.weightedRandomChoice([
40021
+ 30,
40022
+ 60,
40023
+ 80,
40024
+ 100
40025
+ ], [
40026
+ 0.2,
40027
+ 0.5,
40028
+ 0.2,
40029
+ 0.1
40030
+ ])));
40031
+ }
40032
+ return {
40033
+ width,
40034
+ height,
40035
+ availWidth,
40036
+ availHeight
40037
+ };
40038
+ }
40039
+ static generateCanvasHash() {
40040
+ return FingerprintData.CANVAS_HASH;
40041
+ }
40042
+ static generateWebglHash() {
40043
+ return external_node_crypto_namespaceObject.createHash('md5').update(external_node_crypto_namespaceObject.randomBytes(32)).digest('hex');
40044
+ }
40045
+ }
40046
+ class ARC4 {
40047
+ constructor(key){
40048
+ this.s = [];
40049
+ for(let i = 0; i < 256; i++)this.s[i] = i;
40050
+ let j = 0;
40051
+ for(let i = 0; i < 256; i++){
40052
+ j = (j + this.s[i] + key[i % key.length]) % 256;
40053
+ [this.s[i], this.s[j]] = [
40054
+ this.s[j],
40055
+ this.s[i]
40056
+ ];
40343
40057
  }
40344
- });
40345
- return success(0 === res.code ? res.data : [], 0 === res.code ? "获取头条号合集成功!" : "获取头条号合集失败!");
40346
- };
40347
- const getToutiaoConfig = async (_task, params)=>{
40348
- const cookies = params.cookies ?? [];
40349
- const http = new Http({
40350
- headers: {
40351
- cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
40352
- referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
40058
+ }
40059
+ encrypt(data) {
40060
+ const result = new Uint8Array(data.length);
40061
+ let i = 0, j = 0;
40062
+ for(let k = 0; k < data.length; k++){
40063
+ i = (i + 1) % 256;
40064
+ j = (j + this.s[i]) % 256;
40065
+ [this.s[i], this.s[j]] = [
40066
+ this.s[j],
40067
+ this.s[i]
40068
+ ];
40069
+ const keyByte = this.s[(this.s[i] + this.s[j]) % 256];
40070
+ result[k] = data[k] ^ keyByte;
40353
40071
  }
40354
- });
40355
- const getSuggestWords = async ()=>{
40356
- try {
40357
- const res = await http.api({
40358
- method: "get",
40359
- url: "https://mp.toutiao.com/mp/agw/creator_helper/suggest_words",
40360
- params: {
40361
- type: 2,
40362
- words: ""
40363
- }
40364
- });
40365
- return 0 === res.code ? res.hots : [];
40366
- } catch (_error) {
40367
- return [];
40072
+ return result;
40073
+ }
40074
+ }
40075
+ class FingerprintGenerator {
40076
+ constructor(){
40077
+ this.config = CryptoConfig;
40078
+ this.b1Key = new TextEncoder().encode("xhswebmplfbt");
40079
+ this.encoder = new Base64Encoder();
40080
+ }
40081
+ generate(cookies, userAgent) {
40082
+ const cookieString = Object.entries(cookies).map(([k, v])=>`${k}=${v}`).join('; ');
40083
+ const screenConfig = FingerprintHelpers.getScreenConfig();
40084
+ const isIncognitoMode = FingerprintHelpers.weightedRandomChoice([
40085
+ "true",
40086
+ "false"
40087
+ ], [
40088
+ 0.95,
40089
+ 0.05
40090
+ ]);
40091
+ const { vendor, renderer } = FingerprintHelpers.getRendererInfo();
40092
+ const x78Y = Math.floor(101 * Math.random()) + 2350;
40093
+ const fp = {
40094
+ x1: userAgent,
40095
+ x2: "false",
40096
+ x3: "zh-CN",
40097
+ x4: String(FingerprintHelpers.weightedRandomChoice(FingerprintData.COLOR_DEPTH_OPTIONS.values, FingerprintData.COLOR_DEPTH_OPTIONS.weights)),
40098
+ x5: String(FingerprintHelpers.weightedRandomChoice(FingerprintData.DEVICE_MEMORY_OPTIONS.values, FingerprintData.DEVICE_MEMORY_OPTIONS.weights)),
40099
+ x6: "24",
40100
+ x7: `${vendor},${renderer}`,
40101
+ x8: String(FingerprintHelpers.weightedRandomChoice(FingerprintData.CORE_OPTIONS.values, FingerprintData.CORE_OPTIONS.weights)),
40102
+ x9: `${screenConfig.width};${screenConfig.height}`,
40103
+ x10: `${screenConfig.availWidth};${screenConfig.availHeight}`,
40104
+ x11: "-480",
40105
+ x12: "Asia/Shanghai",
40106
+ x13: isIncognitoMode,
40107
+ x14: isIncognitoMode,
40108
+ x15: isIncognitoMode,
40109
+ x16: "false",
40110
+ x17: "false",
40111
+ x18: "un",
40112
+ x19: "Win32",
40113
+ x20: "",
40114
+ x21: FingerprintData.BROWSER_PLUGINS,
40115
+ x22: FingerprintHelpers.generateWebglHash(),
40116
+ x23: "false",
40117
+ x24: "false",
40118
+ x25: "false",
40119
+ x26: "false",
40120
+ x27: "false",
40121
+ x28: "0,false,false",
40122
+ x29: "4,7,8",
40123
+ x30: "swf object not loaded",
40124
+ x33: "0",
40125
+ x34: "0",
40126
+ x35: "0",
40127
+ x36: String(Math.floor(20 * Math.random()) + 1),
40128
+ x37: "0|0|0|0|0|0|0|0|0|1|0|0|0|0|0|0|0|0|1|0|0|0|0|0",
40129
+ x38: "0|0|1|0|1|0|0|0|0|0|1|0|1|0|1|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0",
40130
+ x39: 0,
40131
+ x40: "0",
40132
+ x41: "0",
40133
+ x42: "3.4.4",
40134
+ x43: FingerprintHelpers.generateCanvasHash(),
40135
+ x44: String(Math.floor(Date.now())),
40136
+ x45: "__SEC_CAV__1-1-1-1-1|__SEC_WSA__|",
40137
+ x46: "false",
40138
+ x47: "1|0|0|0|0|0",
40139
+ x48: "",
40140
+ x49: "{list:[],type:}",
40141
+ x50: "",
40142
+ x51: "",
40143
+ x52: "",
40144
+ x53: external_node_crypto_namespaceObject.createHash('md5').update(external_node_crypto_namespaceObject.randomBytes(32)).digest('hex'),
40145
+ x54: FingerprintData.VOICE_HASH_OPTIONS,
40146
+ x55: "380,380,360,400,380,400,420,380,400,400,360,360,440,420",
40147
+ x56: `${vendor}|${renderer}|${FingerprintHelpers.generateWebglHash()}|35`,
40148
+ x57: cookieString,
40149
+ x58: "180",
40150
+ x59: "2",
40151
+ x60: "63",
40152
+ x61: "1291",
40153
+ x62: "2047",
40154
+ x63: "0",
40155
+ x64: "0",
40156
+ x65: "0",
40157
+ x66: {
40158
+ referer: "",
40159
+ location: "https://www.xiaohongshu.com/explore",
40160
+ frame: 0
40161
+ },
40162
+ x67: "1|0",
40163
+ x68: "0",
40164
+ x69: "326|1292|30",
40165
+ x70: [
40166
+ "location"
40167
+ ],
40168
+ x71: "true",
40169
+ x72: "complete",
40170
+ x73: "1191",
40171
+ x74: "0|0|0",
40172
+ x75: "Google Inc.",
40173
+ x76: "true",
40174
+ x77: "1|1|1|1|1|1|1|1|1|1",
40175
+ x78: {
40176
+ x: 0,
40177
+ y: x78Y,
40178
+ left: 0,
40179
+ right: 290.828125,
40180
+ bottom: x78Y + 18,
40181
+ height: 18,
40182
+ top: x78Y,
40183
+ width: 290.828125,
40184
+ font: FingerprintData.FONTS
40185
+ },
40186
+ x79: "144|599565058866",
40187
+ x80: "1|[object FileSystemDirectoryHandle]",
40188
+ x31: "124.04347527516074",
40189
+ x82: "_0x17a2|_0x1954"
40190
+ };
40191
+ return fp;
40192
+ }
40193
+ generateB1(fp) {
40194
+ const b1Fp = {
40195
+ x33: fp.x33,
40196
+ x34: fp.x34,
40197
+ x35: fp.x35,
40198
+ x36: fp.x36,
40199
+ x37: fp.x37,
40200
+ x38: fp.x38,
40201
+ x39: fp.x39,
40202
+ x42: fp.x42,
40203
+ x43: fp.x43,
40204
+ x44: fp.x44,
40205
+ x45: fp.x45,
40206
+ x46: fp.x46,
40207
+ x48: fp.x48,
40208
+ x49: fp.x49,
40209
+ x50: fp.x50,
40210
+ x51: fp.x51,
40211
+ x52: fp.x52,
40212
+ x82: fp.x82
40213
+ };
40214
+ const b1Json = JSON.stringify(b1Fp, null, 0).replace(/\s+/g, '');
40215
+ const cipher = new ARC4(this.b1Key);
40216
+ const ciphertext = cipher.encrypt(new TextEncoder().encode(b1Json));
40217
+ let latin1String = '';
40218
+ for(let i = 0; i < ciphertext.length; i++)latin1String += String.fromCharCode(ciphertext[i]);
40219
+ const encodedUrl = encodeURIComponent(latin1String).replace(/[!'()*~_-]/g, (c)=>c);
40220
+ const b = [];
40221
+ const parts = encodedUrl.split('%').slice(1);
40222
+ for (const part of parts){
40223
+ const chars = part.split('');
40224
+ if (chars.length >= 2) {
40225
+ b.push(parseInt(chars.slice(0, 2).join(''), 16));
40226
+ for(let i = 2; i < chars.length; i++)b.push(chars[i].charCodeAt(0));
40227
+ }
40368
40228
  }
40369
- };
40370
- const getCityDistrict = async ()=>{
40371
- try {
40372
- const res = await http.api({
40373
- method: "get",
40374
- url: "https://mp.toutiao.com/toutiao/normandy/mp/city_district/"
40229
+ const b1 = this.encoder.encode(JSON.stringify(b));
40230
+ return b1;
40231
+ }
40232
+ update(fp, cookies, url) {
40233
+ const cookieString = Object.entries(cookies).map(([k, v])=>`${k}=${v}`).join('; ');
40234
+ fp.x39 = 0;
40235
+ fp.x44 = String(Math.floor(Date.now()));
40236
+ fp.x57 = cookieString;
40237
+ fp.x66 = {
40238
+ referer: "https://www.xiaohongshu.com/explore",
40239
+ location: url,
40240
+ frame: 0
40241
+ };
40242
+ }
40243
+ }
40244
+ class XsCommonSigner {
40245
+ constructor(){
40246
+ this.config = CryptoConfig;
40247
+ this.fpGenerator = new FingerprintGenerator();
40248
+ this.encoder = new Base64Encoder();
40249
+ }
40250
+ sign(cookieDict) {
40251
+ if (!cookieDict.a1) throw new Error("Missing 'a1' in cookies");
40252
+ const a1Value = cookieDict.a1;
40253
+ const fingerprint = this.fpGenerator.generate(cookieDict, this.config.PUBLIC_USERAGENT);
40254
+ const b1 = this.fpGenerator.generateB1(fingerprint);
40255
+ const x9 = CRC32.crc32JsInt(b1, true);
40256
+ const signStruct = {
40257
+ s0: 5,
40258
+ s1: "",
40259
+ x0: "1",
40260
+ x1: "4.2.6",
40261
+ x2: "Windows",
40262
+ x3: "xhs-pc-web",
40263
+ x4: "4.86.0",
40264
+ x5: a1Value,
40265
+ x6: "",
40266
+ x7: "",
40267
+ x8: b1,
40268
+ x9: x9,
40269
+ x10: 0,
40270
+ x11: "normal"
40271
+ };
40272
+ const signJson = JSON.stringify(signStruct);
40273
+ return this.encoder.encode(signJson);
40274
+ }
40275
+ }
40276
+ class Xhshow {
40277
+ buildContentString(method, uri, payload = null) {
40278
+ payload = payload || {};
40279
+ if ('POST' === method.toUpperCase()) return uri + JSON.stringify(payload);
40280
+ if (0 === Object.keys(payload).length) return uri;
40281
+ {
40282
+ const params = Object.entries(payload).map(([key, value])=>{
40283
+ let valueStr;
40284
+ valueStr = Array.isArray(value) ? value.map((v)=>String(v)).join(',') : null !== value ? String(value) : '';
40285
+ valueStr = valueStr.replace(/=/g, '%3D');
40286
+ return `${key}=${valueStr}`;
40375
40287
  });
40376
- return 0 === res.status ? res.data : null;
40377
- } catch (_error) {
40378
- return null;
40288
+ return `${uri}?${params.join('&')}`;
40379
40289
  }
40380
- };
40381
- const getUserRights = async ()=>{
40382
- try {
40383
- const res = await http.api({
40384
- method: "get",
40385
- url: "https://mp.toutiao.com/mp/agw/creator_project/get_benefit_page_info"
40290
+ }
40291
+ generateDValue(content) {
40292
+ return external_node_crypto_namespaceObject.createHash('md5').update(content, 'utf-8').digest('hex');
40293
+ }
40294
+ buildSignature(dValue, a1Value, xsecAppid = "xhs-pc-web", stringParam = "", timestamp) {
40295
+ const payloadArray = this.cryptoProcessor.buildPayloadArray(dValue, a1Value, xsecAppid, stringParam, timestamp);
40296
+ const xorResult = this.cryptoProcessor.bitOps.xorTransformArray(payloadArray);
40297
+ return this.cryptoProcessor.b64encoder.encodeX3(xorResult.slice(0, 124));
40298
+ }
40299
+ signXs(method, uri, a1Value, xsecAppid = "xhs-pc-web", payload = null, timestamp) {
40300
+ const validatedMethod = RequestSignatureValidator.validateMethod(method);
40301
+ const validatedUri = RequestSignatureValidator.validateUri(uri);
40302
+ const validatedA1Value = RequestSignatureValidator.validateA1Value(a1Value);
40303
+ const validatedXsecAppid = RequestSignatureValidator.validateXsecAppid(xsecAppid);
40304
+ const validatedPayload = RequestSignatureValidator.validatePayload(payload);
40305
+ const signatureData = JSON.parse(JSON.stringify(this.cryptoProcessor.config.SIGNATURE_DATA_TEMPLATE));
40306
+ const content = this.buildContentString(validatedMethod, validatedUri, validatedPayload);
40307
+ const dValue = this.generateDValue(content);
40308
+ signatureData.x3 = this.cryptoProcessor.config.X3_PREFIX + this.buildSignature(dValue, validatedA1Value, validatedXsecAppid, content, timestamp);
40309
+ const signatureJson = JSON.stringify(signatureData);
40310
+ return this.cryptoProcessor.config.XYS_PREFIX + this.cryptoProcessor.b64encoder.encode(signatureJson);
40311
+ }
40312
+ signXsGet(uri, a1Value, xsecAppid = "xhs-pc-web", params = null, timestamp) {
40313
+ return this.signXs('GET', uri, a1Value, xsecAppid, params, timestamp);
40314
+ }
40315
+ signXsPost(uri, a1Value, xsecAppid = "xhs-pc-web", payload = null, timestamp) {
40316
+ return this.signXs('POST', uri, a1Value, xsecAppid, payload, timestamp);
40317
+ }
40318
+ signXsCommon(cookieDict) {
40319
+ const cookies = this.parseCookies(cookieDict);
40320
+ return this.xsCommonSigner.sign(cookies);
40321
+ }
40322
+ signXsc(cookieDict) {
40323
+ return this.signXsCommon(cookieDict);
40324
+ }
40325
+ parseCookies(cookies) {
40326
+ if ('string' == typeof cookies) {
40327
+ const cookieObj = {};
40328
+ cookies.split(';').forEach((item)=>{
40329
+ const [key, value] = item.trim().split('=');
40330
+ if (key && value) cookieObj[key] = value;
40386
40331
  });
40387
- return 0 === res.code ? res.data.benefit_level_info_list : [];
40388
- } catch (_error) {
40389
- return [];
40390
- }
40391
- };
40392
- const [suggestWords, cityDistrict, userRights] = await Promise.all([
40393
- getSuggestWords(),
40394
- getCityDistrict(),
40395
- getUserRights()
40396
- ]);
40397
- return success({
40398
- suggestWords,
40399
- cityDistrict,
40400
- userRights
40401
- });
40402
- };
40403
- const getWeixinCollection = async (_task, params)=>{
40404
- const http = new Http({
40405
- headers: {
40406
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";")
40407
- }
40408
- });
40409
- const fingerprint = "4695500bc93ab4ce8fb2692da6564e04";
40410
- const res = await http.api({
40411
- method: "get",
40412
- url: "https://mp.weixin.qq.com/cgi-bin/appmsgalbummgr",
40413
- params: {
40414
- action: "list",
40415
- begin: 0,
40416
- count: 100,
40417
- sub_title: "",
40418
- type: 0,
40419
- latest: 1,
40420
- need_pay: 0,
40421
- fingerprint,
40422
- token: params.token,
40423
- lang: "zh_CN",
40424
- f: "json",
40425
- ajax: 1
40426
- }
40427
- });
40428
- return success(res.list_resp?.items ?? [], 0 === res.base_resp.ret ? "微信合计信息获取成功!" : "微信合集信息获取失败!");
40429
- };
40430
- const getWeixinConfig = async (_task, params)=>{
40431
- const http = new Http({
40432
- headers: {
40433
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";")
40332
+ return cookieObj;
40434
40333
  }
40435
- });
40436
- const fingerprint = "4695500bc93ab4ce8fb2692da6564e04";
40437
- const res = await http.api({
40438
- method: "get",
40439
- url: "https://mp.weixin.qq.com/cgi-bin/masssendpage",
40440
- params: {
40441
- f: "json",
40442
- token: params.token,
40443
- lang: "zh_CN",
40444
- ajax: 1,
40445
- fingerprint: fingerprint,
40446
- random: Math.random().toString()
40334
+ return cookies;
40335
+ }
40336
+ signHeaders(method, uri, cookies, xsecAppid = "xhs-pc-web", params, payload, timestamp) {
40337
+ if (void 0 === timestamp) timestamp = Date.now() / 1000;
40338
+ const methodUpper = method.toUpperCase();
40339
+ let requestData = null;
40340
+ if ('GET' === methodUpper) {
40341
+ if (null != payload) throw new Error("GET requests must use 'params', not 'payload'");
40342
+ requestData = params || null;
40343
+ } else if ('POST' === methodUpper) {
40344
+ if (null != params) throw new Error("POST requests must use 'payload', not 'params'");
40345
+ requestData = payload || null;
40346
+ } else throw new Error(`Unsupported method: ${method}`);
40347
+ const cookieDict = this.parseCookies(cookies);
40348
+ const a1Value = cookieDict.a1;
40349
+ if (!a1Value) throw new Error("Missing 'a1' in cookies");
40350
+ const xS = this.signXs(methodUpper, uri, a1Value, xsecAppid, requestData, timestamp);
40351
+ const xSCommon = this.signXsCommon(cookieDict);
40352
+ const xT = this.getXT(timestamp);
40353
+ const xB3Traceid = this.getB3TraceId();
40354
+ const xXrayTraceid = this.getXrayTraceId(Math.floor(1000 * timestamp));
40355
+ return {
40356
+ 'x-s': xS,
40357
+ 'x-s-common': xSCommon,
40358
+ 'x-t': xT.toString(),
40359
+ 'x-b3-traceid': xB3Traceid,
40360
+ 'x-xray-traceid': xXrayTraceid
40361
+ };
40362
+ }
40363
+ signHeadersGet(uri, cookies, xsecAppid = "xhs-pc-web", params, timestamp) {
40364
+ return this.signHeaders('GET', uri, cookies, xsecAppid, params, void 0, timestamp);
40365
+ }
40366
+ signHeadersPost(uri, cookies, xsecAppid = "xhs-pc-web", payload, timestamp) {
40367
+ return this.signHeaders('POST', uri, cookies, xsecAppid, void 0, payload, timestamp);
40368
+ }
40369
+ decodeX3(x3Signature) {
40370
+ if (x3Signature.startsWith(this.cryptoProcessor.config.X3_PREFIX)) x3Signature = x3Signature.substring(this.cryptoProcessor.config.X3_PREFIX.length);
40371
+ const decodedBytes = this.cryptoProcessor.b64encoder.decodeX3(x3Signature);
40372
+ return this.cryptoProcessor.bitOps.xorTransformArray(Array.from(decodedBytes));
40373
+ }
40374
+ decodeXs(xsSignature) {
40375
+ if (xsSignature.startsWith(this.cryptoProcessor.config.XYS_PREFIX)) xsSignature = xsSignature.substring(this.cryptoProcessor.config.XYS_PREFIX.length);
40376
+ const jsonString = this.cryptoProcessor.b64encoder.decode(xsSignature);
40377
+ try {
40378
+ return JSON.parse(jsonString);
40379
+ } catch (e) {
40380
+ throw new Error(`Invalid signature: JSON decode failed - ${e}`);
40447
40381
  }
40448
- });
40449
- const filtered = {
40450
- publishQuota: 0 === res.base_resp.ret ? res.quota_detail_list.filter((item)=>"kQuotaTypeMassSendNormal" === item.quota_type).map((item)=>item.quota_item_list) : []
40451
- };
40452
- return success(filtered, 0 === res.base_resp.ret ? "微信配置信息获取成功!" : "微信配置信息获取失败!");
40453
- };
40382
+ }
40383
+ getB3TraceId() {
40384
+ return this.cryptoProcessor.randomGen.generateB3TraceId();
40385
+ }
40386
+ getXrayTraceId(timestamp, seq) {
40387
+ return this.cryptoProcessor.randomGen.generateXrayTraceId(timestamp, seq);
40388
+ }
40389
+ getXT(timestamp) {
40390
+ if (void 0 === timestamp) timestamp = Date.now() / 1000;
40391
+ return Math.floor(1000 * timestamp);
40392
+ }
40393
+ buildUrl(baseUrl, params) {
40394
+ if (!params || 0 === Object.keys(params).length) return baseUrl;
40395
+ const queryString = Object.entries(params).map(([key, value])=>{
40396
+ const valueStr = Array.isArray(value) ? value.join(',') : String(value);
40397
+ return `${key}=${encodeURIComponent(valueStr)}`;
40398
+ }).join('&');
40399
+ return `${baseUrl}?${queryString}`;
40400
+ }
40401
+ buildJsonBody(payload) {
40402
+ return JSON.stringify(payload);
40403
+ }
40404
+ constructor(){
40405
+ this.cryptoProcessor = new CryptoProcessor();
40406
+ this.xsCommonSigner = new XsCommonSigner();
40407
+ }
40408
+ }
40409
+ new Xhshow();
40454
40410
  const getXhsCollection_xsEncrypt = new Xhshow();
40455
40411
  const CollectionDetailSchema = classic_schemas_object({
40456
40412
  id: classic_schemas_string(),
@@ -52560,4 +52516,4 @@ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_targe
52560
52516
  });
52561
52517
 
52562
52518
  //# sourceMappingURL=bundle.js.map
52563
- //# debugId=fb6eb3b8-9fcc-53e7-9e60-cd649507d5fa
52519
+ //# debugId=999100f4-e52b-5a9b-a84f-9134dd77b21a