@@ -301,12 +301,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
301
301
} ) ;
302
302
} ;
303
303
Object . 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 ;
305
305
const command_1 = __nccwpck_require__ ( 351 ) ;
306
306
const file_command_1 = __nccwpck_require__ ( 717 ) ;
307
307
const utils_1 = __nccwpck_require__ ( 278 ) ;
308
308
const os = __importStar ( __nccwpck_require__ ( 87 ) ) ;
309
309
const path = __importStar ( __nccwpck_require__ ( 622 ) ) ;
310
+ const oidc_utils_1 = __nccwpck_require__ ( 41 ) ;
310
311
/**
311
312
* The code to exit an action
312
313
*/
@@ -575,6 +576,12 @@ function getState(name) {
575
576
return process . env [ `STATE_${ name } ` ] || '' ;
576
577
}
577
578
exports . 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 ;
578
585
//# sourceMappingURL=core.js.map
579
586
580
587
/***/ } ) ,
@@ -628,6 +635,90 @@ exports.issueCommand = issueCommand;
628
635
629
636
/***/ } ) ,
630
637
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
+
631
722
/***/ 278 :
632
723
/***/ ( ( __unused_webpack_module , exports ) => {
633
724
@@ -663,6 +754,7 @@ function toCommandProperties(annotationProperties) {
663
754
}
664
755
return {
665
756
title : annotationProperties . title ,
757
+ file : annotationProperties . file ,
666
758
line : annotationProperties . startLine ,
667
759
endLine : annotationProperties . endLine ,
668
760
col : annotationProperties . startColumn ,
@@ -887,6 +979,72 @@ function getOctokitOptions(token, options) {
887
979
exports . getOctokitOptions = getOctokitOptions ;
888
980
//# sourceMappingURL=utils.js.map
889
981
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
+
890
1048
/***/ } ) ,
891
1049
892
1050
/***/ 925 :
0 commit comments