mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
fix ESLint
This commit is contained in:
@@ -72,7 +72,7 @@ async function generateJWTToken(serviceAccount) {
|
|||||||
|
|
||||||
const header = {
|
const header = {
|
||||||
alg: 'RS256',
|
alg: 'RS256',
|
||||||
typ: 'JWT'
|
typ: 'JWT',
|
||||||
};
|
};
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
@@ -80,7 +80,7 @@ async function generateJWTToken(serviceAccount) {
|
|||||||
scope: 'https://www.googleapis.com/auth/cloud-platform',
|
scope: 'https://www.googleapis.com/auth/cloud-platform',
|
||||||
aud: 'https://oauth2.googleapis.com/token',
|
aud: 'https://oauth2.googleapis.com/token',
|
||||||
iat: now,
|
iat: now,
|
||||||
exp: expiry
|
exp: expiry,
|
||||||
};
|
};
|
||||||
|
|
||||||
const headerBase64 = Buffer.from(JSON.stringify(header)).toString('base64url');
|
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', {
|
const response = await fetch('https://oauth2.googleapis.com/token', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
},
|
},
|
||||||
body: new URLSearchParams({
|
body: new URLSearchParams({
|
||||||
grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
|
grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
|
||||||
assertion: jwtToken
|
assertion: jwtToken,
|
||||||
})
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
@@ -133,7 +133,7 @@ async function getVertexAIAuth(request) {
|
|||||||
if (request.body.reverse_proxy) {
|
if (request.body.reverse_proxy) {
|
||||||
return {
|
return {
|
||||||
authHeader: `Bearer ${request.body.proxy_password}`,
|
authHeader: `Bearer ${request.body.proxy_password}`,
|
||||||
authType: 'proxy'
|
authType: 'proxy',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ async function getVertexAIAuth(request) {
|
|||||||
if (apiKey) {
|
if (apiKey) {
|
||||||
return {
|
return {
|
||||||
authHeader: `Bearer ${apiKey}`,
|
authHeader: `Bearer ${apiKey}`,
|
||||||
authType: 'express'
|
authType: 'express',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
throw new Error('API key is required for Vertex AI Express mode');
|
throw new Error('API key is required for Vertex AI Express mode');
|
||||||
@@ -166,7 +166,7 @@ async function getVertexAIAuth(request) {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
authHeader: `Bearer ${accessToken}`,
|
authHeader: `Bearer ${accessToken}`,
|
||||||
authType: 'full'
|
authType: 'full',
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to authenticate with service account:', error);
|
console.error('Failed to authenticate with service account:', error);
|
||||||
|
@@ -17,7 +17,7 @@ async function getVertexAIAuth(request) {
|
|||||||
if (request.body.reverse_proxy) {
|
if (request.body.reverse_proxy) {
|
||||||
return {
|
return {
|
||||||
authHeader: `Bearer ${request.body.proxy_password}`,
|
authHeader: `Bearer ${request.body.proxy_password}`,
|
||||||
authType: 'proxy'
|
authType: 'proxy',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ async function getVertexAIAuth(request) {
|
|||||||
if (apiKey) {
|
if (apiKey) {
|
||||||
return {
|
return {
|
||||||
authHeader: `Bearer ${apiKey}`,
|
authHeader: `Bearer ${apiKey}`,
|
||||||
authType: 'express'
|
authType: 'express',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
throw new Error('API key is required for Vertex AI Express mode');
|
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);
|
const accessToken = await getAccessToken(jwtToken);
|
||||||
return {
|
return {
|
||||||
authHeader: `Bearer ${accessToken}`,
|
authHeader: `Bearer ${accessToken}`,
|
||||||
authType: 'full'
|
authType: 'full',
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to authenticate with service account:', error);
|
console.error('Failed to authenticate with service account:', error);
|
||||||
@@ -70,7 +70,7 @@ async function generateJWTToken(serviceAccount) {
|
|||||||
|
|
||||||
const header = {
|
const header = {
|
||||||
alg: 'RS256',
|
alg: 'RS256',
|
||||||
typ: 'JWT'
|
typ: 'JWT',
|
||||||
};
|
};
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
@@ -78,7 +78,7 @@ async function generateJWTToken(serviceAccount) {
|
|||||||
scope: 'https://www.googleapis.com/auth/cloud-platform',
|
scope: 'https://www.googleapis.com/auth/cloud-platform',
|
||||||
aud: 'https://oauth2.googleapis.com/token',
|
aud: 'https://oauth2.googleapis.com/token',
|
||||||
iat: now,
|
iat: now,
|
||||||
exp: expiry
|
exp: expiry,
|
||||||
};
|
};
|
||||||
|
|
||||||
const headerBase64 = Buffer.from(JSON.stringify(header)).toString('base64url');
|
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' },
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||||
body: new URLSearchParams({
|
body: new URLSearchParams({
|
||||||
grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
|
grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
|
||||||
assertion: jwtToken
|
assertion: jwtToken,
|
||||||
})
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
Reference in New Issue
Block a user