@actions/http-client 1.0.10 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/RELEASES.md +4 -0
- package/auth.d.ts +23 -0
- package/auth.js +58 -0
- package/index.d.ts +124 -0
- package/index.js +537 -0
- package/interfaces.d.ts +49 -0
- package/interfaces.js +2 -0
- package/package.json +1 -1
- package/proxy.d.ts +2 -0
- package/proxy.js +57 -0
- package/.github/workflows/test.yml +0 -51
- package/.prettierignore +0 -2
- package/.prettierrc.json +0 -11
- package/__tests__/auth.test.ts +0 -61
- package/__tests__/basics.test.ts +0 -375
- package/__tests__/headers.test.ts +0 -115
- package/__tests__/keepalive.test.ts +0 -79
- package/__tests__/proxy.test.ts +0 -228
- package/auth.ts +0 -86
- package/index.ts +0 -768
- package/interfaces.ts +0 -98
- package/jest.config.js +0 -10
- package/proxy.ts +0 -60
- package/tsconfig.json +0 -15
package/interfaces.ts
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import http = require('http')
|
|
2
|
-
|
|
3
|
-
export interface IHeaders {
|
|
4
|
-
[key: string]: any
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export interface IHttpClient {
|
|
8
|
-
options(
|
|
9
|
-
requestUrl: string,
|
|
10
|
-
additionalHeaders?: IHeaders
|
|
11
|
-
): Promise<IHttpClientResponse>
|
|
12
|
-
get(
|
|
13
|
-
requestUrl: string,
|
|
14
|
-
additionalHeaders?: IHeaders
|
|
15
|
-
): Promise<IHttpClientResponse>
|
|
16
|
-
del(
|
|
17
|
-
requestUrl: string,
|
|
18
|
-
additionalHeaders?: IHeaders
|
|
19
|
-
): Promise<IHttpClientResponse>
|
|
20
|
-
post(
|
|
21
|
-
requestUrl: string,
|
|
22
|
-
data: string,
|
|
23
|
-
additionalHeaders?: IHeaders
|
|
24
|
-
): Promise<IHttpClientResponse>
|
|
25
|
-
patch(
|
|
26
|
-
requestUrl: string,
|
|
27
|
-
data: string,
|
|
28
|
-
additionalHeaders?: IHeaders
|
|
29
|
-
): Promise<IHttpClientResponse>
|
|
30
|
-
put(
|
|
31
|
-
requestUrl: string,
|
|
32
|
-
data: string,
|
|
33
|
-
additionalHeaders?: IHeaders
|
|
34
|
-
): Promise<IHttpClientResponse>
|
|
35
|
-
sendStream(
|
|
36
|
-
verb: string,
|
|
37
|
-
requestUrl: string,
|
|
38
|
-
stream: NodeJS.ReadableStream,
|
|
39
|
-
additionalHeaders?: IHeaders
|
|
40
|
-
): Promise<IHttpClientResponse>
|
|
41
|
-
request(
|
|
42
|
-
verb: string,
|
|
43
|
-
requestUrl: string,
|
|
44
|
-
data: string | NodeJS.ReadableStream,
|
|
45
|
-
headers: IHeaders
|
|
46
|
-
): Promise<IHttpClientResponse>
|
|
47
|
-
requestRaw(
|
|
48
|
-
info: IRequestInfo,
|
|
49
|
-
data: string | NodeJS.ReadableStream
|
|
50
|
-
): Promise<IHttpClientResponse>
|
|
51
|
-
requestRawWithCallback(
|
|
52
|
-
info: IRequestInfo,
|
|
53
|
-
data: string | NodeJS.ReadableStream,
|
|
54
|
-
onResult: (err: any, res: IHttpClientResponse) => void
|
|
55
|
-
): void
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export interface IRequestHandler {
|
|
59
|
-
prepareRequest(options: http.RequestOptions): void
|
|
60
|
-
canHandleAuthentication(response: IHttpClientResponse): boolean
|
|
61
|
-
handleAuthentication(
|
|
62
|
-
httpClient: IHttpClient,
|
|
63
|
-
requestInfo: IRequestInfo,
|
|
64
|
-
objs
|
|
65
|
-
): Promise<IHttpClientResponse>
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export interface IHttpClientResponse {
|
|
69
|
-
message: http.IncomingMessage
|
|
70
|
-
readBody(): Promise<string>
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export interface IRequestInfo {
|
|
74
|
-
options: http.RequestOptions
|
|
75
|
-
parsedUrl: URL
|
|
76
|
-
httpModule: any
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export interface IRequestOptions {
|
|
80
|
-
headers?: IHeaders
|
|
81
|
-
socketTimeout?: number
|
|
82
|
-
ignoreSslError?: boolean
|
|
83
|
-
allowRedirects?: boolean
|
|
84
|
-
allowRedirectDowngrade?: boolean
|
|
85
|
-
maxRedirects?: number
|
|
86
|
-
maxSockets?: number
|
|
87
|
-
keepAlive?: boolean
|
|
88
|
-
deserializeDates?: boolean
|
|
89
|
-
// Allows retries only on Read operations (since writes may not be idempotent)
|
|
90
|
-
allowRetries?: boolean
|
|
91
|
-
maxRetries?: number
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export interface ITypedResponse<T> {
|
|
95
|
-
statusCode: number
|
|
96
|
-
result: T | null
|
|
97
|
-
headers: Object
|
|
98
|
-
}
|
package/jest.config.js
DELETED
package/proxy.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
export function getProxyUrl(reqUrl: URL): URL | undefined {
|
|
2
|
-
let usingSsl = reqUrl.protocol === 'https:'
|
|
3
|
-
|
|
4
|
-
let proxyUrl: URL
|
|
5
|
-
if (checkBypass(reqUrl)) {
|
|
6
|
-
return proxyUrl
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
let proxyVar: string
|
|
10
|
-
if (usingSsl) {
|
|
11
|
-
proxyVar = process.env['https_proxy'] || process.env['HTTPS_PROXY']
|
|
12
|
-
} else {
|
|
13
|
-
proxyVar = process.env['http_proxy'] || process.env['HTTP_PROXY']
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (proxyVar) {
|
|
17
|
-
proxyUrl = new URL(proxyVar)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return proxyUrl
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function checkBypass(reqUrl: URL): boolean {
|
|
24
|
-
if (!reqUrl.hostname) {
|
|
25
|
-
return false
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
let noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || ''
|
|
29
|
-
if (!noProxy) {
|
|
30
|
-
return false
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Determine the request port
|
|
34
|
-
let reqPort: number
|
|
35
|
-
if (reqUrl.port) {
|
|
36
|
-
reqPort = Number(reqUrl.port)
|
|
37
|
-
} else if (reqUrl.protocol === 'http:') {
|
|
38
|
-
reqPort = 80
|
|
39
|
-
} else if (reqUrl.protocol === 'https:') {
|
|
40
|
-
reqPort = 443
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Format the request hostname and hostname with port
|
|
44
|
-
let upperReqHosts = [reqUrl.hostname.toUpperCase()]
|
|
45
|
-
if (typeof reqPort === 'number') {
|
|
46
|
-
upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Compare request host against noproxy
|
|
50
|
-
for (let upperNoProxyItem of noProxy
|
|
51
|
-
.split(',')
|
|
52
|
-
.map(x => x.trim().toUpperCase())
|
|
53
|
-
.filter(x => x)) {
|
|
54
|
-
if (upperReqHosts.some(x => x === upperNoProxyItem)) {
|
|
55
|
-
return true
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return false
|
|
60
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "es2019",
|
|
4
|
-
"module": "commonjs",
|
|
5
|
-
"moduleResolution": "node",
|
|
6
|
-
"typeRoots": [ "node_modules/@types" ],
|
|
7
|
-
"declaration": true,
|
|
8
|
-
"outDir": "_out",
|
|
9
|
-
"forceConsistentCasingInFileNames": true
|
|
10
|
-
},
|
|
11
|
-
"files": [
|
|
12
|
-
"index.ts",
|
|
13
|
-
"auth.ts"
|
|
14
|
-
]
|
|
15
|
-
}
|