@@ -1585,6 +1585,90 @@ module.exports.parseURL = function (input, options) {
1585
1585
};
1586
1586
1587
1587
1588
+ /***/ }),
1589
+
1590
+ /***/ 41:
1591
+ /***/ (function(__unusedmodule, exports, __webpack_require__) {
1592
+
1593
+ "use strict";
1594
+
1595
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
1596
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
1597
+ return new (P || (P = Promise))(function (resolve, reject) {
1598
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
1599
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
1600
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
1601
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
1602
+ });
1603
+ };
1604
+ Object.defineProperty(exports, "__esModule", { value: true });
1605
+ exports.OidcClient = void 0;
1606
+ const http_client_1 = __webpack_require__(925);
1607
+ const auth_1 = __webpack_require__(702);
1608
+ const core_1 = __webpack_require__(186);
1609
+ class OidcClient {
1610
+ static createHttpClient(allowRetry = true, maxRetry = 10) {
1611
+ const requestOptions = {
1612
+ allowRetries: allowRetry,
1613
+ maxRetries: maxRetry
1614
+ };
1615
+ return new http_client_1.HttpClient('actions/oidc-client', [new auth_1.BearerCredentialHandler(OidcClient.getRequestToken())], requestOptions);
1616
+ }
1617
+ static getRequestToken() {
1618
+ const token = process.env['ACTIONS_ID_TOKEN_REQUEST_TOKEN'];
1619
+ if (!token) {
1620
+ throw new Error('Unable to get ACTIONS_ID_TOKEN_REQUEST_TOKEN env variable');
1621
+ }
1622
+ return token;
1623
+ }
1624
+ static getIDTokenUrl() {
1625
+ const runtimeUrl = process.env['ACTIONS_ID_TOKEN_REQUEST_URL'];
1626
+ if (!runtimeUrl) {
1627
+ throw new Error('Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable');
1628
+ }
1629
+ return runtimeUrl;
1630
+ }
1631
+ static getCall(id_token_url) {
1632
+ var _a;
1633
+ return __awaiter(this, void 0, void 0, function* () {
1634
+ const httpclient = OidcClient.createHttpClient();
1635
+ const res = yield httpclient
1636
+ .getJson(id_token_url)
1637
+ .catch(error => {
1638
+ throw new Error(`Failed to get ID Token. \n
1639
+ Error Code : ${error.statusCode}\n
1640
+ Error Message: ${error.result.message}`);
1641
+ });
1642
+ const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value;
1643
+ if (!id_token) {
1644
+ throw new Error('Response json body do not have ID Token field');
1645
+ }
1646
+ return id_token;
1647
+ });
1648
+ }
1649
+ static getIDToken(audience) {
1650
+ return __awaiter(this, void 0, void 0, function* () {
1651
+ try {
1652
+ // New ID Token is requested from action service
1653
+ let id_token_url = OidcClient.getIDTokenUrl();
1654
+ if (audience) {
1655
+ const encodedAudience = encodeURIComponent(audience);
1656
+ id_token_url = `${id_token_url}&audience=${encodedAudience}`;
1657
+ }
1658
+ core_1.debug(`ID token url is ${id_token_url}`);
1659
+ const id_token = yield OidcClient.getCall(id_token_url);
1660
+ core_1.setSecret(id_token);
1661
+ return id_token;
1662
+ }
1663
+ catch (error) {
1664
+ throw new Error(`Error message: ${error.message}`);
1665
+ }
1666
+ });
1667
+ }
1668
+ }
1669
+ exports.OidcClient = OidcClient;
1670
+ //# sourceMappingURL=oidc-utils.js.map
1671
+
1588
1672
/***/ }),
1589
1673
1590
1674
/***/ 44:
@@ -3448,12 +3532,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
3448
3532
});
3449
3533
};
3450
3534
Object.defineProperty(exports, "__esModule", { value: true });
3451
- 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;
3535
+ 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;
3452
3536
const command_1 = __webpack_require__(351);
3453
3537
const file_command_1 = __webpack_require__(717);
3454
3538
const utils_1 = __webpack_require__(278);
3455
3539
const os = __importStar(__webpack_require__(87));
3456
3540
const path = __importStar(__webpack_require__(622));
3541
+ const oidc_utils_1 = __webpack_require__(41);
3457
3542
/**
3458
3543
* The code to exit an action
3459
3544
*/
@@ -3722,6 +3807,12 @@ function getState(name) {
3722
3807
return process.env[`STATE_${name}`] || '';
3723
3808
}
3724
3809
exports.getState = getState;
3810
+ function getIDToken(aud) {
3811
+ return __awaiter(this, void 0, void 0, function* () {
3812
+ return yield oidc_utils_1.OidcClient.getIDToken(aud);
3813
+ });
3814
+ }
3815
+ exports.getIDToken = getIDToken;
3725
3816
//# sourceMappingURL=core.js.map
3726
3817
3727
3818
/***/ }),
@@ -4855,6 +4946,7 @@ function toCommandProperties(annotationProperties) {
4855
4946
}
4856
4947
return {
4857
4948
title: annotationProperties.title,
4949
+ file: annotationProperties.file,
4858
4950
line: annotationProperties.startLine,
4859
4951
endLine: annotationProperties.endLine,
4860
4952
col: annotationProperties.startColumn,
@@ -9274,6 +9366,72 @@ module.exports.Singular = Hook.Singular
9274
9366
module.exports.Collection = Hook.Collection
9275
9367
9276
9368
9369
+ /***/ }),
9370
+
9371
+ /***/ 702:
9372
+ /***/ (function(__unusedmodule, exports) {
9373
+
9374
+ "use strict";
9375
+
9376
+ Object.defineProperty(exports, "__esModule", { value: true });
9377
+ class BasicCredentialHandler {
9378
+ constructor(username, password) {
9379
+ this.username = username;
9380
+ this.password = password;
9381
+ }
9382
+ prepareRequest(options) {
9383
+ options.headers['Authorization'] =
9384
+ 'Basic ' +
9385
+ Buffer.from(this.username + ':' + this.password).toString('base64');
9386
+ }
9387
+ // This handler cannot handle 401
9388
+ canHandleAuthentication(response) {
9389
+ return false;
9390
+ }
9391
+ handleAuthentication(httpClient, requestInfo, objs) {
9392
+ return null;
9393
+ }
9394
+ }
9395
+ exports.BasicCredentialHandler = BasicCredentialHandler;
9396
+ class BearerCredentialHandler {
9397
+ constructor(token) {
9398
+ this.token = token;
9399
+ }
9400
+ // currently implements pre-authorization
9401
+ // TODO: support preAuth = false where it hooks on 401
9402
+ prepareRequest(options) {
9403
+ options.headers['Authorization'] = 'Bearer ' + this.token;
9404
+ }
9405
+ // This handler cannot handle 401
9406
+ canHandleAuthentication(response) {
9407
+ return false;
9408
+ }
9409
+ handleAuthentication(httpClient, requestInfo, objs) {
9410
+ return null;
9411
+ }
9412
+ }
9413
+ exports.BearerCredentialHandler = BearerCredentialHandler;
9414
+ class PersonalAccessTokenCredentialHandler {
9415
+ constructor(token) {
9416
+ this.token = token;
9417
+ }
9418
+ // currently implements pre-authorization
9419
+ // TODO: support preAuth = false where it hooks on 401
9420
+ prepareRequest(options) {
9421
+ options.headers['Authorization'] =
9422
+ 'Basic ' + Buffer.from('PAT:' + this.token).toString('base64');
9423
+ }
9424
+ // This handler cannot handle 401
9425
+ canHandleAuthentication(response) {
9426
+ return false;
9427
+ }
9428
+ handleAuthentication(httpClient, requestInfo, objs) {
9429
+ return null;
9430
+ }
9431
+ }
9432
+ exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler;
9433
+
9434
+
9277
9435
/***/ }),
9278
9436
9279
9437
/***/ 717:
0 commit comments