ibm-cloud-sdk-core 5.4.17 → 5.4.18

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.
@@ -29,22 +29,12 @@ var __extends = (this && this.__extends) || (function () {
29
29
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
30
30
  };
31
31
  })();
32
- var __assign = (this && this.__assign) || function () {
33
- __assign = Object.assign || function(t) {
34
- for (var s, i = 1, n = arguments.length; i < n; i++) {
35
- s = arguments[i];
36
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
37
- t[p] = s[p];
38
- }
39
- return t;
40
- };
41
- return __assign.apply(this, arguments);
42
- };
43
32
  var __importDefault = (this && this.__importDefault) || function (mod) {
44
33
  return (mod && mod.__esModule) ? mod : { "default": mod };
45
34
  };
46
35
  Object.defineProperty(exports, "__esModule", { value: true });
47
36
  exports.BasicAuthenticator = void 0;
37
+ var extend_1 = __importDefault(require("extend"));
48
38
  var helpers_1 = require("../utils/helpers");
49
39
  var authenticator_1 = require("./authenticator");
50
40
  var logger_1 = __importDefault(require("../../lib/logger"));
@@ -89,7 +79,7 @@ var BasicAuthenticator = /** @class */ (function (_super) {
89
79
  BasicAuthenticator.prototype.authenticate = function (requestOptions) {
90
80
  var _this = this;
91
81
  return new Promise(function (resolve) {
92
- requestOptions.headers = __assign(__assign({}, requestOptions.headers), _this.authHeader);
82
+ requestOptions.headers = (0, extend_1.default)(true, {}, requestOptions.headers, _this.authHeader);
93
83
  logger_1.default.debug("Authenticated outbound request (type=".concat(_this.authenticationType(), ")"));
94
84
  resolve();
95
85
  });
@@ -29,22 +29,12 @@ var __extends = (this && this.__extends) || (function () {
29
29
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
30
30
  };
31
31
  })();
32
- var __assign = (this && this.__assign) || function () {
33
- __assign = Object.assign || function(t) {
34
- for (var s, i = 1, n = arguments.length; i < n; i++) {
35
- s = arguments[i];
36
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
37
- t[p] = s[p];
38
- }
39
- return t;
40
- };
41
- return __assign.apply(this, arguments);
42
- };
43
32
  var __importDefault = (this && this.__importDefault) || function (mod) {
44
33
  return (mod && mod.__esModule) ? mod : { "default": mod };
45
34
  };
46
35
  Object.defineProperty(exports, "__esModule", { value: true });
47
36
  exports.BearerTokenAuthenticator = void 0;
37
+ var extend_1 = __importDefault(require("extend"));
48
38
  var helpers_1 = require("../utils/helpers");
49
39
  var authenticator_1 = require("./authenticator");
50
40
  var logger_1 = __importDefault(require("../../lib/logger"));
@@ -94,7 +84,7 @@ var BearerTokenAuthenticator = /** @class */ (function (_super) {
94
84
  var _this = this;
95
85
  return new Promise(function (resolve) {
96
86
  var authHeader = { Authorization: "Bearer ".concat(_this.bearerToken) };
97
- requestOptions.headers = __assign(__assign({}, requestOptions.headers), authHeader);
87
+ requestOptions.headers = (0, extend_1.default)(true, {}, requestOptions.headers, authHeader);
98
88
  logger_1.default.debug("Authenticated outbound request (type=".concat(_this.authenticationType(), ")"));
99
89
  resolve();
100
90
  });
@@ -29,22 +29,12 @@ var __extends = (this && this.__extends) || (function () {
29
29
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
30
30
  };
31
31
  })();
32
- var __assign = (this && this.__assign) || function () {
33
- __assign = Object.assign || function(t) {
34
- for (var s, i = 1, n = arguments.length; i < n; i++) {
35
- s = arguments[i];
36
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
37
- t[p] = s[p];
38
- }
39
- return t;
40
- };
41
- return __assign.apply(this, arguments);
42
- };
43
32
  var __importDefault = (this && this.__importDefault) || function (mod) {
44
33
  return (mod && mod.__esModule) ? mod : { "default": mod };
45
34
  };
46
35
  Object.defineProperty(exports, "__esModule", { value: true });
47
36
  exports.TokenRequestBasedAuthenticatorImmutable = void 0;
37
+ var extend_1 = __importDefault(require("extend"));
48
38
  var jwt_token_manager_1 = require("../token-managers/jwt-token-manager");
49
39
  var authenticator_1 = require("./authenticator");
50
40
  var logger_1 = __importDefault(require("../../lib/logger"));
@@ -92,7 +82,7 @@ var TokenRequestBasedAuthenticatorImmutable = /** @class */ (function (_super) {
92
82
  var _this = this;
93
83
  return this.tokenManager.getToken().then(function (token) {
94
84
  var authHeader = { Authorization: "Bearer ".concat(token) };
95
- requestOptions.headers = __assign(__assign({}, requestOptions.headers), authHeader);
85
+ requestOptions.headers = (0, extend_1.default)(true, {}, requestOptions.headers, authHeader);
96
86
  logger_1.default.debug("Authenticated outbound request (type=".concat(_this.authenticationType(), ")"));
97
87
  });
98
88
  };
@@ -29,22 +29,12 @@ var __extends = (this && this.__extends) || (function () {
29
29
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
30
30
  };
31
31
  })();
32
- var __assign = (this && this.__assign) || function () {
33
- __assign = Object.assign || function(t) {
34
- for (var s, i = 1, n = arguments.length; i < n; i++) {
35
- s = arguments[i];
36
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
37
- t[p] = s[p];
38
- }
39
- return t;
40
- };
41
- return __assign.apply(this, arguments);
42
- };
43
32
  var __importDefault = (this && this.__importDefault) || function (mod) {
44
33
  return (mod && mod.__esModule) ? mod : { "default": mod };
45
34
  };
46
35
  Object.defineProperty(exports, "__esModule", { value: true });
47
36
  exports.Cp4dTokenManager = void 0;
37
+ var extend_1 = __importDefault(require("extend"));
48
38
  var helpers_1 = require("../utils/helpers");
49
39
  var build_user_agent_1 = require("../../lib/build-user-agent");
50
40
  var jwt_token_manager_1 = require("./jwt-token-manager");
@@ -106,7 +96,7 @@ var Cp4dTokenManager = /** @class */ (function (_super) {
106
96
  api_key: this.apikey,
107
97
  },
108
98
  method: 'POST',
109
- headers: __assign(__assign({}, this.headers), requiredHeaders),
99
+ headers: (0, extend_1.default)(true, {}, this.headers, requiredHeaders),
110
100
  rejectUnauthorized: !this.disableSslVerification,
111
101
  },
112
102
  };
@@ -29,22 +29,12 @@ var __extends = (this && this.__extends) || (function () {
29
29
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
30
30
  };
31
31
  })();
32
- var __assign = (this && this.__assign) || function () {
33
- __assign = Object.assign || function(t) {
34
- for (var s, i = 1, n = arguments.length; i < n; i++) {
35
- s = arguments[i];
36
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
37
- t[p] = s[p];
38
- }
39
- return t;
40
- };
41
- return __assign.apply(this, arguments);
42
- };
43
32
  var __importDefault = (this && this.__importDefault) || function (mod) {
44
33
  return (mod && mod.__esModule) ? mod : { "default": mod };
45
34
  };
46
35
  Object.defineProperty(exports, "__esModule", { value: true });
47
36
  exports.IamRequestBasedTokenManager = void 0;
37
+ var extend_1 = __importDefault(require("extend"));
48
38
  var logger_1 = __importDefault(require("../../lib/logger"));
49
39
  var helpers_1 = require("../utils/helpers");
50
40
  var jwt_token_manager_1 = require("./jwt-token-manager");
@@ -165,7 +155,7 @@ var IamRequestBasedTokenManager = /** @class */ (function (_super) {
165
155
  options: {
166
156
  url: this.url + OPERATION_PATH,
167
157
  method: 'POST',
168
- headers: __assign(__assign({}, this.headers), requiredHeaders),
158
+ headers: (0, extend_1.default)(true, {}, this.headers, requiredHeaders),
169
159
  form: this.formData,
170
160
  rejectUnauthorized: !this.disableSslVerification,
171
161
  },
@@ -29,22 +29,12 @@ var __extends = (this && this.__extends) || (function () {
29
29
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
30
30
  };
31
31
  })();
32
- var __assign = (this && this.__assign) || function () {
33
- __assign = Object.assign || function(t) {
34
- for (var s, i = 1, n = arguments.length; i < n; i++) {
35
- s = arguments[i];
36
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
37
- t[p] = s[p];
38
- }
39
- return t;
40
- };
41
- return __assign.apply(this, arguments);
42
- };
43
32
  var __importDefault = (this && this.__importDefault) || function (mod) {
44
33
  return (mod && mod.__esModule) ? mod : { "default": mod };
45
34
  };
46
35
  Object.defineProperty(exports, "__esModule", { value: true });
47
36
  exports.McspTokenManager = void 0;
37
+ var extend_1 = __importDefault(require("extend"));
48
38
  var helpers_1 = require("../utils/helpers");
49
39
  var build_user_agent_1 = require("../../lib/build-user-agent");
50
40
  var jwt_token_manager_1 = require("./jwt-token-manager");
@@ -97,7 +87,7 @@ var McspTokenManager = /** @class */ (function (_super) {
97
87
  apikey: this.apikey,
98
88
  },
99
89
  method: 'POST',
100
- headers: __assign(__assign({}, this.headers), requiredHeaders),
90
+ headers: (0, extend_1.default)(true, {}, this.headers, requiredHeaders),
101
91
  rejectUnauthorized: !this.disableSslVerification,
102
92
  },
103
93
  };
@@ -29,22 +29,12 @@ var __extends = (this && this.__extends) || (function () {
29
29
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
30
30
  };
31
31
  })();
