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