Skip to content

Commit 649ab4b

Browse files
authored
fix(security): fix proxy-Authorization header security issue (#3383)
Refs #3382
1 parent f00b527 commit 649ab4b

6 files changed

+26
-46
lines changed

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ Swagger Client Version | Release Date | OpenAPI Spec compatibility |
5757
`swagger-client` requires Node.js `>=12.20.0` and uses different `fetch` implementation depending
5858
on Node.js version.
5959

60-
- `>=12.20.0 <16.8` - [node-fetch@3](https://www.npmjs.com/package/node-fetch)
61-
- `>=16.8 <18` - [undici](https://www.npmjs.com/package/undici)
60+
- `>=12.20.0 <18` - [node-fetch@3](https://www.npmjs.com/package/node-fetch)
6261
- `>=18` - [native Node.js fetch](https://nodejs.org/dist/latest-v18.x/docs/api/globals.html#fetch)
6362

6463
> NOTE: swagger-client minimum Node.js runtime version aligns with [Node.js Releases](https://nodejs.org/en/about/releases/)

package-lock.json

+11-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
"rimraf": "=5.0.5",
103103
"source-map-explorer": "^2.5.3",
104104
"terser-webpack-plugin": "^5.0.3",
105+
"undici": "^5.28.3",
105106
"webpack": "=5.90.3",
106107
"webpack-bundle-size-analyzer": "=3.1.0",
107108
"webpack-cli": "=5.1.4",
@@ -119,11 +120,10 @@
119120
"fast-json-patch": "^3.0.0-1",
120121
"is-plain-object": "^5.0.0",
121122
"js-yaml": "^4.1.0",
122-
"node-fetch-commonjs": "^3.3.1",
123123
"node-abort-controller": "^3.1.1",
124+
"node-fetch-commonjs": "^3.3.2",
124125
"qs": "^6.10.2",
125-
"traverse": "~0.6.6",
126-
"undici": "^5.24.0"
126+
"traverse": "~0.6.6"
127127
},
128128
"overrides": {
129129
"@swagger-api/apidom-reference": {

src/helpers/fetch-polyfill.node.js

+7-16
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
import {
2-
fetch as fetchU,
3-
Headers as HeaderU,
4-
Request as RequestU,
5-
Response as ResponseU,
6-
FormData as FormDataU,
7-
File as FileU,
8-
Blob as BlobU,
9-
} from './fetch-ponyfill-undici.node.js';
101
import {
112
fetch as fetchNF,
123
Headers as HeadersNF,
@@ -18,23 +9,23 @@ import {
189
} from './fetch-ponyfill-node-fetch.node.js';
1910

2011
if (typeof globalThis.fetch === 'undefined') {
21-
globalThis.fetch = fetchU || fetchNF;
12+
globalThis.fetch = fetchNF;
2213
}
2314
if (typeof globalThis.Headers === 'undefined') {
24-
globalThis.Headers = HeaderU || HeadersNF;
15+
globalThis.Headers = HeadersNF;
2516
}
2617
if (typeof globalThis.Request === 'undefined') {
27-
globalThis.Request = RequestU || RequestNF;
18+
globalThis.Request = RequestNF;
2819
}
2920
if (typeof globalThis.Response === 'undefined') {
30-
globalThis.Response = ResponseU || ResponseNF;
21+
globalThis.Response = ResponseNF;
3122
}
3223
if (typeof globalThis.FormData === 'undefined') {
33-
globalThis.FormData = FormDataU || FormDataNF;
24+
globalThis.FormData = FormDataNF;
3425
}
3526
if (typeof globalThis.File === 'undefined') {
36-
globalThis.File = FileU || FileNF;
27+
globalThis.File = FileNF;
3728
}
3829
if (typeof globalThis.Blob === 'undefined') {
39-
globalThis.Blob = BlobU || BlobNF;
30+
globalThis.Blob = BlobNF;
4031
}

src/helpers/fetch-ponyfill-undici.node.js

-6
This file was deleted.

test/jest.setup.js

+4-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
1+
import { Blob } from 'node:buffer';
12
import process from 'node:process';
23
import http from 'node:http';
34
import path from 'node:path';
45
import fs from 'node:fs';
5-
6-
import {
7-
fetch,
8-
Headers,
9-
Request,
10-
Response,
11-
FormData,
12-
File,
13-
Blob,
14-
} from '../src/helpers/fetch-ponyfill-undici.node.js';
6+
import { ReadableStream } from 'node:stream/web';
7+
import { fetch, Headers, Request, Response, FormData, File } from 'undici';
158

169
// force using undici for testing
1710
globalThis.fetch = fetch;
@@ -21,6 +14,7 @@ globalThis.Response = Response;
2114
globalThis.FormData = FormData;
2215
globalThis.File = File;
2316
globalThis.Blob = Blob;
17+
globalThis.ReadableStream = ReadableStream;
2418

2519
// helpers for reading local files
2620
globalThis.loadFile = (uri) => fs.readFileSync(uri).toString();

0 commit comments

Comments
 (0)