Spaces:
Paused
Paused
Update index.js
Browse files
index.js
CHANGED
|
@@ -15,7 +15,7 @@ let currentIndex = 0;
|
|
| 15 |
let sessionId = null;
|
| 16 |
const CONFIG = {
|
| 17 |
API: {
|
| 18 |
-
BASE_URL:
|
| 19 |
API_KEY: process.env.API_KEY || "sk-123456",//自定义你自己的认证密钥,记得修改
|
| 20 |
RedisUrl: process.env.RedisUrl,
|
| 21 |
RedisToken: process.env.RedisToken
|
|
@@ -35,9 +35,10 @@ const CONFIG = {
|
|
| 35 |
'mistral-large': 'bedrock-mistral.mistral-large-2407-v1-0'
|
| 36 |
},
|
| 37 |
DEFAULT_HEADERS: {
|
|
|
|
| 38 |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
|
| 39 |
"Cache-Control": "no-cache, no-store",
|
| 40 |
-
"
|
| 41 |
"Accept": "text/event-stream",
|
| 42 |
"Accept-Encoding": "gzip, deflate, br, zstd",
|
| 43 |
"Content-Type": "application/json",
|
|
@@ -98,6 +99,7 @@ class TokenManager {
|
|
| 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) {
|
|
@@ -107,10 +109,10 @@ class TokenManager {
|
|
| 107 |
Tokens[currentIndex].aws_waf_token = wafToken;
|
| 108 |
await this.updateCacheTokens();
|
| 109 |
this.updateRedisTokens();
|
| 110 |
-
currentIndex = (currentIndex + 1) % Tokens.length;
|
| 111 |
console.log("成功提取 aws-waf-token");
|
| 112 |
} else {
|
| 113 |
-
currentIndex = (currentIndex + 1) % Tokens.length;
|
| 114 |
await this.updateCacheTokens();
|
| 115 |
console.log("提取aws-waf-token失败");
|
| 116 |
}
|
|
@@ -127,7 +129,7 @@ class TokenManager {
|
|
| 127 |
this.updateRedisTokens();//最后更新redis数据库缓存,异步
|
| 128 |
console.log("更新缓存完毕");
|
| 129 |
}
|
| 130 |
-
currentIndex = (currentIndex + 1) % Tokens.length;
|
| 131 |
}
|
| 132 |
}
|
| 133 |
}
|
|
|
|
| 15 |
let sessionId = null;
|
| 16 |
const CONFIG = {
|
| 17 |
API: {
|
| 18 |
+
BASE_URL: "https://partyrock.aws/stream/getCompletion",//如果需要多号循环,需要设置你自己的denourl
|
| 19 |
API_KEY: process.env.API_KEY || "sk-123456",//自定义你自己的认证密钥,记得修改
|
| 20 |
RedisUrl: process.env.RedisUrl,
|
| 21 |
RedisToken: process.env.RedisToken
|
|
|
|
| 35 |
'mistral-large': 'bedrock-mistral.mistral-large-2407-v1-0'
|
| 36 |
},
|
| 37 |
DEFAULT_HEADERS: {
|
| 38 |
+
"request-id": "",
|
| 39 |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
|
| 40 |
"Cache-Control": "no-cache, no-store",
|
| 41 |
+
"pragma": "no-cache",
|
| 42 |
"Accept": "text/event-stream",
|
| 43 |
"Accept-Encoding": "gzip, deflate, br, zstd",
|
| 44 |
"Content-Type": "application/json",
|
|
|
|
| 99 |
CONFIG.DEFAULT_HEADERS["anti-csrftoken-a2z"] = Tokens[currentIndex].anti_csrftoken_a2z;
|
| 100 |
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}`;
|
| 101 |
CONFIG.DEFAULT_HEADERS.referer = Tokens[currentIndex].refreshUrl;
|
| 102 |
+
CONFIG.DEFAULT_HEADERS["request-id"] = `request-id-${Utils.uuidv4()}`;
|
| 103 |
}
|
| 104 |
|
| 105 |
async updateTokens(response, isWaf = false) {
|
|
|
|
| 109 |
Tokens[currentIndex].aws_waf_token = wafToken;
|
| 110 |
await this.updateCacheTokens();
|
| 111 |
this.updateRedisTokens();
|
| 112 |
+
//currentIndex = (currentIndex + 1) % Tokens.length;
|
| 113 |
console.log("成功提取 aws-waf-token");
|
| 114 |
} else {
|
| 115 |
+
//currentIndex = (currentIndex + 1) % Tokens.length;
|
| 116 |
await this.updateCacheTokens();
|
| 117 |
console.log("提取aws-waf-token失败");
|
| 118 |
}
|
|
|
|
| 129 |
this.updateRedisTokens();//最后更新redis数据库缓存,异步
|
| 130 |
console.log("更新缓存完毕");
|
| 131 |
}
|
| 132 |
+
//currentIndex = (currentIndex + 1) % Tokens.length;
|
| 133 |
}
|
| 134 |
}
|
| 135 |
}
|