Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 904b21412d | |||
| 844682e182 | |||
| f699b96ecf | |||
| 774f139bef | |||
| 5a395b732b | |||
| 89e7efa45d |
@@ -50,7 +50,6 @@ describe('@actions/github', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const octokit = getOctokit(token)
|
const octokit = getOctokit(token)
|
||||||
|
|
||||||
const branch = await octokit.rest.repos.getBranch({
|
const branch = await octokit.rest.repos.getBranch({
|
||||||
owner: 'actions',
|
owner: 'actions',
|
||||||
repo: 'toolkit',
|
repo: 'toolkit',
|
||||||
@@ -66,17 +65,6 @@ describe('@actions/github', () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
process.env['https_proxy'] = proxyUrl
|
process.env['https_proxy'] = proxyUrl
|
||||||
// const myFetch: typeof undiciFetch = (url, opts) => {
|
|
||||||
// return undiciFetch(url, {
|
|
||||||
// ...opts,
|
|
||||||
// dispatcher: new ProxyAgent({
|
|
||||||
// uri: proxyUrl,
|
|
||||||
// keepAliveTimeout: 10,
|
|
||||||
// keepAliveMaxTimeout: 10,
|
|
||||||
// }),
|
|
||||||
// });
|
|
||||||
// };
|
|
||||||
|
|
||||||
const octokit = getOctokit(token)
|
const octokit = getOctokit(token)
|
||||||
|
|
||||||
const repository = await octokit.graphql(
|
const repository = await octokit.graphql(
|
||||||
|
|||||||
Generated
+38
-63
@@ -1,34 +1,42 @@
|
|||||||
{
|
{
|
||||||
"name": "@actions/github",
|
"name": "@actions/github",
|
||||||
"version": "5.1.1",
|
"version": "6.0.2",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@actions/github",
|
"name": "@actions/github",
|
||||||
"version": "5.1.1",
|
"version": "6.0.2",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/http-client": "file:../http-client/actions-http-client-3.0.0.tgz",
|
"@actions/http-client": "file:actions-http-client-3.0.3.tgz",
|
||||||
"@octokit/core": "^4.2.4",
|
"@octokit/core": "^4.2.4",
|
||||||
"@octokit/plugin-paginate-rest": "^6.1.2",
|
"@octokit/plugin-paginate-rest": "^6.1.2",
|
||||||
"@octokit/plugin-rest-endpoint-methods": "^7.2.3"
|
"@octokit/plugin-rest-endpoint-methods": "^7.2.3",
|
||||||
|
"undici": "^5.25.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/proxy": "^1.0.1",
|
"@types/proxy": "^1.0.1",
|
||||||
"proxy": "^2.1.1",
|
"proxy": "^2.1.1"
|
||||||
"undici": "^5.25.2"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/http-client": {
|
"node_modules/@actions/http-client": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.3",
|
||||||
"resolved": "file:../http-client/actions-http-client-3.0.0.tgz",
|
"resolved": "file:actions-http-client-3.0.3.tgz",
|
||||||
"integrity": "sha512-HiloxFqJ4f0Z34H7pcqYcYb+UK+CqUKJmNY245AITh9HyJMvLz9wCrb5J+UWO6S63klrJBnzYBguTNUYrbCNrQ==",
|
"integrity": "sha512-oD3QP51ndN4IMUntw5mWcP7yZ/7c9cpLRejqbUwe9cT5vC72bWHLr5odlPzE+RAsoEVZMEkKazJbCjXdTzq8og==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"tunnel": "^0.0.6"
|
"tunnel": "^0.0.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@fastify/busboy": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-JUFJad5lv7jxj926GPgymrWQxxjPYuJNiNjNMzqT+HiuP6Vl3dk5xzG+8sTX96np0ZAluvaMzPsjhHZ5rNuNQQ==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@octokit/auth-token": {
|
"node_modules/@octokit/auth-token": {
|
||||||
"version": "3.0.4",
|
"version": "3.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-3.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-3.0.4.tgz",
|
||||||
@@ -165,9 +173,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "20.7.1",
|
"version": "20.8.2",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.7.1.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.2.tgz",
|
||||||
"integrity": "sha512-LT+OIXpp2kj4E2S/p91BMe+VgGX2+lfO+XTpfXhh+bCk2LkQtHZSub8ewFBMGP5ClysPjTDFa4sMI8Q3n4T0wg==",
|
"integrity": "sha512-Vvycsc9FQdwhxE3y3DzeIxuEJbWGDsnrxvMADzTDF/lcdR9/K+AQIeAghTQsHtotg/q0j3WEOYS/jQgSdWue3w==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/@types/proxy": {
|
"node_modules/@types/proxy": {
|
||||||
@@ -217,18 +225,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.1.tgz",
|
||||||
"integrity": "sha512-/6FKxSTWoJdbsLDF8tdIjaRiFXiE6UHsEHE3OPI/cwPURCVi1ukP0gmLn7XWEiFk5TcwQjjY5PWsU+j+tgXgmw=="
|
"integrity": "sha512-/6FKxSTWoJdbsLDF8tdIjaRiFXiE6UHsEHE3OPI/cwPURCVi1ukP0gmLn7XWEiFk5TcwQjjY5PWsU+j+tgXgmw=="
|
||||||
},
|
},
|
||||||
"node_modules/busboy": {
|
|
||||||
"version": "1.6.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz",
|
|
||||||
"integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"streamsearch": "^1.1.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10.16.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/camelcase": {
|
"node_modules/camelcase": {
|
||||||
"version": "5.0.0",
|
"version": "5.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.0.0.tgz",
|
||||||
@@ -380,15 +376,6 @@
|
|||||||
"node": ">= 14"
|
"node": ">= 14"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/streamsearch": {
|
|
||||||
"version": "1.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz",
|
|
||||||
"integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==",
|
|
||||||
"dev": true,
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/supports-color": {
|
"node_modules/supports-color": {
|
||||||
"version": "5.5.0",
|
"version": "5.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
|
||||||
@@ -415,12 +402,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/undici": {
|
"node_modules/undici": {
|
||||||
"version": "5.25.2",
|
"version": "5.25.4",
|
||||||
"resolved": "https://registry.npmjs.org/undici/-/undici-5.25.2.tgz",
|
"resolved": "https://registry.npmjs.org/undici/-/undici-5.25.4.tgz",
|
||||||
"integrity": "sha512-tch8RbCfn1UUH1PeVCXva4V8gDpGAud/w0WubD6sHC46vYQ3KDxL+xv1A2UxK0N6jrVedutuPHxe1XIoqerwMw==",
|
"integrity": "sha512-450yJxT29qKMf3aoudzFpIciqpx6Pji3hEWaXqXmanbXF58LTAGCKxcJjxMXWu3iG+Mudgo3ZUfDB6YDFd/dAw==",
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"busboy": "^1.6.0"
|
"@fastify/busboy": "^2.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=14.0"
|
"node": ">=14.0"
|
||||||
@@ -453,12 +439,17 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/http-client": {
|
"@actions/http-client": {
|
||||||
"version": "file:../http-client/actions-http-client-3.0.0.tgz",
|
"version": "file:actions-http-client-3.0.3.tgz",
|
||||||
"integrity": "sha512-HiloxFqJ4f0Z34H7pcqYcYb+UK+CqUKJmNY245AITh9HyJMvLz9wCrb5J+UWO6S63klrJBnzYBguTNUYrbCNrQ==",
|
"integrity": "sha512-oD3QP51ndN4IMUntw5mWcP7yZ/7c9cpLRejqbUwe9cT5vC72bWHLr5odlPzE+RAsoEVZMEkKazJbCjXdTzq8og==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"tunnel": "^0.0.6"
|
"tunnel": "^0.0.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@fastify/busboy": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-JUFJad5lv7jxj926GPgymrWQxxjPYuJNiNjNMzqT+HiuP6Vl3dk5xzG+8sTX96np0ZAluvaMzPsjhHZ5rNuNQQ=="
|
||||||
|
},
|
||||||
"@octokit/auth-token": {
|
"@octokit/auth-token": {
|
||||||
"version": "3.0.4",
|
"version": "3.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-3.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-3.0.4.tgz",
|
||||||
@@ -567,9 +558,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@types/node": {
|
"@types/node": {
|
||||||
"version": "20.7.1",
|
"version": "20.8.2",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.7.1.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.2.tgz",
|
||||||
"integrity": "sha512-LT+OIXpp2kj4E2S/p91BMe+VgGX2+lfO+XTpfXhh+bCk2LkQtHZSub8ewFBMGP5ClysPjTDFa4sMI8Q3n4T0wg==",
|
"integrity": "sha512-Vvycsc9FQdwhxE3y3DzeIxuEJbWGDsnrxvMADzTDF/lcdR9/K+AQIeAghTQsHtotg/q0j3WEOYS/jQgSdWue3w==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/proxy": {
|
"@types/proxy": {
|
||||||
@@ -613,15 +604,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.1.tgz",
|
||||||
"integrity": "sha512-/6FKxSTWoJdbsLDF8tdIjaRiFXiE6UHsEHE3OPI/cwPURCVi1ukP0gmLn7XWEiFk5TcwQjjY5PWsU+j+tgXgmw=="
|
"integrity": "sha512-/6FKxSTWoJdbsLDF8tdIjaRiFXiE6UHsEHE3OPI/cwPURCVi1ukP0gmLn7XWEiFk5TcwQjjY5PWsU+j+tgXgmw=="
|
||||||
},
|
},
|
||||||
"busboy": {
|
|
||||||
"version": "1.6.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz",
|
|
||||||
"integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==",
|
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
|
||||||
"streamsearch": "^1.1.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"camelcase": {
|
"camelcase": {
|
||||||
"version": "5.0.0",
|
"version": "5.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.0.0.tgz",
|
||||||
@@ -730,12 +712,6 @@
|
|||||||
"debug": "^4.3.4"
|
"debug": "^4.3.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"streamsearch": {
|
|
||||||
"version": "1.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz",
|
|
||||||
"integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"supports-color": {
|
"supports-color": {
|
||||||
"version": "5.5.0",
|
"version": "5.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
|
||||||
@@ -756,12 +732,11 @@
|
|||||||
"integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg=="
|
"integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg=="
|
||||||
},
|
},
|
||||||
"undici": {
|
"undici": {
|
||||||
"version": "5.25.2",
|
"version": "5.25.4",
|
||||||
"resolved": "https://registry.npmjs.org/undici/-/undici-5.25.2.tgz",
|
"resolved": "https://registry.npmjs.org/undici/-/undici-5.25.4.tgz",
|
||||||
"integrity": "sha512-tch8RbCfn1UUH1PeVCXva4V8gDpGAud/w0WubD6sHC46vYQ3KDxL+xv1A2UxK0N6jrVedutuPHxe1XIoqerwMw==",
|
"integrity": "sha512-450yJxT29qKMf3aoudzFpIciqpx6Pji3hEWaXqXmanbXF58LTAGCKxcJjxMXWu3iG+Mudgo3ZUfDB6YDFd/dAw==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"busboy": "^1.6.0"
|
"@fastify/busboy": "^2.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"universal-user-agent": {
|
"universal-user-agent": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@actions/github",
|
"name": "@actions/github",
|
||||||
"version": "5.1.1",
|
"version": "6.0.2",
|
||||||
"description": "Actions github lib",
|
"description": "Actions github lib",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"github",
|
"github",
|
||||||
@@ -38,14 +38,14 @@
|
|||||||
"url": "https://github.com/actions/toolkit/issues"
|
"url": "https://github.com/actions/toolkit/issues"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/http-client": "file:../http-client/actions-http-client-3.0.0.tgz",
|
"@actions/http-client": "file:actions-http-client-3.0.3.tgz",
|
||||||
"@octokit/core": "^4.2.4",
|
"@octokit/core": "^4.2.4",
|
||||||
"@octokit/plugin-paginate-rest": "^6.1.2",
|
"@octokit/plugin-paginate-rest": "^6.1.2",
|
||||||
"@octokit/plugin-rest-endpoint-methods": "^7.2.3"
|
"@octokit/plugin-rest-endpoint-methods": "^7.2.3",
|
||||||
|
"undici": "^5.25.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/proxy": "^1.0.1",
|
"@types/proxy": "^1.0.1",
|
||||||
"proxy": "^2.1.1",
|
"proxy": "^2.1.1"
|
||||||
"undici": "^5.25.2"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import * as http from 'http'
|
import * as http from 'http'
|
||||||
import * as httpClient from '@actions/http-client'
|
import * as httpClient from '@actions/http-client'
|
||||||
import {OctokitOptions} from '@octokit/core/dist-types/types'
|
import {OctokitOptions} from '@octokit/core/dist-types/types'
|
||||||
import { ProxyServer, createProxy } from "proxy";
|
|
||||||
import { ProxyAgent, Agent, fetch as undiciFetch } from "undici";
|
import { ProxyAgent, Agent, fetch as undiciFetch } from "undici";
|
||||||
|
|
||||||
export function getAuthString(
|
export function getAuthString(
|
||||||
@@ -22,20 +21,20 @@ export function getProxyAgent(destinationUrl: string): http.Agent {
|
|||||||
return hc.getAgent(destinationUrl)
|
return hc.getAgent(destinationUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getNewProxyAgent(destinationUrl: string): ProxyAgent | Agent {
|
export function getProxyAgentDispatcher(destinationUrl: string): ProxyAgent | undefined {
|
||||||
const hc = new httpClient.HttpClient()
|
const hc = new httpClient.HttpClient()
|
||||||
return hc.getNewAgent(destinationUrl)
|
return hc.getAgentDispatcher(destinationUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getProxyFetchAgent(destinationUrl): any {
|
export function getProxyFetch(destinationUrl): any {
|
||||||
const httpAgent = getNewProxyAgent(destinationUrl)
|
const httpAgent = getProxyAgentDispatcher(destinationUrl)
|
||||||
const myFetch: typeof undiciFetch = (url, opts) => {
|
const proxyFetch: typeof undiciFetch = (url, opts) => {
|
||||||
return undiciFetch(url, {
|
return undiciFetch(url, {
|
||||||
...opts,
|
...opts,
|
||||||
dispatcher: httpAgent,
|
dispatcher: httpAgent,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
return myFetch;
|
return proxyFetch;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getApiBaseUrl(): string {
|
export function getApiBaseUrl(): string {
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ const baseUrl = Utils.getApiBaseUrl()
|
|||||||
export const defaults: OctokitOptions = {
|
export const defaults: OctokitOptions = {
|
||||||
baseUrl,
|
baseUrl,
|
||||||
request: {
|
request: {
|
||||||
fetch: Utils.getProxyFetchAgent(baseUrl)
|
agent: Utils.getProxyAgent(baseUrl),
|
||||||
|
fetch: Utils.getProxyFetch(baseUrl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import * as http from 'http'
|
import * as http from 'http'
|
||||||
import * as httpm from '../lib/'
|
import * as httpm from '../lib/'
|
||||||
import * as pm from '../lib/proxy'
|
import * as pm from '../lib/proxy'
|
||||||
|
import { ProxyAgent, Agent, fetch as undiciFetch } from "undici";
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
|
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
|
||||||
const proxy = require('proxy')
|
const proxy = require('proxy')
|
||||||
|
|
||||||
@@ -13,7 +14,7 @@ const _proxyUrl = 'http://127.0.0.1:8080'
|
|||||||
describe('proxy', () => {
|
describe('proxy', () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
// Start proxy server
|
// Start proxy server
|
||||||
_proxyServer = proxy()
|
_proxyServer = proxy.createProxy()
|
||||||
await new Promise<void>(resolve => {
|
await new Promise<void>(resolve => {
|
||||||
const port = Number(_proxyUrl.split(':')[2])
|
const port = Number(_proxyUrl.split(':')[2])
|
||||||
_proxyServer.listen(port, () => resolve())
|
_proxyServer.listen(port, () => resolve())
|
||||||
@@ -294,6 +295,23 @@ describe('proxy', () => {
|
|||||||
expect(agent.proxyOptions.port).toBe('8080')
|
expect(agent.proxyOptions.port).toBe('8080')
|
||||||
expect(agent.proxyOptions.proxyAuth).toBe('user:password')
|
expect(agent.proxyOptions.proxyAuth).toBe('user:password')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('proxy settings return ProxyAgent', async () => {
|
||||||
|
process.env['https_proxy'] = 'http://127.0.0.1:8080'
|
||||||
|
const httpClient = new httpm.HttpClient()
|
||||||
|
const agent = httpClient.getAgentDispatcher('https://some-url')
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(agent)
|
||||||
|
expect(agent instanceof ProxyAgent).toBe(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
// it('proxyAuth is set in tunnel agent when authentication is provided', async () => {
|
||||||
|
// const httpClient = new httpm.HttpClient()
|
||||||
|
// const agent: Agent | ProxyAgent = httpClient.getAgentDispatcher('https://some-url')
|
||||||
|
// // eslint-disable-next-line no-console
|
||||||
|
// console.log(agent)
|
||||||
|
// expect(agent instanceof Agent).toBe(true)
|
||||||
|
// })
|
||||||
})
|
})
|
||||||
|
|
||||||
function _clearVars(): void {
|
function _clearVars(): void {
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Generated
+28
-49
@@ -1,22 +1,31 @@
|
|||||||
{
|
{
|
||||||
"name": "@actions/http-client",
|
"name": "@actions/http-client",
|
||||||
"version": "3.0.0",
|
"version": "3.0.3",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@actions/http-client",
|
"name": "@actions/http-client",
|
||||||
"version": "3.0.0",
|
"version": "3.0.3",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"tunnel": "^0.0.6"
|
"tunnel": "^0.0.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^20.7.1",
|
"@types/node": "20.7.1",
|
||||||
"@types/proxy": "^1.0.2",
|
"@types/proxy": "^1.0.1",
|
||||||
"@types/tunnel": "0.0.3",
|
"@types/tunnel": "0.0.3",
|
||||||
"proxy": "^2.1.1",
|
"proxy": "^2.1.1",
|
||||||
"undici": "^5.25.2"
|
"undici": "^5.25.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@fastify/busboy": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-JUFJad5lv7jxj926GPgymrWQxxjPYuJNiNjNMzqT+HiuP6Vl3dk5xzG+8sTX96np0ZAluvaMzPsjhHZ5rNuNQQ==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
@@ -76,18 +85,6 @@
|
|||||||
"integrity": "sha512-GFj8iVxo9onSU6BnnQvVwqvxh60UcSHJEDnIk3z4B6iOjsKSmqe+ibW0Rsz7YO7IE1HG3D3tqCNIidP46SZVdQ==",
|
"integrity": "sha512-GFj8iVxo9onSU6BnnQvVwqvxh60UcSHJEDnIk3z4B6iOjsKSmqe+ibW0Rsz7YO7IE1HG3D3tqCNIidP46SZVdQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/busboy": {
|
|
||||||
"version": "1.6.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz",
|
|
||||||
"integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==",
|
|
||||||
"dev": true,
|
|
||||||
"dependencies": {
|
|
||||||
"streamsearch": "^1.1.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10.16.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/camelcase": {
|
"node_modules/camelcase": {
|
||||||
"version": "5.0.0",
|
"version": "5.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.0.0.tgz",
|
||||||
@@ -199,15 +196,6 @@
|
|||||||
"node": ">= 14"
|
"node": ">= 14"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/streamsearch": {
|
|
||||||
"version": "1.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz",
|
|
||||||
"integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==",
|
|
||||||
"dev": true,
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/supports-color": {
|
"node_modules/supports-color": {
|
||||||
"version": "5.5.0",
|
"version": "5.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
|
||||||
@@ -229,12 +217,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/undici": {
|
"node_modules/undici": {
|
||||||
"version": "5.25.2",
|
"version": "5.25.4",
|
||||||
"resolved": "https://registry.npmjs.org/undici/-/undici-5.25.2.tgz",
|
"resolved": "https://registry.npmjs.org/undici/-/undici-5.25.4.tgz",
|
||||||
"integrity": "sha512-tch8RbCfn1UUH1PeVCXva4V8gDpGAud/w0WubD6sHC46vYQ3KDxL+xv1A2UxK0N6jrVedutuPHxe1XIoqerwMw==",
|
"integrity": "sha512-450yJxT29qKMf3aoudzFpIciqpx6Pji3hEWaXqXmanbXF58LTAGCKxcJjxMXWu3iG+Mudgo3ZUfDB6YDFd/dAw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"busboy": "^1.6.0"
|
"@fastify/busboy": "^2.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=14.0"
|
"node": ">=14.0"
|
||||||
@@ -242,6 +230,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@fastify/busboy": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-JUFJad5lv7jxj926GPgymrWQxxjPYuJNiNjNMzqT+HiuP6Vl3dk5xzG+8sTX96np0ZAluvaMzPsjhHZ5rNuNQQ==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"@types/node": {
|
"@types/node": {
|
||||||
"version": "20.7.1",
|
"version": "20.7.1",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.7.1.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.7.1.tgz",
|
||||||
@@ -293,15 +287,6 @@
|
|||||||
"integrity": "sha512-GFj8iVxo9onSU6BnnQvVwqvxh60UcSHJEDnIk3z4B6iOjsKSmqe+ibW0Rsz7YO7IE1HG3D3tqCNIidP46SZVdQ==",
|
"integrity": "sha512-GFj8iVxo9onSU6BnnQvVwqvxh60UcSHJEDnIk3z4B6iOjsKSmqe+ibW0Rsz7YO7IE1HG3D3tqCNIidP46SZVdQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"busboy": {
|
|
||||||
"version": "1.6.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz",
|
|
||||||
"integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==",
|
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
|
||||||
"streamsearch": "^1.1.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"camelcase": {
|
"camelcase": {
|
||||||
"version": "5.0.0",
|
"version": "5.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.0.0.tgz",
|
||||||
@@ -384,12 +369,6 @@
|
|||||||
"debug": "^4.3.4"
|
"debug": "^4.3.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"streamsearch": {
|
|
||||||
"version": "1.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz",
|
|
||||||
"integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"supports-color": {
|
"supports-color": {
|
||||||
"version": "5.5.0",
|
"version": "5.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
|
||||||
@@ -405,12 +384,12 @@
|
|||||||
"integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg=="
|
"integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg=="
|
||||||
},
|
},
|
||||||
"undici": {
|
"undici": {
|
||||||
"version": "5.25.2",
|
"version": "5.25.4",
|
||||||
"resolved": "https://registry.npmjs.org/undici/-/undici-5.25.2.tgz",
|
"resolved": "https://registry.npmjs.org/undici/-/undici-5.25.4.tgz",
|
||||||
"integrity": "sha512-tch8RbCfn1UUH1PeVCXva4V8gDpGAud/w0WubD6sHC46vYQ3KDxL+xv1A2UxK0N6jrVedutuPHxe1XIoqerwMw==",
|
"integrity": "sha512-450yJxT29qKMf3aoudzFpIciqpx6Pji3hEWaXqXmanbXF58LTAGCKxcJjxMXWu3iG+Mudgo3ZUfDB6YDFd/dAw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"busboy": "^1.6.0"
|
"@fastify/busboy": "^2.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@actions/http-client",
|
"name": "@actions/http-client",
|
||||||
"version": "3.0.0",
|
"version": "3.0.3",
|
||||||
"description": "Actions Http Client",
|
"description": "Actions Http Client",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"github",
|
"github",
|
||||||
@@ -39,11 +39,11 @@
|
|||||||
"url": "https://github.com/actions/toolkit/issues"
|
"url": "https://github.com/actions/toolkit/issues"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^20.7.1",
|
"@types/node": "20.7.1",
|
||||||
"@types/proxy": "^1.0.2",
|
|
||||||
"@types/tunnel": "0.0.3",
|
"@types/tunnel": "0.0.3",
|
||||||
"proxy": "^2.1.1",
|
"proxy": "^2.1.1",
|
||||||
"undici": "^5.25.2"
|
"undici": "^5.25.4",
|
||||||
|
"@types/proxy": "^1.0.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"tunnel": "^0.0.6"
|
"tunnel": "^0.0.6"
|
||||||
|
|||||||
@@ -137,9 +137,9 @@ export class HttpClient {
|
|||||||
private _allowRetries = false
|
private _allowRetries = false
|
||||||
private _maxRetries = 1
|
private _maxRetries = 1
|
||||||
private _agent: any
|
private _agent: any
|
||||||
private _newAgent: any
|
|
||||||
private _proxyAgent: any
|
private _proxyAgent: any
|
||||||
private _newProxyAgent: any
|
private _agentDispatcher: any
|
||||||
|
private _proxyAgentDispatcher: any
|
||||||
private _keepAlive = false
|
private _keepAlive = false
|
||||||
private _disposed = false
|
private _disposed = false
|
||||||
|
|
||||||
@@ -567,15 +567,15 @@ export class HttpClient {
|
|||||||
return this._getAgent(parsedUrl)
|
return this._getAgent(parsedUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
getNewAgent(serverUrl: string): ProxyAgent | Agent {
|
getAgentDispatcher(serverUrl: string): ProxyAgent | undefined {
|
||||||
const parsedUrl = new URL(serverUrl)
|
const parsedUrl = new URL(serverUrl)
|
||||||
const proxyUrl = pm.getProxyUrl(parsedUrl)
|
const proxyUrl = pm.getProxyUrl(parsedUrl)
|
||||||
const useProxy = proxyUrl && proxyUrl.hostname
|
const useProxy = proxyUrl && proxyUrl.hostname
|
||||||
if (useProxy) {
|
if (useProxy) {
|
||||||
return this._getProxyAgent(parsedUrl)
|
return this._getProxyAgentDispatcher(parsedUrl, proxyUrl)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return this._getNewAgent(parsedUrl)
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -694,7 +694,7 @@ export class HttpClient {
|
|||||||
|
|
||||||
// if reusing agent across request and tunneling agent isn't assigned create a new agent
|
// if reusing agent across request and tunneling agent isn't assigned create a new agent
|
||||||
if (this._keepAlive && !agent) {
|
if (this._keepAlive && !agent) {
|
||||||
const options = { keepAlive: this._keepAlive, maxSockets }
|
const options = {keepAlive: this._keepAlive, maxSockets}
|
||||||
agent = usingSsl ? new https.Agent(options) : new http.Agent(options)
|
agent = usingSsl ? new https.Agent(options) : new http.Agent(options)
|
||||||
this._agent = agent
|
this._agent = agent
|
||||||
}
|
}
|
||||||
@@ -716,17 +716,16 @@ export class HttpClient {
|
|||||||
return agent
|
return agent
|
||||||
}
|
}
|
||||||
|
|
||||||
private _getProxyAgent(parsedUrl: URL): ProxyAgent {
|
private _getProxyAgentDispatcher(parsedUrl: URL, proxyUrl: URL): ProxyAgent {
|
||||||
let proxyAgent
|
let proxyAgent
|
||||||
const proxyUrl = pm.getProxyUrl(parsedUrl)
|
|
||||||
const useProxy = proxyUrl && proxyUrl.hostname
|
const useProxy = proxyUrl && proxyUrl.hostname
|
||||||
|
|
||||||
if (this._keepAlive && useProxy) {
|
if (this._keepAlive && useProxy) {
|
||||||
proxyAgent = this._newProxyAgent
|
proxyAgent = this._proxyAgentDispatcher
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._keepAlive && !useProxy) {
|
if (this._keepAlive && !useProxy) {
|
||||||
proxyAgent = this._newAgent
|
proxyAgent = this._agentDispatcher
|
||||||
}
|
}
|
||||||
|
|
||||||
// if agent is already assigned use that agent.
|
// if agent is already assigned use that agent.
|
||||||
@@ -749,7 +748,7 @@ export class HttpClient {
|
|||||||
token: `${proxyUrl.username}:${proxyUrl.password}`
|
token: `${proxyUrl.username}:${proxyUrl.password}`
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
this._newProxyAgent = proxyAgent
|
this._proxyAgentDispatcher = proxyAgent
|
||||||
}
|
}
|
||||||
|
|
||||||
if (usingSsl && this._ignoreSslError) {
|
if (usingSsl && this._ignoreSslError) {
|
||||||
@@ -764,11 +763,11 @@ export class HttpClient {
|
|||||||
return proxyAgent
|
return proxyAgent
|
||||||
}
|
}
|
||||||
|
|
||||||
private _getNewAgent(parsedUrl: URL): Agent {
|
private _getAgentDispatcher(parsedUrl: URL): Agent {
|
||||||
let agent;
|
let agent;
|
||||||
|
|
||||||
if (this._keepAlive) {
|
if (this._keepAlive) {
|
||||||
agent = this._newAgent
|
agent = this._agentDispatcher
|
||||||
}
|
}
|
||||||
|
|
||||||
// if agent is already assigned use that agent.
|
// if agent is already assigned use that agent.
|
||||||
@@ -783,13 +782,13 @@ export class HttpClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if reusing agent across request and tunneling agent isn't assigned create a new agent
|
// if reusing agent across request and tunneling agent isn't assigned create a new agent
|
||||||
if (this._keepAlive && !agent) {
|
if (!agent) {
|
||||||
agent = new Agent(
|
agent = new Agent(
|
||||||
{
|
{
|
||||||
pipelining: (!this._keepAlive ? 0 : 1),
|
pipelining: (!this._keepAlive ? 0 : 1),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
this._newAgent = agent
|
this._agentDispatcher = agent
|
||||||
}
|
}
|
||||||
|
|
||||||
if (usingSsl && this._ignoreSslError) {
|
if (usingSsl && this._ignoreSslError) {
|
||||||
@@ -886,5 +885,5 @@ export class HttpClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const lowercaseKeys = (obj: { [index: string]: any }): any =>
|
const lowercaseKeys = (obj: {[index: string]: any}): any =>
|
||||||
Object.keys(obj).reduce((c: any, k) => ((c[k.toLowerCase()] = obj[k]), c), {})
|
Object.keys(obj).reduce((c: any, k) => ((c[k.toLowerCase()] = obj[k]), c), {})
|
||||||
|
|||||||
Reference in New Issue
Block a user