fix ESLint

7fcd40c829b7499ca91b8d3fd83d5b83ff838fd1

InterestingDarkness <computeridiot999@gmail.com>

2 files changed, +15 -15Ignore whitespace
src/endpoints/backends/chat-completions.js+8 -8
@@ -72,7 +72,7 @@ async function generateJWTToken(serviceAccount) {
7272
73 const header = {73 const header = {
74 alg: 'RS256',74 alg: 'RS256',
75 typ: 'JWT'75 typ: 'JWT',
76 };76 };
7777
78 const payload = {78 const payload = {
@@ -80,7 +80,7 @@ async function generateJWTToken(serviceAccount) {
80 scope: 'https://www.googleapis.com/auth/cloud-platform',80 scope: 'https://www.googleapis.com/auth/cloud-platform',
81 aud: 'https://oauth2.googleapis.com/token',81 aud: 'https://oauth2.googleapis.com/token',
82 iat: now,82 iat: now,
83 exp: expiry83 exp: expiry,
84 };84 };
8585
86 const headerBase64 = Buffer.from(JSON.stringify(header)).toString('base64url');86 const headerBase64 = Buffer.from(JSON.stringify(header)).toString('base64url');
@@ -104,12 +104,12 @@ async function getAccessToken(jwtToken) {
104 const response = await fetch('https://oauth2.googleapis.com/token', {104 const response = await fetch('https://oauth2.googleapis.com/token', {
105 method: 'POST',105 method: 'POST',
106 headers: {106 headers: {
107 'Content-Type': 'application/x-www-form-urlencoded'107 'Content-Type': 'application/x-www-form-urlencoded',
108 },108 },
109 body: new URLSearchParams({109 body: new URLSearchParams({
110 grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',110 grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
111 assertion: jwtToken111 assertion: jwtToken,
112 })112 }),
113 });113 });
114114
115 if (!response.ok) {115 if (!response.ok) {
@@ -133,7 +133,7 @@ async function getVertexAIAuth(request) {
133 if (request.body.reverse_proxy) {133 if (request.body.reverse_proxy) {
134 return {134 return {
135 authHeader: `Bearer ${request.body.proxy_password}`,135 authHeader: `Bearer ${request.body.proxy_password}`,
136 authType: 'proxy'136 authType: 'proxy',
137 };137 };
138 }138 }
139139
@@ -143,7 +143,7 @@ async function getVertexAIAuth(request) {
143 if (apiKey) {143 if (apiKey) {
144 return {144 return {
145 authHeader: `Bearer ${apiKey}`,145 authHeader: `Bearer ${apiKey}`,
146 authType: 'express'146 authType: 'express',
147 };147 };
148 }148 }
149 throw new Error('API key is required for Vertex AI Express mode');149 throw new Error('API key is required for Vertex AI Express mode');
@@ -166,7 +166,7 @@ async function getVertexAIAuth(request) {
166166
167 return {167 return {
168 authHeader: `Bearer ${accessToken}`,168 authHeader: `Bearer ${accessToken}`,
169 authType: 'full'169 authType: 'full',
170 };170 };
171 } catch (error) {171 } catch (error) {
172 console.error('Failed to authenticate with service account:', error);172 console.error('Failed to authenticate with service account:', error);
src/endpoints/google.js+7 -7
@@ -17,7 +17,7 @@ async function getVertexAIAuth(request) {
17 if (request.body.reverse_proxy) {17 if (request.body.reverse_proxy) {
18 return {18 return {
19 authHeader: `Bearer ${request.body.proxy_password}`,19 authHeader: `Bearer ${request.body.proxy_password}`,
20 authType: 'proxy'20 authType: 'proxy',
21 };21 };
22 }22 }
2323
@@ -26,7 +26,7 @@ async function getVertexAIAuth(request) {
26 if (apiKey) {26 if (apiKey) {
27 return {27 return {
28 authHeader: `Bearer ${apiKey}`,28 authHeader: `Bearer ${apiKey}`,
29 authType: 'express'29 authType: 'express',
30 };30 };
31 }31 }
32 throw new Error('API key is required for Vertex AI Express mode');32 throw new Error('API key is required for Vertex AI Express mode');
@@ -46,7 +46,7 @@ async function getVertexAIAuth(request) {
46 const accessToken = await getAccessToken(jwtToken);46 const accessToken = await getAccessToken(jwtToken);
47 return {47 return {
48 authHeader: `Bearer ${accessToken}`,48 authHeader: `Bearer ${accessToken}`,
49 authType: 'full'49 authType: 'full',
50 };50 };
51 } catch (error) {51 } catch (error) {
52 console.error('Failed to authenticate with service account:', error);52 console.error('Failed to authenticate with service account:', error);
@@ -70,7 +70,7 @@ async function generateJWTToken(serviceAccount) {
7070
71 const header = {71 const header = {
72 alg: 'RS256',72 alg: 'RS256',
73 typ: 'JWT'73 typ: 'JWT',
74 };74 };
7575
76 const payload = {76 const payload = {
@@ -78,7 +78,7 @@ async function generateJWTToken(serviceAccount) {
78 scope: 'https://www.googleapis.com/auth/cloud-platform',78 scope: 'https://www.googleapis.com/auth/cloud-platform',
79 aud: 'https://oauth2.googleapis.com/token',79 aud: 'https://oauth2.googleapis.com/token',
80 iat: now,80 iat: now,
81 exp: expiry81 exp: expiry,
82 };82 };
8383
84 const headerBase64 = Buffer.from(JSON.stringify(header)).toString('base64url');84 const headerBase64 = Buffer.from(JSON.stringify(header)).toString('base64url');
@@ -99,8 +99,8 @@ async function getAccessToken(jwtToken) {
99 headers: { 'Content-Type': 'application/x-www-form-urlencoded' },99 headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
100 body: new URLSearchParams({100 body: new URLSearchParams({
101 grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',101 grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
102 assertion: jwtToken102 assertion: jwtToken,
103 })103 }),
104 });104 });
105105
106 if (!response.ok) {106 if (!response.ok) {