ibm-cloud-sdk-core 2.17.1 → 2.17.5

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/.cra/.cveignore CHANGED
@@ -1,6 +1,2 @@
1
1
  [
2
- {
3
- "cve": "CVE-2021-3807",
4
- "alwaysOmit": true
5
- }
6
2
  ]
package/CHANGELOG.md CHANGED
@@ -1,3 +1,31 @@
1
+ ## [2.17.5](https://github.com/IBM/node-sdk-core/compare/v2.17.4...v2.17.5) (2021-12-17)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * avoid Buffer re-encode during compression ([#184](https://github.com/IBM/node-sdk-core/issues/184)) ([8b82f36](https://github.com/IBM/node-sdk-core/commit/8b82f36bf6d4ac0163563ce3a10f0a395bd87627))
7
+
8
+ ## [2.17.4](https://github.com/IBM/node-sdk-core/compare/v2.17.3...v2.17.4) (2021-12-16)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * don't always convert bytes to text in streamToPromise ([#182](https://github.com/IBM/node-sdk-core/issues/182)) ([7fe261b](https://github.com/IBM/node-sdk-core/commit/7fe261b20f934cd3fde45acc69b9d4888836aa69))
14
+
15
+ ## [2.17.3](https://github.com/IBM/node-sdk-core/compare/v2.17.2...v2.17.3) (2021-12-13)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * bump dependencies to avoid vulnerability alerts ([#183](https://github.com/IBM/node-sdk-core/issues/183)) ([aef2c6a](https://github.com/IBM/node-sdk-core/commit/aef2c6a2b2a58ce71990b4ae754a3a0ce32e64fd))
21
+
22
+ ## [2.17.2](https://github.com/IBM/node-sdk-core/compare/v2.17.1...v2.17.2) (2021-12-08)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * **VpcInstanceAuthenticator:** omit request body for default profile scenario ([#181](https://github.com/IBM/node-sdk-core/issues/181)) ([1e3fb2d](https://github.com/IBM/node-sdk-core/commit/1e3fb2d8efede7f1382538d4a4918b16e04deeea))
28
+
1
29
  ## [2.17.1](https://github.com/IBM/node-sdk-core/compare/v2.17.0...v2.17.1) (2021-12-06)
2
30
 
3
31
 
