diff --git a/package-lock.json b/package-lock.json index 17261baf1..ee3fad3a1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,6 @@ "dependencies": { "axios": "^0.21.1", "axios-ntlm": "^1.2.0", - "content-type-parser": "^1.0.2", "debug": "^4.3.2", "formidable": "^1.2.2", "get-stream": "^6.0.1", @@ -19,6 +18,7 @@ "sax": ">=0.6", "strip-bom": "^3.0.0", "uuid": "^8.3.2", + "whatwg-mimetype": "3.0.0", "xml-crypto": "^2.1.3" }, "devDependencies": { @@ -29,6 +29,7 @@ "@types/request": "^2.48.7", "@types/sax": "^1.2.3", "@types/uuid": "^8.3.1", + "@types/whatwg-mimetype": "^2.1.1", "body-parser": "^1.15.2", "colors": "^1.3.3", "coveralls": "^3.1.1", @@ -53,7 +54,7 @@ "typescript": "^3.9.10" }, "engines": { - "node": ">=10.0.0" + "node": ">=12.0.0" } }, "node_modules/@babel/code-frame": { @@ -328,6 +329,12 @@ "integrity": "sha512-Y2mHTRAbqfFkpjldbkHGY8JIzRN6XqYRliG8/24FcHm2D2PwW24fl5xMRTVGdrb7iMrwCaIEbLWerGIkXuFWVg==", "dev": true }, + "node_modules/@types/whatwg-mimetype": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@types/whatwg-mimetype/-/whatwg-mimetype-2.1.1.tgz", + "integrity": "sha512-ojnf89qt5AWnqsjyPqMLN8uVaxm5x23vxNQ1me6EPBOdJe1YYuIZUzg809MZUG8UU6HKhkr6ah4fi2WUvD0DFw==", + "dev": true + }, "node_modules/@xmldom/xmldom": { "version": "0.7.2", "resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.7.2.tgz", @@ -910,11 +917,6 @@ "node": ">= 0.6" } }, - "node_modules/content-type-parser": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/content-type-parser/-/content-type-parser-1.0.2.tgz", - "integrity": "sha512-lM4l4CnMEwOLHAHr/P6MEZwZFPJFtAAKgL6pogbXmVZggIqXhdB6RbBtPOTsw2FcXwYhehRGERJmRrjOiIB8pQ==" - }, "node_modules/convert-source-map": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.7.0.tgz", @@ -4605,6 +4607,14 @@ "integrity": "sha512-Uw5ooOQxRASHgu6C7GVvUxisKXfSgW4oFlO+aa+PAkgmH89O3CXxEEzNRNtHSqtXFTl0nAC1uYj0GMSH27uwtQ==", "dev": true }, + "node_modules/whatwg-mimetype": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-3.0.0.tgz", + "integrity": "sha512-nt+N2dzIutVRxARx1nghPKGv1xHikU7HKdfafKkLNLindmPU/ch3U31NOCGGA/dmPcmb1VlofO0vnKAcsm0o/Q==", + "engines": { + "node": ">=12" + } + }, "node_modules/which": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", @@ -5145,6 +5155,12 @@ "integrity": "sha512-Y2mHTRAbqfFkpjldbkHGY8JIzRN6XqYRliG8/24FcHm2D2PwW24fl5xMRTVGdrb7iMrwCaIEbLWerGIkXuFWVg==", "dev": true }, + "@types/whatwg-mimetype": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@types/whatwg-mimetype/-/whatwg-mimetype-2.1.1.tgz", + "integrity": "sha512-ojnf89qt5AWnqsjyPqMLN8uVaxm5x23vxNQ1me6EPBOdJe1YYuIZUzg809MZUG8UU6HKhkr6ah4fi2WUvD0DFw==", + "dev": true + }, "@xmldom/xmldom": { "version": "0.7.2", "resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.7.2.tgz", @@ -5629,11 +5645,6 @@ "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==", "dev": true }, - "content-type-parser": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/content-type-parser/-/content-type-parser-1.0.2.tgz", - "integrity": "sha512-lM4l4CnMEwOLHAHr/P6MEZwZFPJFtAAKgL6pogbXmVZggIqXhdB6RbBtPOTsw2FcXwYhehRGERJmRrjOiIB8pQ==" - }, "convert-source-map": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.7.0.tgz", @@ -8527,6 +8538,11 @@ "integrity": "sha512-Uw5ooOQxRASHgu6C7GVvUxisKXfSgW4oFlO+aa+PAkgmH89O3CXxEEzNRNtHSqtXFTl0nAC1uYj0GMSH27uwtQ==", "dev": true }, + "whatwg-mimetype": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-3.0.0.tgz", + "integrity": "sha512-nt+N2dzIutVRxARx1nghPKGv1xHikU7HKdfafKkLNLindmPU/ch3U31NOCGGA/dmPcmb1VlofO0vnKAcsm0o/Q==" + }, "which": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", diff --git a/package.json b/package.json index a22c61fa8..95e6203aa 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,6 @@ "dependencies": { "axios": "^0.21.1", "axios-ntlm": "^1.2.0", - "content-type-parser": "^1.0.2", "debug": "^4.3.2", "formidable": "^1.2.2", "get-stream": "^6.0.1", @@ -17,6 +16,7 @@ "sax": ">=0.6", "strip-bom": "^3.0.0", "uuid": "^8.3.2", + "whatwg-mimetype": "3.0.0", "xml-crypto": "^2.1.3" }, "repository": { @@ -53,6 +53,7 @@ "@types/request": "^2.48.7", "@types/sax": "^1.2.3", "@types/uuid": "^8.3.1", + "@types/whatwg-mimetype": "^2.1.1", "body-parser": "^1.15.2", "colors": "^1.3.3", "coveralls": "^3.1.1", diff --git a/src/http.ts b/src/http.ts index a9d4f41d7..63207fb99 100644 --- a/src/http.ts +++ b/src/http.ts @@ -5,12 +5,11 @@ import * as req from 'axios'; import { NtlmClient } from 'axios-ntlm'; -import * as contentTypeParser from 'content-type-parser'; import * as debugBuilder from 'debug'; import { ReadStream } from 'fs'; import * as url from 'url'; - import { v4 as uuidv4 } from 'uuid'; +import MIMEType = require('whatwg-mimetype'); import { gzipSync } from 'zlib'; import { IExOptions, IHeaders, IHttpClient, IMTOMAttachments, IOptions } from './types'; import { parseMTOMResp } from './utils'; @@ -212,9 +211,9 @@ export class HttpClient implements IHttpClient { const isMultipartResp = res.headers['content-type'] && res.headers['content-type'].toLowerCase().indexOf('multipart/related') > -1; if (isMultipartResp) { let boundary; - const parsedContentType = contentTypeParser(res.headers['content-type']); - if (parsedContentType && parsedContentType.parameterList) { - boundary = ((parsedContentType.parameterList as any[]).find((item) => item.key === 'boundary') || {}).value; + const parsedContentType = MIMEType.parse(res.headers['content-type']); + if (parsedContentType) { + boundary = parsedContentType.parameters.get('boundary'); } if (!boundary) { return callback(new Error('Missing boundary from content-type'));