From b1bf582203059de707b01896031c101b7cd5ff0f Mon Sep 17 00:00:00 2001 From: Rikki Gibson Date: Tue, 5 Jun 2018 15:34:11 -0700 Subject: [PATCH] Require granular uuidv4. Remove process polyfill. Remove withCredentials: true in axios. --- lib/axiosHttpClient.ts | 2 -- lib/util/utils.ts | 8 ++++---- test/testUtils.ts | 2 +- tsconfig.webpack.json => tsconfig.es.json | 3 ++- webpack.config.ts | 2 +- webpack.testconfig.ts | 2 +- 6 files changed, 9 insertions(+), 10 deletions(-) rename tsconfig.webpack.json => tsconfig.es.json (61%) diff --git a/lib/axiosHttpClient.ts b/lib/axiosHttpClient.ts index 9533045..b8034c0 100644 --- a/lib/axiosHttpClient.ts +++ b/lib/axiosHttpClient.ts @@ -122,8 +122,6 @@ export class AxiosHttpClient implements HttpClient { data: axiosBody, transformResponse: undefined, validateStatus: () => true, - maxRedirects: 0, - withCredentials: true, // Workaround for https://github.com/axios/axios/issues/1362 maxContentLength: 1024 * 1024 * 1024 * 10, responseType: httpRequest.rawResponse ? (isNode ? "stream" : "blob") : "text", diff --git a/lib/util/utils.ts b/lib/util/utils.ts index 550fcb0..ea7b54f 100644 --- a/lib/util/utils.ts +++ b/lib/util/utils.ts @@ -2,7 +2,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. import * as xml2js from "isomorphic-xml2js"; -import * as uuid from "uuid"; +import * as uuidv4 from "uuid/v4"; import { HttpOperationResponse } from "../httpOperationResponse"; import { RestError } from "../restError"; import { WebResource } from "../webResource"; @@ -132,7 +132,7 @@ export function objectValues(obj: { [key: string]: any; }): any[] { * @return {string} RFC4122 v4 UUID. */ export function generateUuid(): string { - return uuid.v4(); + return uuidv4(); } /* @@ -200,9 +200,9 @@ export function promiseToCallback(promise: Promise): Function { } return (cb: Function): void => { promise.then((data: any) => { - process.nextTick(cb, undefined, data); + cb(undefined, data); }, (err: Error) => { - process.nextTick(cb, err); + cb(err); }); }; } diff --git a/test/testUtils.ts b/test/testUtils.ts index 5172edd..7f081b9 100644 --- a/test/testUtils.ts +++ b/test/testUtils.ts @@ -2,7 +2,7 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // parseInt just gives NaN (falsy) for undefined/null -const port = parseInt(process.env.PORT!) || 3001; +const port = (typeof process !== "undefined" && parseInt(process.env.PORT!)) || 3001; /** * Base URL for the ms-rest-js testserver. diff --git a/tsconfig.webpack.json b/tsconfig.es.json similarity index 61% rename from tsconfig.webpack.json rename to tsconfig.es.json index 88c8f07..dae744d 100644 --- a/tsconfig.webpack.json +++ b/tsconfig.es.json @@ -1,6 +1,7 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "module": "es6" + "module": "es6", + "outDir": "es" } } diff --git a/webpack.config.ts b/webpack.config.ts index b4a666d..46cd8f3 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -31,7 +31,7 @@ const config: webpack.Configuration = { tty: false, v8: false, Buffer: false, - process: true, + process: false, stream: false } }; diff --git a/webpack.testconfig.ts b/webpack.testconfig.ts index 770f1f6..799becd 100644 --- a/webpack.testconfig.ts +++ b/webpack.testconfig.ts @@ -34,7 +34,7 @@ const config: webpack.Configuration = { tty: false, v8: false, Buffer: false, - process: true, + process: false, stream: false } };