@@ -129,12 +129,15 @@ var VpcInstanceTokenManager = /** @class */ (function (_super) {
129
129
  case 0: return [4 /*yield*/, this.getInstanceIdentityToken()];
130
130
  case 1:
131
131
  instanceIdentityToken = _a.sent();
132
- body = {};
133
132
  if (this.iamProfileId) {
134
- body.trusted_profile = { id: this.iamProfileId };
133
+ body = {
134
+ trusted_profile: { id: this.iamProfileId },
135
+ };
135
136
  }
136
137
  else if (this.iamProfileCrn) {
137
- body.trusted_profile = { crn: this.iamProfileCrn };
138
+ body = {
139
+ trusted_profile: { crn: this.iamProfileCrn },
140
+ };
138
141
  }
139
142
  parameters = {
140
143
  options: {
@@ -54,7 +54,7 @@
54
54
  | [readCrTokenFile(filepath)](./ibm-cloud-sdk-core.readcrtokenfile.md) | |
55
55
  | [readExternalSources(serviceName)](./ibm-cloud-sdk-core.readexternalsources.md) | Read properties stored in external sources like Environment Variables, the credentials file, VCAP services, etc. and return them as an object. The keys of this object will have the service name prefix removed and will be converted to lower camel case.<!-- -->Only one source will be used at a time. |
56
56
  | [removeSuffix(str, suffix)](./ibm-cloud-sdk-core.removesuffix.md) | Remove a given suffix if it exists. |
57
- | [streamToPromise(stream)](./ibm-cloud-sdk-core.streamtopromise.md) | Helper method that can be bound to a stream - it sets the output to utf-8, captures all of the results, and returns a promise that resolves to the final text Essentially a smaller version of concat-stream wrapped in a promise |
57
+ | [streamToPromise(stream)](./ibm-cloud-sdk-core.streamtopromise.md) | Helper method that can be bound to a stream - it captures all of the results, and returns a promise that resolves to the final buffer or array of text chunks Essentially a smaller version of concat-stream wrapped in a promise |
58
58
  | [stripTrailingSlash(url)](./ibm-cloud-sdk-core.striptrailingslash.md) | |
59
59
  | [toLowerKeys(obj)](./ibm-cloud-sdk-core.tolowerkeys.md) | This function converts an object's keys to lower case. note: does not convert nested keys |
60
60
  | [validateInput(options, requiredOptions)](./ibm-cloud-sdk-core.validateinput.md) | |
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## streamToPromise() function
6
6
 
7
- Helper method that can be bound to a stream - it sets the output to utf-8, captures all of the results, and returns a promise that resolves to the final text Essentially a smaller version of concat-stream wrapped in a promise
7
+ Helper method that can be bound to a stream - it captures all of the results, and returns a promise that resolves to the final buffer or array of text chunks Essentially a smaller version of concat-stream wrapped in a promise
8
8
 
9
9
  <b>Signature:</b>
10
10
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "metadata": {
3
3
  "toolPackage": "@microsoft/api-extractor",
4
- "toolVersion": "7.18.19",
4
+ "toolVersion": "7.19.2",
5
5
  "schemaVersion": 1004,
6
6
  "oldestForwardsCompatibleVersion": 1001,
7
7
  "tsdocConfig": {
@@ -5139,7 +5139,7 @@
5139
5139
  {
5140
5140
  "kind": "Function",
5141
5141
  "canonicalReference": "ibm-cloud-sdk-core!streamToPromise:function(1)",
5142
- "docComment": "/**\n * Helper method that can be bound to a stream - it sets the output to utf-8, captures all of the results, and returns a promise that resolves to the final text Essentially a smaller version of concat-stream wrapped in a promise\n *\n * @param stream - Optional stream param for when not bound to an existing stream instance. @return {Promise}\n */\n",
5142
+ "docComment": "/**\n * Helper method that can be bound to a stream - it captures all of the results, and returns a promise that resolves to the final buffer or array of text chunks Essentially a smaller version of concat-stream wrapped in a promise\n *\n * @param stream - Optional stream param for when not bound to an existing stream instance. @return {Promise}\n */\n",
5143
5143
  "excerptTokens": [
5144
5144
  {
5145
5145
  "kind": "Content",
@@ -77,12 +77,16 @@ export class VpcInstanceTokenManager extends JwtTokenManager {
77
77
  return __awaiter(this, void 0, void 0, function* () {
78
78
  const instanceIdentityToken = yield this.getInstanceIdentityToken();
79
79
  // construct request body
80
- const body = {};
80
+ let body;
81
81
  if (this.iamProfileId) {
82
- body.trusted_profile = { id: this.iamProfileId };
82
+ body = {
83
+ trusted_profile: { id: this.iamProfileId },
84
+ };
83
85
  }
84
86
  else if (this.iamProfileCrn) {
85
- body.trusted_profile = { crn: this.iamProfileCrn };
87
+ body = {
88
+ trusted_profile: { crn: this.iamProfileCrn },
89
+ };
86
90
  }
87
91
  const parameters = {
88
92
  options: {
@@ -360,7 +360,11 @@ export class RequestWrapper {
360
360
  let reqBuffer;
361
361
  try {
362
362
  if (isStream(data)) {
363
- reqBuffer = Buffer.from(yield streamToPromise(data));
363
+ const streamData = yield streamToPromise(data);
364
+ reqBuffer = Buffer.isBuffer(streamData) ? streamData : Buffer.from(streamData);
365
+ }
366
+ else if (Buffer.isBuffer(data)) {
367
+ reqBuffer = data;
364
368
  }
365
369
  else if (data.toString && data.toString() !== '[object Object]' && !Array.isArray(data)) {
366
370
  // this handles pretty much any primitive that isnt a JSON object or array
@@ -16,7 +16,8 @@
16
16
  /// <reference types="node" />
17
17
  import { Stream } from 'stream';
18
18
  /**
19
- * Helper method that can be bound to a stream - it sets the output to utf-8, captures all of the results, and returns a promise that resolves to the final text
19
+ * Helper method that can be bound to a stream - it captures all of the results, and returns a promise that resolves to the final buffer
20
+ * or array of text chunks
20
21
  * Essentially a smaller version of concat-stream wrapped in a promise
21
22
  *
22
23
  * @param {Stream} stream Optional stream param for when not bound to an existing stream instance.
@@ -14,7 +14,8 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  /**
17
- * Helper method that can be bound to a stream - it sets the output to utf-8, captures all of the results, and returns a promise that resolves to the final text
17
+ * Helper method that can be bound to a stream - it captures all of the results, and returns a promise that resolves to the final buffer
18
+ * or array of text chunks
18
19
  * Essentially a smaller version of concat-stream wrapped in a promise
19
20
  *
20
21
  * @param {Stream} stream Optional stream param for when not bound to an existing stream instance.
@@ -29,7 +30,7 @@ export function streamToPromise(stream) {
29
30
  results.push(result);
30
31
  })
31
32
  .on('end', () => {
32
- resolve(Buffer.isBuffer(results[0]) ? Buffer.concat(results).toString() : results);
33
+ resolve(Buffer.isBuffer(results[0]) ? Buffer.concat(results) : results);
33
34
  })
34
35
  .on('error', reject);
35
36
  });
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.18.19"
8
+ "packageVersion": "7.19.2"
9
9
  }
10
10
  ]
11
11
  }
@@ -1228,7 +1228,8 @@ export declare class BaseService {
1228
1228
  }
1229
1229
 
1230
1230
  /**
1231
- * Helper method that can be bound to a stream - it sets the output to utf-8, captures all of the results, and returns a promise that resolves to the final text
1231
+ * Helper method that can be bound to a stream - it captures all of the results, and returns a promise that resolves to the final buffer
1232
+ * or array of text chunks
1232
1233
  * Essentially a smaller version of concat-stream wrapped in a promise
1233
1234
  *
1234
1235
  * @param {Stream} stream Optional stream param for when not bound to an existing stream instance.
@@ -411,35 +411,38 @@ var RequestWrapper = /** @class */ (function () {
411
411
  };
412
412
  RequestWrapper.prototype.gzipRequestBody = function (data, headers) {
413
413
  return __awaiter(this, void 0, void 0, function () {
414
- var contentSetToGzip, reqBuffer, _a, _b, err_1;
415
- return __generator(this, function (_c) {
416
- switch (_c.label) {
414
+ var contentSetToGzip, reqBuffer, streamData, err_1;
415
+ return __generator(this, function (_a) {
416
+ switch (_a.label) {
417
417
  case 0:
418
418
  contentSetToGzip = headers['Content-Encoding'] && headers['Content-Encoding'].toString().includes('gzip');
419
419
  if (!data || contentSetToGzip) {
420
420
  return [2 /*return*/, data];
421
421
  }
422
- _c.label = 1;
422
+ _a.label = 1;
423
423
  case 1:
424
- _c.trys.push([1, 5, , 6]);
424
+ _a.trys.push([1, 5, , 6]);
425
425
  if (!isstream_1.default(data)) return [3 /*break*/, 3];
426
- _b = (_a = Buffer).from;
427
426
  return [4 /*yield*/, stream_to_promise_1.streamToPromise(data)];
428
427
  case 2:
429
- reqBuffer = _b.apply(_a, [_c.sent()]);
428
+ streamData = _a.sent();
429
+ reqBuffer = Buffer.isBuffer(streamData) ? streamData : Buffer.from(streamData);
430
430
  return [3 /*break*/, 4];
431
431
  case 3:
432
- if (data.toString && data.toString() !== '[object Object]' && !Array.isArray(data)) {
432
+ if (Buffer.isBuffer(data)) {
433
+ reqBuffer = data;
434
+ }
435
+ else if (data.toString && data.toString() !== '[object Object]' && !Array.isArray(data)) {
433
436
  // this handles pretty much any primitive that isnt a JSON object or array
434
437
  reqBuffer = Buffer.from(data.toString());
435
438
  }
436
439
  else {
437
440
  reqBuffer = Buffer.from(JSON.stringify(data));
438
441
  }
439
- _c.label = 4;
442
+ _a.label = 4;
440
443
  case 4: return [3 /*break*/, 6];
441
444
  case 5:
442
- err_1 = _c.sent();
445
+ err_1 = _a.sent();
443
446
  logger_1.default.error('Error converting request body to a buffer - data will not be compressed.');
444
447
  logger_1.default.debug(err_1);
445
448
  return [2 /*return*/, data];
@@ -16,7 +16,8 @@
16
16
  /// <reference types="node" />
17
17
  import { Stream } from 'stream';
18
18
  /**
19
- * Helper method that can be bound to a stream - it sets the output to utf-8, captures all of the results, and returns a promise that resolves to the final text
19
+ * Helper method that can be bound to a stream - it captures all of the results, and returns a promise that resolves to the final buffer
20
+ * or array of text chunks
20
21
  * Essentially a smaller version of concat-stream wrapped in a promise
21
22
  *
22
23
  * @param {Stream} stream Optional stream param for when not bound to an existing stream instance.
@@ -16,7 +16,8 @@
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  /**
19
- * Helper method that can be bound to a stream - it sets the output to utf-8, captures all of the results, and returns a promise that resolves to the final text
19
+ * Helper method that can be bound to a stream - it captures all of the results, and returns a promise that resolves to the final buffer
20
+ * or array of text chunks
20
21
  * Essentially a smaller version of concat-stream wrapped in a promise
21
22
  *
22
23
  * @param {Stream} stream Optional stream param for when not bound to an existing stream instance.
@@ -31,7 +32,7 @@ function streamToPromise(stream) {
31
32
  results.push(result);
32
33
  })
33
34
  .on('end', function () {
34
- resolve(Buffer.isBuffer(results[0]) ? Buffer.concat(results).toString() : results);
35
+ resolve(Buffer.isBuffer(results[0]) ? Buffer.concat(results) : results);
35
36
  })
36
37
  .on('error', reject);
37
38
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ibm-cloud-sdk-core",
3
- "version": "2.17.1",
3
+ "version": "2.17.5",
4
4
  "description": "Core functionality to support SDKs generated with IBM's OpenAPI SDK Generator.",
5
5
  "main": "index.js",
6
6
  "module": "./es/index.js",
@@ -86,7 +86,7 @@
86
86
  "build:doc": "npm-run-all build:api build:md copy:doc",
87
87
  "copy:doc": "cpx \"temp/ibm-cloud-sdk-core.api.json\" dist/docs",
88
88
  "copy:pkg": "package-json-reducer -s \"config devDependencies directories scripts jestSonar jest\" -o ./dist/package.json package.json",
89
- "postversion": "tsc-publish --no-checks --dry-run",
89
+ "postversion": "publisher --no-checks --dry-run",
90
90
  "all": "npm-run-all build test lint"
91
91
  },
92
92
  "jest": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "metadata": {
3
3
  "toolPackage": "@microsoft/api-extractor",
4
- "toolVersion": "7.18.19",
4
+ "toolVersion": "7.19.2",
5
5
  "schemaVersion": 1004,
6
6
  "oldestForwardsCompatibleVersion": 1001,
7
7
  "tsdocConfig": {
@@ -5139,7 +5139,7 @@
5139
5139
  {
5140
5140
  "kind": "Function",
5141
5141
  "canonicalReference": "ibm-cloud-sdk-core!streamToPromise:function(1)",
5142
- "docComment": "/**\n * Helper method that can be bound to a stream - it sets the output to utf-8, captures all of the results, and returns a promise that resolves to the final text Essentially a smaller version of concat-stream wrapped in a promise\n *\n * @param stream - Optional stream param for when not bound to an existing stream instance. @return {Promise}\n */\n",
5142
+ "docComment": "/**\n * Helper method that can be bound to a stream - it captures all of the results, and returns a promise that resolves to the final buffer or array of text chunks Essentially a smaller version of concat-stream wrapped in a promise\n *\n * @param stream - Optional stream param for when not bound to an existing stream instance. @return {Promise}\n */\n",
5143
5143
  "excerptTokens": [
5144
5144
  {
5145
5145
  "kind": "Content",