2022-11-04 00:55:07 +08:00
|
|
|
"use strict";
|
|
|
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
|
|
if (k2 === undefined) k2 = k;
|
2023-10-26 04:27:07 +08:00
|
|
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
|
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
|
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
|
|
}
|
|
|
|
Object.defineProperty(o, k2, desc);
|
2022-11-04 00:55:07 +08:00
|
|
|
}) : (function(o, m, k, k2) {
|
|
|
|
if (k2 === undefined) k2 = k;
|
|
|
|
o[k2] = m[k];
|
|
|
|
}));
|
|
|
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
|
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
|
|
}) : function(o, v) {
|
|
|
|
o["default"] = v;
|
|
|
|
});
|
|
|
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
|
if (mod && mod.__esModule) return mod;
|
|
|
|
var result = {};
|
2023-10-26 04:27:07 +08:00
|
|
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
2022-11-04 00:55:07 +08:00
|
|
|
__setModuleDefault(result, mod);
|
|
|
|
return result;
|
|
|
|
};
|
2023-10-26 04:27:07 +08:00
|
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
|
|
});
|
|
|
|
};
|
2022-11-04 00:55:07 +08:00
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
2023-10-26 04:27:07 +08:00
|
|
|
exports.getApiBaseUrl = exports.getProxyFetch = exports.getProxyAgentDispatcher = exports.getProxyAgent = exports.getAuthString = void 0;
|
2022-11-04 00:55:07 +08:00
|
|
|
const httpClient = __importStar(require("@actions/http-client"));
|
2023-10-26 04:27:07 +08:00
|
|
|
const undici_1 = require("undici");
|
2022-11-04 00:55:07 +08:00
|
|
|
function getAuthString(token, options) {
|
|
|
|
if (!token && !options.auth) {
|
|
|
|
throw new Error('Parameter token or opts.auth is required');
|
|
|
|
}
|
|
|
|
else if (token && options.auth) {
|
|
|
|
throw new Error('Parameters token and opts.auth may not both be specified');
|
|
|
|
}
|
|
|
|
return typeof options.auth === 'string' ? options.auth : `token ${token}`;
|
|
|
|
}
|
|
|
|
exports.getAuthString = getAuthString;
|
|
|
|
function getProxyAgent(destinationUrl) {
|
|
|
|
const hc = new httpClient.HttpClient();
|
|
|
|
return hc.getAgent(destinationUrl);
|
|
|
|
}
|
|
|
|
exports.getProxyAgent = getProxyAgent;
|
2023-10-26 04:27:07 +08:00
|
|
|
function getProxyAgentDispatcher(destinationUrl) {
|
|
|
|
const hc = new httpClient.HttpClient();
|
|
|
|
return hc.getAgentDispatcher(destinationUrl);
|
|
|
|
}
|
|
|
|
exports.getProxyAgentDispatcher = getProxyAgentDispatcher;
|
|
|
|
function getProxyFetch(destinationUrl) {
|
|
|
|
const httpDispatcher = getProxyAgentDispatcher(destinationUrl);
|
|
|
|
const proxyFetch = (url, opts) => __awaiter(this, void 0, void 0, function* () {
|
|
|
|
return (0, undici_1.fetch)(url, Object.assign(Object.assign({}, opts), { dispatcher: httpDispatcher }));
|
|
|
|
});
|
|
|
|
return proxyFetch;
|
|
|
|
}
|
|
|
|
exports.getProxyFetch = getProxyFetch;
|
2022-11-04 00:55:07 +08:00
|
|
|
function getApiBaseUrl() {
|
|
|
|
return process.env['GITHUB_API_URL'] || 'https://api.github.com';
|
|
|
|
}
|
|
|
|
exports.getApiBaseUrl = getApiBaseUrl;
|
|
|
|
//# sourceMappingURL=utils.js.map
|