32
- var __assign = (this && this.__assign) || function () {
33
- __assign = Object.assign || function(t) {
34
- for (var s, i = 1, n = arguments.length; i < n; i++) {
35
- s = arguments[i];
36
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
37
- t[p] = s[p];
38
- }
39
- return t;
40
- };
41
- return __assign.apply(this, arguments);
42
- };
43
32
  var __importDefault = (this && this.__importDefault) || function (mod) {
44
33
  return (mod && mod.__esModule) ? mod : { "default": mod };
45
34
  };
46
35
  Object.defineProperty(exports, "__esModule", { value: true });
47
36
  exports.McspV2TokenManager = void 0;
37
+ var extend_1 = __importDefault(require("extend"));
48
38
  var helpers_1 = require("../utils/helpers");
49
39
  var build_user_agent_1 = require("../../lib/build-user-agent");
50
40
  var jwt_token_manager_1 = require("./jwt-token-manager");
@@ -125,7 +115,7 @@ var McspV2TokenManager = /** @class */ (function (_super) {
125
115
  'Content-Type': 'application/json',
126
116
  'User-Agent': this.userAgent,
127
117
  };
128
- var requestHeaders = __assign(__assign({}, this.headers), requiredHeaders);
118
+ var requestHeaders = (0, extend_1.default)(true, {}, this.headers, requiredHeaders);
129
119
  // The keys used here must match the path parameter references in PATH_TEMPLATE above.
130
120
  var pathParams = {
131
121
  scopeCollectionType: this.scopeCollectionType,
@@ -3270,67 +3270,6 @@
3270
3270
  },
3271
3271
  "implementsTokenRanges": []
3272
3272
  },
