diff --git a/packages/core/README.md b/packages/core/README.md index ac75489d..827805da 100644 --- a/packages/core/README.md +++ b/packages/core/README.md @@ -227,11 +227,8 @@ In action's `main.ts`: const core = require('@actions/core'); async function getIDTokenAction(): Promise { - let aud = '' const audience = core.getInput('audience', {required: false}) - if (audience !== undefined) - aud = `${audience}` - const id_token = await core.getIDToken(aud) + const id_token = await core.getIDToken(audience) core.setOutput('id_token', id_token) } diff --git a/packages/core/src/oidc-utils.ts b/packages/core/src/oidc-utils.ts index c92e6ae2..413ab4d0 100644 --- a/packages/core/src/oidc-utils.ts +++ b/packages/core/src/oidc-utils.ts @@ -15,9 +15,11 @@ interface TokenResponse { export class OidcClient { private static createHttpClient(allowRetry = true, maxRetry = 10) { - let requestOptions : IRequestOptions = {} - requestOptions.allowRetries = allowRetry - requestOptions.maxRetries = maxRetry + let requestOptions : IRequestOptions = { + allowRetries: allowRetry, + maxRetries: maxRetry + } + return new HttpClient('actions/oidc-client', [ new BearerCredentialHandler(OidcClient.getRuntimeToken())], requestOptions) @@ -45,7 +47,7 @@ export class OidcClient { private static async postCall(httpclient: actions_http_client.HttpClient, id_token_url: string, audience: string): Promise { - const data :TokenRequest = { aud: !!audience ? audience : ''} + const data: TokenRequest = { aud: audience } debug(`audience is ${!!audience ? audience : 'not defined'}`)