Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
David Corrigan committed May 9, 2024
1 parent 02204f9 commit 3393871
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions jfrog-tasks-utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,24 +195,24 @@ async function getAccessTokenWithOIDForEndpoint(endpoint_name, provider_name, en
const oidcClaims = JSON.parse(Buffer.from(oidcTokenParts[1], 'base64').toString());

// Log the OIDC token claims so users know how to configure AWS
console.log("OIDC Token Subject: ", oidcClaims.sub);
console.log('OIDC Token Subject: ', oidcClaims.sub);
console.log(`OIDC Token Claims: {"sub": "${oidcClaims.sub}"}`);
console.log("OIDC Token Issuer (Provider URL): ", oidcClaims.iss);
console.log("OIDC Token Audience: ", oidcClaims.aud);
console.log('OIDC Token Issuer (Provider URL): ', oidcClaims.iss);
console.log('OIDC Token Audience: ', oidcClaims.aud);

const artifactoryTokenRequestBoth = {
"grant_type": "urn:ietf:params:oauth:grant-type:token-exchange",
"subject_token_type": "urn:ietf:params:oauth:token-type:id_token",
"subject_token": adoToken,
"provider_name": provider_name
grant_type: 'urn:ietf:params:oauth:grant-type:token-exchange',
subject_token_type: 'urn:ietf:params:oauth:token-type:id_token',
subject_token: adoToken,
provider_name: provider_name,
};

let token_server = auth_server ? auth_server : endpoint_server;

let response = await fetch(`${token_server}/access/api/v1/oidc/token`, {
method: 'post',
body: JSON.stringify(artifactoryTokenRequestBoth),
headers: { 'Content-Type': 'application/json' }
headers: { 'Content-Type': 'application/json' },
});
const data = await response.json();
console.log(`JFrog access token acquired, expires in ${(data.expires_in / 60).toFixed(2)} minutes.`);
Expand All @@ -221,12 +221,12 @@ async function getAccessTokenWithOIDForEndpoint(endpoint_name, provider_name, en
}

async function getOidcTokenForEndpoint(endpoint_name) {
const jobId = getVariableRequired("System.JobId");
const planId = getVariableRequired("System.PlanId");
const projectId = getVariableRequired("System.TeamProjectId");
const hub = getVariableRequired("System.HostType");
const uri = getVariableRequired("System.CollectionUri");
const token = getVariableRequired("System.AccessToken");
const jobId = getVariableRequired('System.JobId');
const planId = getVariableRequired('System.PlanId');
const projectId = getVariableRequired('System.TeamProjectId');
const hub = getVariableRequired('System.HostType');
const uri = getVariableRequired('System.CollectionUri');
const token = getVariableRequired('System.AccessToken');

const auth = azNodeLib.getBasicHandler('', token);
const connection = new azNodeLib.WebApi(uri, auth);
Expand All @@ -239,12 +239,12 @@ async function getOidcTokenForEndpoint(endpoint_name) {
}

function getVariableRequired(name) {
const variable = tl.getVariable(name)
const variable = tl.getVariable(name);
if (!variable) {
throw new Error(`Required variable '${name}' returned undefined!`)
throw new Error(`Required variable '${name}' returned undefined!`);
}

return variable
return variable;
}

function generateDownloadCliErrorMessage(downloadUrl, cliVersion) {
Expand Down

0 comments on commit 3393871

Please sign in to comment.