3273
- {
3274
- "kind": "Function",
3275
- "canonicalReference": "ibm-cloud-sdk-core!deepMerge:function(1)",
3276
- "docComment": "",
3277
- "excerptTokens": [
3278
- {
3279
- "kind": "Content",
3280
- "text": "export declare function deepMerge(target: "
3281
- },
3282
- {
3283
- "kind": "Content",
3284
- "text": "any"
3285
- },
3286
- {
3287
- "kind": "Content",
3288
- "text": ", source: "
3289
- },
3290
- {
3291
- "kind": "Content",
3292
- "text": "any"
3293
- },
3294
- {
3295
- "kind": "Content",
3296
- "text": "): "
3297
- },
3298
- {
3299
- "kind": "Content",
3300
- "text": "any"
3301
- },
3302
- {
3303
- "kind": "Content",
3304
- "text": ";"
3305
- }
3306
- ],
3307
- "fileUrlPath": "dist/es/lib/helper.d.ts",
3308
- "returnTypeTokenRange": {
3309
- "startIndex": 5,
3310
- "endIndex": 6
3311
- },
3312
- "releaseTag": "Public",
3313
- "overloadIndex": 1,
3314
- "parameters": [
3315
- {
3316
- "parameterName": "target",
3317
- "parameterTypeTokenRange": {
3318
- "startIndex": 1,
3319
- "endIndex": 2
3320
- },
3321
- "isOptional": false
3322
- },
3323
- {
3324
- "parameterName": "source",
3325
- "parameterTypeTokenRange": {
3326
- "startIndex": 3,
3327
- "endIndex": 4
3328
- },
3329
- "isOptional": false
3330
- }
3331
- ],
3332
- "name": "deepMerge"
3333
- },
3334
3273
  {
3335
3274
  "kind": "Function",
3336
3275
  "canonicalReference": "ibm-cloud-sdk-core!fileExistsAtPath:function(1)",
@@ -13,6 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import extend from 'extend';
16
17
  import { computeBasicAuthHeader, validateInput } from '../utils/helpers';
17
18
  import { Authenticator } from './authenticator';
18
19
  import logger from '../../lib/logger';
@@ -54,7 +55,7 @@ export class BasicAuthenticator extends Authenticator {
54
55
  */
55
56
  authenticate(requestOptions) {
56
57
  return new Promise((resolve) => {
57
- requestOptions.headers = Object.assign(Object.assign({}, requestOptions.headers), this.authHeader);
58
+ requestOptions.headers = extend(true, {}, requestOptions.headers, this.authHeader);
58
59
  logger.debug(`Authenticated outbound request (type=${this.authenticationType()})`);
59
60
  resolve();
60
61
  });
@@ -13,6 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import extend from 'extend';
16
17
  import { validateInput } from '../utils/helpers';
17
18
  import { Authenticator } from './authenticator';
18
19
  import logger from '../../lib/logger';
@@ -59,7 +60,7 @@ export class BearerTokenAuthenticator extends Authenticator {
59
60
  authenticate(requestOptions) {
60
61
  return new Promise((resolve) => {
61
62
  const authHeader = { Authorization: `Bearer ${this.bearerToken}` };
62
- requestOptions.headers = Object.assign(Object.assign({}, requestOptions.headers), authHeader);
63
+ requestOptions.headers = extend(true, {}, requestOptions.headers, authHeader);
63
64
  logger.debug(`Authenticated outbound request (type=${this.authenticationType()})`);
64
65
  resolve();
65
66
  });
@@ -13,6 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import extend from 'extend';
16
17
  import { JwtTokenManager } from '../token-managers/jwt-token-manager';
17
18
  import { Authenticator } from './authenticator';
18
19
  import logger from '../../lib/logger';
@@ -57,7 +58,7 @@ export class TokenRequestBasedAuthenticatorImmutable extends Authenticator {
57
58
  authenticate(requestOptions) {
58
59
  return this.tokenManager.getToken().then((token) => {
59
60
  const authHeader = { Authorization: `Bearer ${token}` };
60
- requestOptions.headers = Object.assign(Object.assign({}, requestOptions.headers), authHeader);
61
+ requestOptions.headers = extend(true, {}, requestOptions.headers, authHeader);
61
62
  logger.debug(`Authenticated outbound request (type=${this.authenticationType()})`);
62
63
  });
63
64
  }
@@ -13,6 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import extend from 'extend';
16
17
  import { validateInput } from '../utils/helpers';
17
18
  import { buildUserAgent } from '../../lib/build-user-agent';
18
19
  import { JwtTokenManager } from './jwt-token-manager';
@@ -72,7 +73,7 @@ export class Cp4dTokenManager extends JwtTokenManager {
72
73
  api_key: this.apikey,
73
74
  },
74
75
  method: 'POST',
75
- headers: Object.assign(Object.assign({}, this.headers), requiredHeaders),
76
+ headers: extend(true, {}, this.headers, requiredHeaders),
76
77
  rejectUnauthorized: !this.disableSslVerification,
77
78
  },
78
79
  };
@@ -13,6 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import extend from 'extend';
16
17
  import logger from '../../lib/logger';
17
18
  import { computeBasicAuthHeader, getCurrentTime, onlyOne, removeSuffix } from '../utils/helpers';
18
19
  import { JwtTokenManager } from './jwt-token-manager';
@@ -130,7 +131,7 @@ export class IamRequestBasedTokenManager extends JwtTokenManager {
130
131
  options: {
131
132
  url: this.url + OPERATION_PATH,
132
133
  method: 'POST',
133
- headers: Object.assign(Object.assign({}, this.headers), requiredHeaders),
134
+ headers: extend(true, {}, this.headers, requiredHeaders),
134
135
  form: this.formData,
135
136
  rejectUnauthorized: !this.disableSslVerification,
136
137
  },
@@ -13,6 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import extend from 'extend';
16
17
  import { validateInput } from '../utils/helpers';
17
18
  import { buildUserAgent } from '../../lib/build-user-agent';
18
19
  import { JwtTokenManager } from './jwt-token-manager';
@@ -63,7 +64,7 @@ export class McspTokenManager extends JwtTokenManager {
63
64
  apikey: this.apikey,
64
65
  },
65
66
  method: 'POST',
66
- headers: Object.assign(Object.assign({}, this.headers), requiredHeaders),
67
+ headers: extend(true, {}, this.headers, requiredHeaders),
67
68
  rejectUnauthorized: !this.disableSslVerification,
68
69
  },
69
70
  };
@@ -13,6 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import extend from 'extend';
16
17
  import { validateInput } from '../utils/helpers';
17
18
  import { buildUserAgent } from '../../lib/build-user-agent';
18
19
  import { JwtTokenManager } from './jwt-token-manager';
@@ -91,7 +92,7 @@ export class McspV2TokenManager extends JwtTokenManager {
91
92
  'Content-Type': 'application/json',
92
93
  'User-Agent': this.userAgent,
93
94
  };
94
- const requestHeaders = Object.assign(Object.assign({}, this.headers), requiredHeaders);
95
+ const requestHeaders = extend(true, {}, this.headers, requiredHeaders);
95
96
  // The keys used here must match the path parameter references in PATH_TEMPLATE above.
96
97
  const pathParams = {
97
98
  scopeCollectionType: this.scopeCollectionType,
@@ -13,6 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import extend from 'extend';
16
17
  import { checkCredentials, readExternalSources } from '../auth';
17
18
  import { stripTrailingSlash } from './helper';
18
19
  import logger from './logger';
@@ -205,7 +206,7 @@ export class BaseService {
205
206
  const userAgent = {
206
207
  'User-Agent': this.defaultUserAgent,
207
208
  };
208
- parameters.defaultOptions.headers = Object.assign(Object.assign({}, userAgent), parameters.defaultOptions.headers);
209
+ parameters.defaultOptions.headers = extend(true, {}, userAgent, parameters.defaultOptions.headers);
209
210
  return this.authenticator.authenticate(parameters.defaultOptions).then(() =>
210
211
  // resolve() handles rejection as well, so resolving the result of sendRequest should allow for proper handling later
211
212
  this.requestWrapperInstance.sendRequest(parameters));
@@ -23,6 +23,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
23
23
  });
24
24
  };
25
25
  import { isAxiosError } from 'axios';
26
+ import extend from 'extend';
26
27
  import { CookieJar } from 'tough-cookie';
27
28
  import logger from './logger';
28
29
  const internalCreateCookieInterceptor = (cookieJar) => {
@@ -41,7 +42,8 @@ const internalCreateCookieInterceptor = (cookieJar) => {
41
42
  const cookieHeaderValue = yield cookieJar.getCookieString(config.url);
42
43
  if (cookieHeaderValue) {
43
44
  logger.debug('CookieInterceptor: setting cookie header');
44
- config.headers.cookie = cookieHeaderValue;
45
+ const cookieHeader = { cookie: cookieHeaderValue };
46
+ config.headers = extend(true, {}, config.headers, cookieHeader);
45
47
  }
46
48
  else {
47
49
  logger.debug(`CookieInterceptor: no cookies for: ${config.url}`);
@@ -126,4 +126,3 @@ export declare function constructServiceUrl(parameterizedUrl: string, defaultUrl
126
126
  * @returns true if "mimeType" represents a JSON media type and false otherwise
127
127
  */
128
128
  export declare function isJsonMimeType(mimeType: string): boolean;
129
- export declare function deepMerge(target: any, source: any): any;
package/es/lib/helper.js CHANGED
@@ -310,44 +310,3 @@ export function isJsonMimeType(mimeType) {
310
310
  logger.debug(`Determining if the mime type '${mimeType}' specifies JSON content.`);
311
311
  return !!mimeType && /^application\/json(\s*;.*)?$/i.test(mimeType);
312
312
  }
313
- const isObj = (val) => val && typeof val === 'object' && !Array.isArray(val);
314
- /**
315
- * Deep clone a value (object, array, or primitive)
316
- * @param value - The value to clone
317
- * @returns A deep clone of the value
318
- */
319
- function deepClone(value) {
320
- if (value == null) {
321
- return value;
322
- }
323
- // Handle arrays - create a new array with cloned elements
324
- if (Array.isArray(value)) {
325
- return value.map((item) => deepClone(item));
326
- }
327
- // Handle objects - create a new object with cloned properties
328
- if (typeof value === 'object') {
329
- const cloned = {};
330
- Object.keys(value).forEach((key) => {
331
- cloned[key] = deepClone(value[key]);
332
- });
333
- return cloned;
334
- }
335
- // Handle primitives (string, number, boolean, etc.)
336
- return value;
337
- }
338
- export function deepMerge(target, source) {
339
- // Handle null/undefined inputs by treating them as empty objects
340
- const safeTarget = target || {};
341
- const safeSource = source || {};
342
- const result = Object.assign({}, safeTarget);
343
- Object.keys(safeSource).forEach((key) => {
344
- if (isObj(safeTarget[key]) && isObj(safeSource[key])) {
345
- result[key] = deepMerge(safeTarget[key], safeSource[key]);
346
- }
347
- else {
348
- // Clone the source value to prevent mutation of the original
349
- result[key] = deepClone(safeSource[key]);
350
- }
351
- });
352
- return result;
353
- }
@@ -25,12 +25,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
25
25
  */
26
26
  import axios from 'axios';
27
27
  import * as rax from 'retry-axios';
28
+ import extend from 'extend';
28
29
  import FormData from 'form-data';
29
30
  import { Agent } from 'https';
30
31
  import isStream from 'isstream';
31
32
  import { stringify } from 'querystring';
32
33
  import { gzipSync } from 'zlib';
33
- import { buildRequestFileObject, deepMerge, isEmptyObject, isFileData, isFileWithMetadata, isJsonMimeType, stripTrailingSlash, } from './helper';
34
+ import { buildRequestFileObject, isEmptyObject, isFileData, isFileWithMetadata, isJsonMimeType, stripTrailingSlash, } from './helper';
34
35
  import { redactSecrets } from './private-helpers';
35
36
  import logger from './logger';
36
37
  import { streamToPromise } from './stream-to-promise';
@@ -38,10 +39,15 @@ import { createCookieInterceptor } from './cookie-support';
38
39
  import { chainError } from './chain-error';
39
40
  export class RequestWrapper {
40
41
  constructor(axiosOptions) {
41
- axiosOptions !== null && axiosOptions !== void 0 ? axiosOptions : (axiosOptions = {});
42
+ axiosOptions = axiosOptions || {};
42
43
  this.compressRequestData = Boolean(axiosOptions.enableGzipCompression);
43
- // override a couple axios defaults then merge axios config into default
44
- const axiosConfig = Object.assign({ maxContentLength: -1, maxBodyLength: Infinity }, axiosOptions);
44
+ // override a couple axios defaults
45
+ const axiosConfig = {
46
+ maxContentLength: -1,
47
+ maxBodyLength: Infinity,
48
+ };
49
+ // merge axios config into default
50
+ extend(true, axiosConfig, axiosOptions);
45
51
  // if the user explicitly sets `disableSslVerification` to true,
46
52
  // `rejectUnauthorized` must be set to false in the https agent
47
53
  if (axiosOptions.disableSslVerification === true) {
@@ -190,7 +196,7 @@ export class RequestWrapper {
190
196
  */
191
197
  sendRequest(parameters) {
192
198
  return __awaiter(this, void 0, void 0, function* () {
193
- const options = deepMerge(parameters.defaultOptions, parameters.options);
199
+ const options = extend(true, {}, parameters.defaultOptions, parameters.options);
194
200
  const { path, body, form, formData, qs, method, serviceUrl, axiosOptions } = options;
195
201
  let { headers, url } = options;
196
202
  const multipartForm = new FormData();
@@ -243,10 +249,10 @@ export class RequestWrapper {
243
249
  if (formData) {
244
250
  data = multipartForm;
245
251
  // form-data generates headers that MUST be included or the request will fail
246
- headers = Object.assign(Object.assign({}, headers), multipartForm.getHeaders());
252
+ headers = extend(true, {}, headers, multipartForm.getHeaders());
247
253
  }
248
254
  // accept gzip encoded responses if Accept-Encoding is not already set
249
- headers['Accept-Encoding'] || (headers['Accept-Encoding'] = 'gzip');
255
+ headers['Accept-Encoding'] = headers['Accept-Encoding'] || 'gzip';
250
256
  // compress request body data if enabled
251
257
  if (this.compressRequestData) {
252
258
  data = yield this.gzipRequestBody(data, headers);
@@ -591,8 +591,6 @@ export declare class Cp4dTokenManager extends JwtTokenManager {
591
591
  protected requestToken(): Promise<any>;
592
592
  }
593
593
 
594
- export declare function deepMerge(target: any, source: any): any;
595
-
596
594
  export declare function fileExistsAtPath(filepath: string): boolean;
597
595
 
598
596
  /**
@@ -30,6 +30,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
30
30
  };
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
32
  exports.BaseService = void 0;
33
+ var extend_1 = __importDefault(require("extend"));
33
34
  var auth_1 = require("../auth");
34
35
  var helper_1 = require("./helper");
35
36
  var logger_1 = __importDefault(require("./logger"));
@@ -223,7 +224,7 @@ var BaseService = /** @class */ (function () {
223
224
  var userAgent = {
224
225
  'User-Agent': this.defaultUserAgent,
225
226
  };
226
- parameters.defaultOptions.headers = __assign(__assign({}, userAgent), parameters.defaultOptions.headers);
227
+ parameters.defaultOptions.headers = (0, extend_1.default)(true, {}, userAgent, parameters.defaultOptions.headers);
227
228
  return this.authenticator.authenticate(parameters.defaultOptions).then(function () {
228
229
  // resolve() handles rejection as well, so resolving the result of sendRequest should allow for proper handling later
229
230
  return _this.requestWrapperInstance.sendRequest(parameters);
@@ -56,6 +56,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
56
56
  Object.defineProperty(exports, "__esModule", { value: true });
57
57
  exports.createCookieInterceptor = void 0;
58
58
  var axios_1 = require("axios");
59
+ var extend_1 = __importDefault(require("extend"));
59
60
  var tough_cookie_1 = require("tough-cookie");
60
61
  var logger_1 = __importDefault(require("./logger"));
61
62
  var internalCreateCookieInterceptor = function (cookieJar) {
@@ -68,7 +69,7 @@ var internalCreateCookieInterceptor = function (cookieJar) {
68
69
  */
69
70
  function requestInterceptor(config) {
70
71
  return __awaiter(this, void 0, void 0, function () {
71
- var cookieHeaderValue;
72
+ var cookieHeaderValue, cookieHeader;
72
73
  return __generator(this, function (_a) {
73
74
  switch (_a.label) {
74
75
  case 0:
@@ -80,7 +81,8 @@ var internalCreateCookieInterceptor = function (cookieJar) {
80
81
  cookieHeaderValue = _a.sent();
81
82
  if (cookieHeaderValue) {
82
83
  logger_1.default.debug('CookieInterceptor: setting cookie header');
83
- config.headers.cookie = cookieHeaderValue;
84
+ cookieHeader = { cookie: cookieHeaderValue };
85
+ config.headers = (0, extend_1.default)(true, {}, config.headers, cookieHeader);
84
86
  }
85
87
  else {
86
88
  logger_1.default.debug("CookieInterceptor: no cookies for: ".concat(config.url));
package/lib/helper.d.ts CHANGED
@@ -126,4 +126,3 @@ export declare function constructServiceUrl(parameterizedUrl: string, defaultUrl
126
126
  * @returns true if "mimeType" represents a JSON media type and false otherwise
127
127
  */
128
128
  export declare function isJsonMimeType(mimeType: string): boolean;
129
- export declare function deepMerge(target: any, source: any): any;
package/lib/helper.js CHANGED
@@ -14,17 +14,6 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- var __assign = (this && this.__assign) || function () {
18
- __assign = Object.assign || function(t) {
19
- for (var s, i = 1, n = arguments.length; i < n; i++) {
20
- s = arguments[i];
21
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
- t[p] = s[p];
23
- }
24
- return t;
25
- };
26
- return __assign.apply(this, arguments);
27
- };
28
17
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
29
18
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
30
19
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -74,7 +63,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
74
63
  return (mod && mod.__esModule) ? mod : { "default": mod };
75
64
  };
76
65
  Object.defineProperty(exports, "__esModule", { value: true });
77
- exports.deepMerge = exports.isJsonMimeType = exports.constructServiceUrl = exports.toLowerKeys = exports.buildRequestFileObject = exports.getFormat = exports.isHTML = exports.validateParams = exports.getMissingParams = exports.getQueryParam = exports.stripTrailingSlash = exports.getContentType = exports.isEmptyObject = exports.isFileData = exports.isFileWithMetadata = void 0;
66
+ exports.isJsonMimeType = exports.constructServiceUrl = exports.toLowerKeys = exports.buildRequestFileObject = exports.getFormat = exports.isHTML = exports.validateParams = exports.getMissingParams = exports.getQueryParam = exports.stripTrailingSlash = exports.getContentType = exports.isEmptyObject = exports.isFileData = exports.isFileWithMetadata = void 0;
78
67
  var isstream_1 = require("isstream");
79
68
  var mime_types_1 = require("mime-types");
80
69
  var path_1 = require("path");
@@ -394,45 +383,3 @@ function isJsonMimeType(mimeType) {
394
383
  return !!mimeType && /^application\/json(\s*;.*)?$/i.test(mimeType);
395
384
  }
396
385
  exports.isJsonMimeType = isJsonMimeType;
397
- var isObj = function (val) { return val && typeof val === 'object' && !Array.isArray(val); };
398
- /**
399
- * Deep clone a value (object, array, or primitive)
400
- * @param value - The value to clone
401
- * @returns A deep clone of the value
402
- */
403
- function deepClone(value) {
404
- if (value == null) {
405
- return value;
406
- }
407
- // Handle arrays - create a new array with cloned elements
408
- if (Array.isArray(value)) {
409
- return value.map(function (item) { return deepClone(item); });
410
- }
411
- // Handle objects - create a new object with cloned properties
412
- if (typeof value === 'object') {
413
- var cloned_1 = {};
414
- Object.keys(value).forEach(function (key) {
415
- cloned_1[key] = deepClone(value[key]);
416
- });
417
- return cloned_1;
418
- }
419
- // Handle primitives (string, number, boolean, etc.)
420
- return value;
421
- }
422
- function deepMerge(target, source) {
423
- // Handle null/undefined inputs by treating them as empty objects
424
- var safeTarget = target || {};
425
- var safeSource = source || {};
426
- var result = __assign({}, safeTarget);
427
- Object.keys(safeSource).forEach(function (key) {
428
- if (isObj(safeTarget[key]) && isObj(safeSource[key])) {
429
- result[key] = deepMerge(safeTarget[key], safeSource[key]);
430
- }
431
- else {
432
- // Clone the source value to prevent mutation of the original
433
- result[key] = deepClone(safeSource[key]);
434
- }
435
- });
436
- return result;
437
- }
438
- exports.deepMerge = deepMerge;
@@ -92,6 +92,7 @@ exports.RequestWrapper = void 0;
92
92
  */
93
93
  var axios_1 = __importDefault(require("axios"));
94
94
  var rax = __importStar(require("retry-axios"));
95
+ var extend_1 = __importDefault(require("extend"));
95
96
  var form_data_1 = __importDefault(require("form-data"));
96
97
  var https_1 = require("https");
97
98
  var isstream_1 = __importDefault(require("isstream"));
@@ -106,10 +107,15 @@ var chain_error_1 = require("./chain-error");
106
107
  var RequestWrapper = /** @class */ (function () {
107
108
  function RequestWrapper(axiosOptions) {
108
109
  var _this = this;
109
- axiosOptions !== null && axiosOptions !== void 0 ? axiosOptions : (axiosOptions = {});
110
+ axiosOptions = axiosOptions || {};
110
111
  this.compressRequestData = Boolean(axiosOptions.enableGzipCompression);
111
- // override a couple axios defaults then merge axios config into default
112
- var axiosConfig = __assign({ maxContentLength: -1, maxBodyLength: Infinity }, axiosOptions);
112
+ // override a couple axios defaults
113
+ var axiosConfig = {
114
+ maxContentLength: -1,
115
+ maxBodyLength: Infinity,
116
+ };
117
+ // merge axios config into default
118
+ (0, extend_1.default)(true, axiosConfig, axiosOptions);
113
119
  // if the user explicitly sets `disableSslVerification` to true,
114
120
  // `rejectUnauthorized` must be set to false in the https agent
115
121
  if (axiosOptions.disableSslVerification === true) {
@@ -263,7 +269,7 @@ var RequestWrapper = /** @class */ (function () {
263
269
  return __generator(this, function (_c) {
264
270
  switch (_c.label) {
265
271
  case 0:
266
- options = (0, helper_1.deepMerge)(parameters.defaultOptions, parameters.options);
272
+ options = (0, extend_1.default)(true, {}, parameters.defaultOptions, parameters.options);
267
273
  path = options.path, body = options.body, form = options.form, formData = options.formData, qs = options.qs, method = options.method, serviceUrl = options.serviceUrl, axiosOptions = options.axiosOptions;
268
274
  headers = options.headers, url = options.url;
269
275
  multipartForm = new form_data_1.default();
@@ -327,10 +333,10 @@ var RequestWrapper = /** @class */ (function () {
327
333
  if (formData) {
328
334
  data = multipartForm;
329
335
  // form-data generates headers that MUST be included or the request will fail
330
- headers = __assign(__assign({}, headers), multipartForm.getHeaders());
336
+ headers = (0, extend_1.default)(true, {}, headers, multipartForm.getHeaders());
331
337
  }
332
338
  // accept gzip encoded responses if Accept-Encoding is not already set
333
- headers['Accept-Encoding'] || (headers['Accept-Encoding'] = 'gzip');
339
+ headers['Accept-Encoding'] = headers['Accept-Encoding'] || 'gzip';
334
340
  if (!this.compressRequestData) return [3 /*break*/, 9];
335
341
  return [4 /*yield*/, this.gzipRequestBody(data, headers)];
336
342
  case 8:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ibm-cloud-sdk-core",
3
- "version": "5.4.17",
3
+ "version": "5.4.18",
4
4
  "description": "Core functionality to support SDKs generated with IBM's OpenAPI SDK Generator.",
5
5
  "main": "./index.js",
6
6
  "typings": "./es/index.d.ts",
@@ -45,6 +45,7 @@
45
45
  "camelcase": "6.3.0",
46
46
  "debug": "4.3.4",
47
47
  "dotenv": "16.4.5",
48
+ "extend": "3.0.2",
48
49
  "file-type": "21.3.2",
49
50
  "form-data": "4.0.4",
50
51
  "isstream": "0.1.2",