Spaces:
Paused
Paused
Update index.js
Browse files
index.js
CHANGED
|
@@ -97,7 +97,7 @@ class TokenManager {
|
|
| 97 |
sessionId = Utils.uuidv4();
|
| 98 |
CONFIG.DEFAULT_HEADERS["anti-csrftoken-a2z"] = Tokens[currentIndex].anti_csrftoken_a2z;
|
| 99 |
CONFIG.DEFAULT_HEADERS.Cookie = `idToken=${Tokens[currentIndex].idToken}; pr_refresh_token=${Tokens[currentIndex].pr_refresh_token};aws-waf-token=${Tokens[currentIndex].aws_waf_token};cwr_s=${Tokens[currentIndex].cwr_s};cwr_u=${sessionId}`;
|
| 100 |
-
CONFIG.DEFAULT_HEADERS.referer = Tokens[currentIndex].
|
| 101 |
}
|
| 102 |
|
| 103 |
async updateTokens(response, isWaf = false) {
|
|
@@ -167,7 +167,7 @@ class Utils {
|
|
| 167 |
await page.setUserAgent(
|
| 168 |
CONFIG.DEFAULT_HEADERS["User-Agent"]
|
| 169 |
)
|
| 170 |
-
await page.goto(Tokens[currentIndex].
|
| 171 |
waitUntil: 'networkidle2',
|
| 172 |
timeout: 30000
|
| 173 |
});
|
|
@@ -252,7 +252,7 @@ async function initializeService() {
|
|
| 252 |
? JSON.parse(checkRedis)
|
| 253 |
: checkRedis;
|
| 254 |
Tokens.push({
|
| 255 |
-
|
| 256 |
anti_csrftoken_a2z: parsedRedis.anti_csrftoken_a2z,
|
| 257 |
pr_refresh_token: parsedRedis.pr_refresh_token,
|
| 258 |
aws_waf_token: parsedRedis.aws_waf_token,
|
|
@@ -265,18 +265,18 @@ async function initializeService() {
|
|
| 265 |
}
|
| 266 |
} else {
|
| 267 |
console.log(index, '没有缓存,开始提取环境变量');
|
| 268 |
-
const
|
| 269 |
const anti_csrftoken_a2z = process.env[`AUTH_TOKENS_${index}_ANTI_CSRF_TOKEN`];
|
| 270 |
const cookie = process.env[`AUTH_TOKENS_${index}_COOKIE`];
|
| 271 |
|
| 272 |
-
if (!
|
| 273 |
break;
|
| 274 |
}
|
| 275 |
const cookies = await Utils.extractTokens(cookie);
|
| 276 |
|
| 277 |
-
if (
|
| 278 |
Tokens.push({
|
| 279 |
-
|
| 280 |
anti_csrftoken_a2z,
|
| 281 |
pr_refresh_token: cookies["pr_refresh_token"],
|
| 282 |
aws_waf_token: cookies["aws-waf-token"],
|
|
|
|
| 97 |
sessionId = Utils.uuidv4();
|
| 98 |
CONFIG.DEFAULT_HEADERS["anti-csrftoken-a2z"] = Tokens[currentIndex].anti_csrftoken_a2z;
|
| 99 |
CONFIG.DEFAULT_HEADERS.Cookie = `idToken=${Tokens[currentIndex].idToken}; pr_refresh_token=${Tokens[currentIndex].pr_refresh_token};aws-waf-token=${Tokens[currentIndex].aws_waf_token};cwr_s=${Tokens[currentIndex].cwr_s};cwr_u=${sessionId}`;
|
| 100 |
+
CONFIG.DEFAULT_HEADERS.referer = Tokens[currentIndex].refreshUrl;
|
| 101 |
}
|
| 102 |
|
| 103 |
async updateTokens(response, isWaf = false) {
|
|
|
|
| 167 |
await page.setUserAgent(
|
| 168 |
CONFIG.DEFAULT_HEADERS["User-Agent"]
|
| 169 |
)
|
| 170 |
+
await page.goto(Tokens[currentIndex].refreshUrl, {
|
| 171 |
waitUntil: 'networkidle2',
|
| 172 |
timeout: 30000
|
| 173 |
});
|
|
|
|
| 252 |
? JSON.parse(checkRedis)
|
| 253 |
: checkRedis;
|
| 254 |
Tokens.push({
|
| 255 |
+
refreshUrl: parsedRedis.refreshUrl,
|
| 256 |
anti_csrftoken_a2z: parsedRedis.anti_csrftoken_a2z,
|
| 257 |
pr_refresh_token: parsedRedis.pr_refresh_token,
|
| 258 |
aws_waf_token: parsedRedis.aws_waf_token,
|
|
|
|
| 265 |
}
|
| 266 |
} else {
|
| 267 |
console.log(index, '没有缓存,开始提取环境变量');
|
| 268 |
+
const refreshUrl = process.env[`AUTH_TOKENS_${index}_REFRESH_URL`];
|
| 269 |
const anti_csrftoken_a2z = process.env[`AUTH_TOKENS_${index}_ANTI_CSRF_TOKEN`];
|
| 270 |
const cookie = process.env[`AUTH_TOKENS_${index}_COOKIE`];
|
| 271 |
|
| 272 |
+
if (!refreshUrl && !anti_csrftoken_a2z && !cookie) {
|
| 273 |
break;
|
| 274 |
}
|
| 275 |
const cookies = await Utils.extractTokens(cookie);
|
| 276 |
|
| 277 |
+
if (refreshUrl && anti_csrftoken_a2z && cookie) {
|
| 278 |
Tokens.push({
|
| 279 |
+
refreshUrl,
|
| 280 |
anti_csrftoken_a2z,
|
| 281 |
pr_refresh_token: cookies["pr_refresh_token"],
|
| 282 |
aws_waf_token: cookies["aws-waf-token"],
|