Moved oidc functionality to actions/core

This commit is contained in:
Sourav Chanduka
2021-08-04 09:24:51 +05:30
parent 5afccaa9db
commit 9c6e7d8265
18 changed files with 170 additions and 17027 deletions
+19
View File
@@ -5,6 +5,8 @@ import {toCommandValue} from './utils'
import * as os from 'os'
import * as path from 'path'
import {getIDTokenUrl, parseJson, postCall} from './oidc-utils'
/**
* Interface for getInput options
*/
@@ -284,3 +286,20 @@ export function saveState(name: string, value: any): void {
export function getState(name: string): string {
return process.env[`STATE_${name}`] || ''
}
export async function getIDToken(audience: string): Promise<string> {
try {
// New ID Token is requested from action service
let id_token_url: string = getIDTokenUrl()
debug(`ID token url is ${id_token_url}`)
let body: string = await postCall(id_token_url, audience)
let id_token = parseJson(body)
return id_token
} catch (error) {
setFailed(error.message)
return error.message
}
}