From 7fcd40c829b7499ca91b8d3fd83d5b83ff838fd1 Mon Sep 17 00:00:00 2001 From: InterestingDarkness Date: Mon, 26 May 2025 22:16:36 +0800 Subject: [PATCH] fix ESLint --- src/endpoints/backends/chat-completions.js | 16 ++++++++-------- src/endpoints/google.js | 14 +++++++------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/endpoints/backends/chat-completions.js b/src/endpoints/backends/chat-completions.js index 38d420c6b..7c340ace8 100644 --- a/src/endpoints/backends/chat-completions.js +++ b/src/endpoints/backends/chat-completions.js @@ -72,7 +72,7 @@ async function generateJWTToken(serviceAccount) { const header = { alg: 'RS256', - typ: 'JWT' + typ: 'JWT', }; const payload = { @@ -80,7 +80,7 @@ async function generateJWTToken(serviceAccount) { scope: 'https://www.googleapis.com/auth/cloud-platform', aud: 'https://oauth2.googleapis.com/token', iat: now, - exp: expiry + exp: expiry, }; const headerBase64 = Buffer.from(JSON.stringify(header)).toString('base64url'); @@ -104,12 +104,12 @@ async function getAccessToken(jwtToken) { const response = await fetch('https://oauth2.googleapis.com/token', { method: 'POST', headers: { - 'Content-Type': 'application/x-www-form-urlencoded' + 'Content-Type': 'application/x-www-form-urlencoded', }, body: new URLSearchParams({ grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer', - assertion: jwtToken - }) + assertion: jwtToken, + }), }); if (!response.ok) { @@ -133,7 +133,7 @@ async function getVertexAIAuth(request) { if (request.body.reverse_proxy) { return { authHeader: `Bearer ${request.body.proxy_password}`, - authType: 'proxy' + authType: 'proxy', }; } @@ -143,7 +143,7 @@ async function getVertexAIAuth(request) { if (apiKey) { return { authHeader: `Bearer ${apiKey}`, - authType: 'express' + authType: 'express', }; } throw new Error('API key is required for Vertex AI Express mode'); @@ -166,7 +166,7 @@ async function getVertexAIAuth(request) { return { authHeader: `Bearer ${accessToken}`, - authType: 'full' + authType: 'full', }; } catch (error) { console.error('Failed to authenticate with service account:', error); diff --git a/src/endpoints/google.js b/src/endpoints/google.js index 950abed44..a42e15af7 100644 --- a/src/endpoints/google.js +++ b/src/endpoints/google.js @@ -17,7 +17,7 @@ async function getVertexAIAuth(request) { if (request.body.reverse_proxy) { return { authHeader: `Bearer ${request.body.proxy_password}`, - authType: 'proxy' + authType: 'proxy', }; } @@ -26,7 +26,7 @@ async function getVertexAIAuth(request) { if (apiKey) { return { authHeader: `Bearer ${apiKey}`, - authType: 'express' + authType: 'express', }; } throw new Error('API key is required for Vertex AI Express mode'); @@ -46,7 +46,7 @@ async function getVertexAIAuth(request) { const accessToken = await getAccessToken(jwtToken); return { authHeader: `Bearer ${accessToken}`, - authType: 'full' + authType: 'full', }; } catch (error) { console.error('Failed to authenticate with service account:', error); @@ -70,7 +70,7 @@ async function generateJWTToken(serviceAccount) { const header = { alg: 'RS256', - typ: 'JWT' + typ: 'JWT', }; const payload = { @@ -78,7 +78,7 @@ async function generateJWTToken(serviceAccount) { scope: 'https://www.googleapis.com/auth/cloud-platform', aud: 'https://oauth2.googleapis.com/token', iat: now, - exp: expiry + exp: expiry, }; const headerBase64 = Buffer.from(JSON.stringify(header)).toString('base64url'); @@ -99,8 +99,8 @@ async function getAccessToken(jwtToken) { headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: new URLSearchParams({ grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer', - assertion: jwtToken - }) + assertion: jwtToken, + }), }); if (!response.ok) {