@@ -301,12 +301,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
301301 } ) ;
302302} ;
303303Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
304- exports . getState = exports . saveState = exports . group = exports . endGroup = exports . startGroup = exports . info = exports . notice = exports . warning = exports . error = exports . debug = exports . isDebug = exports . setFailed = exports . setCommandEcho = exports . setOutput = exports . getBooleanInput = exports . getMultilineInput = exports . getInput = exports . addPath = exports . setSecret = exports . exportVariable = exports . ExitCode = void 0 ;
304+ exports . getIDToken = exports . getState = exports . saveState = exports . group = exports . endGroup = exports . startGroup = exports . info = exports . notice = exports . warning = exports . error = exports . debug = exports . isDebug = exports . setFailed = exports . setCommandEcho = exports . setOutput = exports . getBooleanInput = exports . getMultilineInput = exports . getInput = exports . addPath = exports . setSecret = exports . exportVariable = exports . ExitCode = void 0 ;
305305const command_1 = __nccwpck_require__ ( 351 ) ;
306306const file_command_1 = __nccwpck_require__ ( 717 ) ;
307307const utils_1 = __nccwpck_require__ ( 278 ) ;
308308const os = __importStar ( __nccwpck_require__ ( 87 ) ) ;
309309const path = __importStar ( __nccwpck_require__ ( 622 ) ) ;
310+ const oidc_utils_1 = __nccwpck_require__ ( 41 ) ;
310311/**
311312 * The code to exit an action
312313 */
@@ -575,6 +576,12 @@ function getState(name) {
575576 return process . env [ `STATE_${ name } ` ] || '' ;
576577}
577578exports . getState = getState ;
579+ function getIDToken ( aud ) {
580+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
581+ return yield oidc_utils_1 . OidcClient . getIDToken ( aud ) ;
582+ } ) ;
583+ }
584+ exports . getIDToken = getIDToken ;
578585//# sourceMappingURL=core.js.map
579586
580587/***/ } ) ,
@@ -628,6 +635,90 @@ exports.issueCommand = issueCommand;
628635
629636/***/ } ) ,
630637
638+ /***/ 41 :
639+ /***/ ( function ( __unused_webpack_module , exports , __nccwpck_require__ ) {
640+
641+ "use strict" ;
642+
643+ var __awaiter = ( this && this . __awaiter ) || function ( thisArg , _arguments , P , generator ) {
644+ function adopt ( value ) { return value instanceof P ? value : new P ( function ( resolve ) { resolve ( value ) ; } ) ; }
645+ return new ( P || ( P = Promise ) ) ( function ( resolve , reject ) {
646+ function fulfilled ( value ) { try { step ( generator . next ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
647+ function rejected ( value ) { try { step ( generator [ "throw" ] ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
648+ function step ( result ) { result . done ? resolve ( result . value ) : adopt ( result . value ) . then ( fulfilled , rejected ) ; }
649+ step ( ( generator = generator . apply ( thisArg , _arguments || [ ] ) ) . next ( ) ) ;
650+ } ) ;
651+ } ;
652+ Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
653+ exports . OidcClient = void 0 ;
654+ const http_client_1 = __nccwpck_require__ ( 925 ) ;
655+ const auth_1 = __nccwpck_require__ ( 702 ) ;
656+ const core_1 = __nccwpck_require__ ( 186 ) ;
657+ class OidcClient {
658+ static createHttpClient ( allowRetry = true , maxRetry = 10 ) {
659+ const requestOptions = {
660+ allowRetries : allowRetry ,
661+ maxRetries : maxRetry
662+ } ;
663+ return new http_client_1 . HttpClient ( 'actions/oidc-client' , [ new auth_1 . BearerCredentialHandler ( OidcClient . getRequestToken ( ) ) ] , requestOptions ) ;
664+ }
665+ static getRequestToken ( ) {
666+ const token = process . env [ 'ACTIONS_ID_TOKEN_REQUEST_TOKEN' ] ;
667+ if ( ! token ) {
668+ throw new Error ( 'Unable to get ACTIONS_ID_TOKEN_REQUEST_TOKEN env variable' ) ;
669+ }
670+ return token ;
671+ }
672+ static getIDTokenUrl ( ) {
673+ const runtimeUrl = process . env [ 'ACTIONS_ID_TOKEN_REQUEST_URL' ] ;
674+ if ( ! runtimeUrl ) {
675+ throw new Error ( 'Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable' ) ;
676+ }
677+ return runtimeUrl ;
678+ }
679+ static getCall ( id_token_url ) {
680+ var _a ;
681+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
682+ const httpclient = OidcClient . createHttpClient ( ) ;
683+ const res = yield httpclient
684+ . getJson ( id_token_url )
685+ . catch ( error => {
686+ throw new Error ( `Failed to get ID Token. \n
687+ Error Code : ${ error . statusCode } \n
688+ Error Message: ${ error . result . message } ` ) ;
689+ } ) ;
690+ const id_token = ( _a = res . result ) === null || _a === void 0 ? void 0 : _a . value ;
691+ if ( ! id_token ) {
692+ throw new Error ( 'Response json body do not have ID Token field' ) ;
693+ }
694+ return id_token ;
695+ } ) ;
696+ }
697+ static getIDToken ( audience ) {
698+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
699+ try {
700+ // New ID Token is requested from action service
701+ let id_token_url = OidcClient . getIDTokenUrl ( ) ;
702+ if ( audience ) {
703+ const encodedAudience = encodeURIComponent ( audience ) ;
704+ id_token_url = `${ id_token_url } &audience=${ encodedAudience } ` ;
705+ }
706+ core_1 . debug ( `ID token url is ${ id_token_url } ` ) ;
707+ const id_token = yield OidcClient . getCall ( id_token_url ) ;
708+ core_1 . setSecret ( id_token ) ;
709+ return id_token ;
710+ }
711+ catch ( error ) {
712+ throw new Error ( `Error message: ${ error . message } ` ) ;
713+ }
714+ } ) ;
715+ }
716+ }
717+ exports . OidcClient = OidcClient ;
718+ //# sourceMappingURL=oidc-utils.js.map
719+
720+ /***/ } ) ,
721+
631722/***/ 278 :
632723/***/ ( ( __unused_webpack_module , exports ) => {
633724
@@ -663,6 +754,7 @@ function toCommandProperties(annotationProperties) {
663754 }
664755 return {
665756 title : annotationProperties . title ,
757+ file : annotationProperties . file ,
666758 line : annotationProperties . startLine ,
667759 endLine : annotationProperties . endLine ,
668760 col : annotationProperties . startColumn ,
@@ -887,6 +979,72 @@ function getOctokitOptions(token, options) {
887979exports . getOctokitOptions = getOctokitOptions ;
888980//# sourceMappingURL=utils.js.map
889981
982+ /***/ } ) ,
983+
984+ /***/ 702 :
985+ /***/ ( ( __unused_webpack_module , exports ) => {
986+
987+ "use strict" ;
988+
989+ Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
990+ class BasicCredentialHandler {
991+ constructor ( username , password ) {
992+ this . username = username ;
993+ this . password = password ;
994+ }
995+ prepareRequest ( options ) {
996+ options . headers [ 'Authorization' ] =
997+ 'Basic ' +
998+ Buffer . from ( this . username + ':' + this . password ) . toString ( 'base64' ) ;
999+ }
1000+ // This handler cannot handle 401
1001+ canHandleAuthentication ( response ) {
1002+ return false ;
1003+ }
1004+ handleAuthentication ( httpClient , requestInfo , objs ) {
1005+ return null ;
1006+ }
1007+ }
1008+ exports . BasicCredentialHandler = BasicCredentialHandler ;
1009+ class BearerCredentialHandler {
1010+ constructor ( token ) {
1011+ this . token = token ;
1012+ }
1013+ // currently implements pre-authorization
1014+ // TODO: support preAuth = false where it hooks on 401
1015+ prepareRequest ( options ) {
1016+ options . headers [ 'Authorization' ] = 'Bearer ' + this . token ;
1017+ }
1018+ // This handler cannot handle 401
1019+ canHandleAuthentication ( response ) {
1020+ return false ;
1021+ }
1022+ handleAuthentication ( httpClient , requestInfo , objs ) {
1023+ return null ;
1024+ }
1025+ }
1026+ exports . BearerCredentialHandler = BearerCredentialHandler ;
1027+ class PersonalAccessTokenCredentialHandler {
1028+ constructor ( token ) {
1029+ this . token = token ;
1030+ }
1031+ // currently implements pre-authorization
1032+ // TODO: support preAuth = false where it hooks on 401
1033+ prepareRequest ( options ) {
1034+ options . headers [ 'Authorization' ] =
1035+ 'Basic ' + Buffer . from ( 'PAT:' + this . token ) . toString ( 'base64' ) ;
1036+ }
1037+ // This handler cannot handle 401
1038+ canHandleAuthentication ( response ) {
1039+ return false ;
1040+ }
1041+ handleAuthentication ( httpClient , requestInfo , objs ) {
1042+ return null ;
1043+ }
1044+ }
1045+ exports . PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler ;
1046+
1047+
8901048/***/ } ) ,
8911049
8921050/***/ 925 :
0 commit comments