ibm-cloud-sdk-core 3.2.1 → 3.2.2-beta

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.
Files changed (160) hide show
  1. package/{auth → dist/auth}/authenticators/authenticator-interface.d.ts +0 -0
  2. package/{auth → dist/auth}/authenticators/authenticator-interface.js +0 -0
  3. package/{auth → dist/auth}/authenticators/authenticator.d.ts +0 -0
  4. package/{auth → dist/auth}/authenticators/authenticator.js +1 -0
  5. package/{auth → dist/auth}/authenticators/basic-authenticator.d.ts +0 -0
  6. package/{auth → dist/auth}/authenticators/basic-authenticator.js +7 -4
  7. package/{auth → dist/auth}/authenticators/bearer-token-authenticator.d.ts +0 -0
  8. package/{auth → dist/auth}/authenticators/bearer-token-authenticator.js +7 -4
  9. package/{auth → dist/auth}/authenticators/cloud-pak-for-data-authenticator.d.ts +0 -0
  10. package/{auth → dist/auth}/authenticators/cloud-pak-for-data-authenticator.js +4 -1
  11. package/{auth → dist/auth}/authenticators/container-authenticator.d.ts +0 -0
  12. package/{auth → dist/auth}/authenticators/container-authenticator.js +4 -1
  13. package/{auth → dist/auth}/authenticators/iam-authenticator.d.ts +0 -0
  14. package/{auth → dist/auth}/authenticators/iam-authenticator.js +5 -2
  15. package/{auth → dist/auth}/authenticators/iam-request-based-authenticator.d.ts +0 -0
  16. package/{auth → dist/auth}/authenticators/iam-request-based-authenticator.js +4 -1
  17. package/{auth → dist/auth}/authenticators/index.d.ts +0 -0
  18. package/dist/auth/authenticators/index.js +38 -0
  19. package/{auth → dist/auth}/authenticators/no-auth-authenticator.d.ts +0 -0
  20. package/{auth → dist/auth}/authenticators/no-auth-authenticator.js +4 -1
  21. package/{auth → dist/auth}/authenticators/token-request-based-authenticator.d.ts +0 -0
  22. package/{auth → dist/auth}/authenticators/token-request-based-authenticator.js +6 -3
  23. package/{auth → dist/auth}/authenticators/vpc-instance-authenticator.d.ts +0 -0
  24. package/{auth → dist/auth}/authenticators/vpc-instance-authenticator.js +4 -1
  25. package/{auth → dist/auth}/index.d.ts +0 -0
  26. package/dist/auth/index.js +34 -0
  27. package/{auth → dist/auth}/token-managers/container-token-manager.d.ts +0 -0
  28. package/{auth → dist/auth}/token-managers/container-token-manager.js +7 -4
  29. package/{auth → dist/auth}/token-managers/cp4d-token-manager.d.ts +0 -0
  30. package/{auth → dist/auth}/token-managers/cp4d-token-manager.js +6 -3
  31. package/{auth → dist/auth}/token-managers/iam-request-based-token-manager.d.ts +0 -0
  32. package/{auth → dist/auth}/token-managers/iam-request-based-token-manager.js +9 -6
  33. package/{auth → dist/auth}/token-managers/iam-token-manager.d.ts +0 -0
  34. package/{auth → dist/auth}/token-managers/iam-token-manager.js +5 -2
  35. package/{auth → dist/auth}/token-managers/index.d.ts +0 -0
  36. package/{auth → dist/auth}/token-managers/index.js +8 -7
  37. package/{auth → dist/auth}/token-managers/jwt-token-manager.d.ts +0 -0
  38. package/{auth → dist/auth}/token-managers/jwt-token-manager.js +5 -2
  39. package/{auth → dist/auth}/token-managers/token-manager.d.ts +0 -0
  40. package/{auth → dist/auth}/token-managers/token-manager.js +5 -4
  41. package/{auth → dist/auth}/token-managers/vpc-instance-token-manager.d.ts +0 -0
  42. package/{auth → dist/auth}/token-managers/vpc-instance-token-manager.js +11 -8
  43. package/{auth → dist/auth}/utils/file-reading-helpers.browser.d.ts +0 -0
  44. package/{auth → dist/auth}/utils/file-reading-helpers.browser.js +1 -0
  45. package/{auth → dist/auth}/utils/file-reading-helpers.d.ts +0 -0
  46. package/{auth → dist/auth}/utils/file-reading-helpers.js +12 -11
  47. package/{auth → dist/auth}/utils/get-authenticator-from-environment.d.ts +0 -0
  48. package/{auth → dist/auth}/utils/get-authenticator-from-environment.js +3 -2
  49. package/{auth → dist/auth}/utils/helpers.d.ts +0 -0
  50. package/{auth → dist/auth}/utils/helpers.js +5 -4
  51. package/{auth → dist/auth}/utils/index.d.ts +0 -0
  52. package/dist/auth/utils/index.js +46 -0
  53. package/{auth → dist/auth}/utils/read-external-sources.d.ts +0 -0
  54. package/{auth → dist/auth}/utils/read-external-sources.js +6 -5
  55. package/{docs → dist/docs}/ibm-cloud-sdk-core.api.json +0 -0
  56. package/{es → dist/es}/auth/authenticators/authenticator-interface.d.ts +0 -0
  57. package/{es → dist/es}/auth/authenticators/authenticator-interface.js +1 -0
  58. package/{es → dist/es}/auth/authenticators/authenticator.d.ts +0 -0
  59. package/{es → dist/es}/auth/authenticators/authenticator.js +0 -0
  60. package/{es → dist/es}/auth/authenticators/basic-authenticator.d.ts +0 -0
  61. package/{es → dist/es}/auth/authenticators/basic-authenticator.js +0 -0
  62. package/{es → dist/es}/auth/authenticators/bearer-token-authenticator.d.ts +0 -0
  63. package/{es → dist/es}/auth/authenticators/bearer-token-authenticator.js +0 -0
  64. package/{es → dist/es}/auth/authenticators/cloud-pak-for-data-authenticator.d.ts +0 -0
  65. package/{es → dist/es}/auth/authenticators/cloud-pak-for-data-authenticator.js +0 -0
  66. package/{es → dist/es}/auth/authenticators/container-authenticator.d.ts +0 -0
  67. package/{es → dist/es}/auth/authenticators/container-authenticator.js +0 -0
  68. package/{es → dist/es}/auth/authenticators/iam-authenticator.d.ts +0 -0
  69. package/{es → dist/es}/auth/authenticators/iam-authenticator.js +0 -0
  70. package/{es → dist/es}/auth/authenticators/iam-request-based-authenticator.d.ts +0 -0
  71. package/{es → dist/es}/auth/authenticators/iam-request-based-authenticator.js +0 -0
  72. package/{es → dist/es}/auth/authenticators/index.d.ts +0 -0
  73. package/{es → dist/es}/auth/authenticators/index.js +0 -0
  74. package/{es → dist/es}/auth/authenticators/no-auth-authenticator.d.ts +0 -0
  75. package/{es → dist/es}/auth/authenticators/no-auth-authenticator.js +0 -0
  76. package/{es → dist/es}/auth/authenticators/token-request-based-authenticator.d.ts +0 -0
  77. package/{es → dist/es}/auth/authenticators/token-request-based-authenticator.js +0 -0
  78. package/{es → dist/es}/auth/authenticators/vpc-instance-authenticator.d.ts +0 -0
  79. package/{es → dist/es}/auth/authenticators/vpc-instance-authenticator.js +0 -0
  80. package/{es → dist/es}/auth/index.d.ts +0 -0
  81. package/{es → dist/es}/auth/index.js +0 -0
  82. package/{es → dist/es}/auth/token-managers/container-token-manager.d.ts +0 -0
  83. package/{es → dist/es}/auth/token-managers/container-token-manager.js +0 -0
  84. package/{es → dist/es}/auth/token-managers/cp4d-token-manager.d.ts +0 -0
  85. package/{es → dist/es}/auth/token-managers/cp4d-token-manager.js +0 -0
  86. package/{es → dist/es}/auth/token-managers/iam-request-based-token-manager.d.ts +0 -0
  87. package/{es → dist/es}/auth/token-managers/iam-request-based-token-manager.js +0 -0
  88. package/{es → dist/es}/auth/token-managers/iam-token-manager.d.ts +0 -0
  89. package/{es → dist/es}/auth/token-managers/iam-token-manager.js +0 -0
  90. package/{es → dist/es}/auth/token-managers/index.d.ts +0 -0
  91. package/{es → dist/es}/auth/token-managers/index.js +0 -0
  92. package/{es → dist/es}/auth/token-managers/jwt-token-manager.d.ts +0 -0
  93. package/{es → dist/es}/auth/token-managers/jwt-token-manager.js +0 -0
  94. package/{es → dist/es}/auth/token-managers/token-manager.d.ts +0 -0
  95. package/{es → dist/es}/auth/token-managers/token-manager.js +0 -0
  96. package/{es → dist/es}/auth/token-managers/vpc-instance-token-manager.d.ts +0 -0
  97. package/{es → dist/es}/auth/token-managers/vpc-instance-token-manager.js +0 -0
  98. package/{es → dist/es}/auth/utils/file-reading-helpers.browser.d.ts +0 -0
  99. package/{es → dist/es}/auth/utils/file-reading-helpers.browser.js +0 -0
  100. package/{es → dist/es}/auth/utils/file-reading-helpers.d.ts +0 -0
  101. package/{es → dist/es}/auth/utils/file-reading-helpers.js +0 -0
  102. package/{es → dist/es}/auth/utils/get-authenticator-from-environment.d.ts +0 -0
  103. package/{es → dist/es}/auth/utils/get-authenticator-from-environment.js +0 -0
  104. package/{es → dist/es}/auth/utils/helpers.d.ts +0 -0
  105. package/{es → dist/es}/auth/utils/helpers.js +0 -0
  106. package/{es → dist/es}/auth/utils/index.d.ts +0 -0
  107. package/{es → dist/es}/auth/utils/index.js +0 -0
  108. package/{es → dist/es}/auth/utils/read-external-sources.d.ts +0 -0
  109. package/{es → dist/es}/auth/utils/read-external-sources.js +0 -0
  110. package/{es → dist/es}/index.d.ts +0 -0
  111. package/{es → dist/es}/index.js +0 -0
  112. package/{es → dist/es}/lib/base-service.d.ts +0 -0
  113. package/{es → dist/es}/lib/base-service.js +0 -0
  114. package/{es → dist/es}/lib/content-type.d.ts +0 -0
  115. package/{es → dist/es}/lib/content-type.js +0 -0
  116. package/{es → dist/es}/lib/get-new-logger.d.ts +0 -0
  117. package/{es → dist/es}/lib/get-new-logger.js +0 -0
  118. package/{es → dist/es}/lib/helper.d.ts +0 -0
  119. package/{es → dist/es}/lib/helper.js +0 -0
  120. package/{es → dist/es}/lib/logger.d.ts +0 -0
  121. package/{es → dist/es}/lib/logger.js +0 -0
  122. package/{es → dist/es}/lib/querystring.d.ts +0 -0
  123. package/{es → dist/es}/lib/querystring.js +0 -0
  124. package/{es → dist/es}/lib/request-wrapper.d.ts +0 -0
  125. package/{es → dist/es}/lib/request-wrapper.js +13 -5
  126. package/{es → dist/es}/lib/sdk-test-helpers.browser.d.ts +0 -0
  127. package/{es → dist/es}/lib/sdk-test-helpers.browser.js +0 -0
  128. package/{es → dist/es}/lib/sdk-test-helpers.d.ts +0 -0
  129. package/{es → dist/es}/lib/sdk-test-helpers.js +0 -0
  130. package/{es → dist/es}/lib/stream-to-promise.d.ts +0 -0
  131. package/{es → dist/es}/lib/stream-to-promise.js +0 -0
  132. package/{ibm-cloud-sdk-core.d.ts → dist/ibm-cloud-sdk-core.d.ts} +0 -0
  133. package/{index.d.ts → dist/index.d.ts} +0 -0
  134. package/dist/index.js +63 -0
  135. package/{lib → dist/lib}/base-service.d.ts +0 -0
  136. package/{lib → dist/lib}/base-service.js +7 -6
  137. package/{lib → dist/lib}/content-type.d.ts +0 -0
  138. package/{lib → dist/lib}/content-type.js +1 -1
  139. package/{lib → dist/lib}/get-new-logger.d.ts +0 -0
  140. package/{lib → dist/lib}/get-new-logger.js +6 -5
  141. package/{lib → dist/lib}/helper.d.ts +0 -0
  142. package/{lib → dist/lib}/helper.js +21 -18
  143. package/{lib → dist/lib}/logger.d.ts +0 -0
  144. package/{lib → dist/lib}/logger.js +1 -1
  145. package/{lib → dist/lib}/querystring.d.ts +0 -0
  146. package/{lib → dist/lib}/querystring.js +1 -1
  147. package/{lib → dist/lib}/request-wrapper.d.ts +0 -0
  148. package/{lib → dist/lib}/request-wrapper.js +54 -29
  149. package/{lib → dist/lib}/sdk-test-helpers.browser.d.ts +0 -0
  150. package/{lib → dist/lib}/sdk-test-helpers.browser.js +1 -0
  151. package/{lib → dist/lib}/sdk-test-helpers.d.ts +0 -0
  152. package/{lib → dist/lib}/sdk-test-helpers.js +8 -7
  153. package/{lib → dist/lib}/stream-to-promise.d.ts +0 -0
  154. package/{lib → dist/lib}/stream-to-promise.js +1 -0
  155. package/dist/package.json +71 -0
  156. package/package.json +40 -6
  157. package/auth/authenticators/index.js +0 -37
  158. package/auth/index.js +0 -23
  159. package/auth/utils/index.js +0 -34
  160. package/index.js +0 -43
@@ -4,10 +4,12 @@ var __extends = (this && this.__extends) || (function () {
4
4
  var extendStatics = function (d, b) {
5
5
  extendStatics = Object.setPrototypeOf ||
6
6
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
7
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
8
8
  return extendStatics(d, b);
9
9
  };
10
10
  return function (d, b) {
11
+ if (typeof b !== "function" && b !== null)
12
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
13
  extendStatics(d, b);
12
14
  function __() { this.constructor = d; }
13
15
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -28,6 +30,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
30
  return (mod && mod.__esModule) ? mod : { "default": mod };
29
31
  };
30
32
  Object.defineProperty(exports, "__esModule", { value: true });
33
+ exports.JwtTokenManager = void 0;
31
34
  /**
32
35
  * (C) Copyright IBM Corp. 2019, 2021.
33
36
  *
@@ -102,7 +105,7 @@ var JwtTokenManager = /** @class */ (function (_super) {
102
105
  }
103
106
  // the time of expiration is found by decoding the JWT access token
104
107
  // exp is the time of expire and iat is the time of token retrieval
105
- var decodedResponse = jsonwebtoken_1.decode(this.accessToken);
108
+ var decodedResponse = (0, jsonwebtoken_1.decode)(this.accessToken);
106
109
  if (!decodedResponse) {
107
110
  var err = 'Access token recieved is not a valid JWT';
108
111
  logger_1.default.error(err);
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
5
  };
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.TokenManager = void 0;
7
8
  var helper_1 = require("../../lib/helper");
8
9
  var logger_1 = __importDefault(require("../../lib/logger"));
9
10
  var request_wrapper_1 = require("../../lib/request-wrapper");
@@ -31,7 +32,7 @@ var TokenManager = /** @class */ (function () {
31
32
  // all parameters are optional
32
33
  options = options || {};
33
34
  if (options.url) {
34
- this.url = helper_1.stripTrailingSlash(options.url);
35
+ this.url = (0, helper_1.stripTrailingSlash)(options.url);
35
36
  }
36
37
  // request options
37
38
  this.disableSslVerification = Boolean(options.disableSslVerification);
@@ -99,7 +100,7 @@ var TokenManager = /** @class */ (function () {
99
100
  */
100
101
  TokenManager.prototype.pacedRequestToken = function () {
101
102
  var _this = this;
102
- var currentTime = utils_1.getCurrentTime();
103
+ var currentTime = (0, utils_1.getCurrentTime)();
103
104
  if (this.requestTime > currentTime - 60) {
104
105
  // token request is active -- queue the promise for this request
105
106
  return new Promise(function (resolve, reject) {
@@ -161,7 +162,7 @@ var TokenManager = /** @class */ (function () {
161
162
  if (!expireTime) {
162
163
  return true;
163
164
  }
164
- var currentTime = utils_1.getCurrentTime();
165
+ var currentTime = (0, utils_1.getCurrentTime)();
165
166
  return expireTime <= currentTime;
166
167
  };
167
168
  /**
@@ -173,7 +174,7 @@ var TokenManager = /** @class */ (function () {
173
174
  */
174
175
  TokenManager.prototype.tokenNeedsRefresh = function () {
175
176
  var refreshTime = this.refreshTime;
176
- var currentTime = utils_1.getCurrentTime();
177
+ var currentTime = (0, utils_1.getCurrentTime)();
177
178
  if (refreshTime && refreshTime > currentTime) {
178
179
  return false;
179
180
  }
@@ -18,10 +18,12 @@ var __extends = (this && this.__extends) || (function () {
18
18
  var extendStatics = function (d, b) {
19
19
  extendStatics = Object.setPrototypeOf ||
20
20
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
21
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
21
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
22
22
  return extendStatics(d, b);
23
23
  };
24
24
  return function (d, b) {
25
+ if (typeof b !== "function" && b !== null)
26
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
25
27
  extendStatics(d, b);
26
28
  function __() { this.constructor = d; }
27
29
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -67,6 +69,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
67
69
  return (mod && mod.__esModule) ? mod : { "default": mod };
68
70
  };
69
71
  Object.defineProperty(exports, "__esModule", { value: true });
72
+ exports.VpcInstanceTokenManager = void 0;
70
73
  var logger_1 = __importDefault(require("../../lib/logger"));
71
74
  var utils_1 = require("../utils");
72
75
  var jwt_token_manager_1 = require("./jwt-token-manager");
@@ -95,7 +98,7 @@ var VpcInstanceTokenManager = /** @class */ (function (_super) {
95
98
  // all parameters are optional
96
99
  options = options || {};
97
100
  _this = _super.call(this, options) || this;
98
- if (!utils_1.atMostOne(options.iamProfileId, options.iamProfileCrn)) {
101
+ if (!(0, utils_1.atMostOne)(options.iamProfileId, options.iamProfileCrn)) {
99
102
  throw new Error('At most one of `iamProfileId` or `iamProfileCrn` may be specified.');
100
103
  }
101
104
  _this.url = options.url || DEFAULT_IMS_ENDPOINT;
@@ -141,7 +144,7 @@ var VpcInstanceTokenManager = /** @class */ (function (_super) {
141
144
  }
142
145
  parameters = {
143
146
  options: {
144
- url: this.url + "/instance_identity/v1/iam_token",
147
+ url: "".concat(this.url, "/instance_identity/v1/iam_token"),
145
148
  qs: {
146
149
  version: METADATA_SERVICE_VERSION,
147
150
  },
@@ -150,11 +153,11 @@ var VpcInstanceTokenManager = /** @class */ (function (_super) {
150
153
  headers: {
151
154
  'Content-Type': 'application/json',
152
155
  Accept: 'application/json',
153
- Authorization: "Bearer " + instanceIdentityToken,
156
+ Authorization: "Bearer ".concat(instanceIdentityToken),
154
157
  },
155
158
  },
156
159
  };
157
- logger_1.default.debug("Invoking VPC 'create_iam_token' operation: " + parameters.options.url);
160
+ logger_1.default.debug("Invoking VPC 'create_iam_token' operation: ".concat(parameters.options.url));
158
161
  return [2 /*return*/, this.requestWrapperInstance.sendRequest(parameters)];
159
162
  }
160
163
  });
@@ -168,7 +171,7 @@ var VpcInstanceTokenManager = /** @class */ (function (_super) {
168
171
  case 0:
169
172
  parameters = {
170
173
  options: {
171
- url: this.url + "/instance_identity/v1/token",
174
+ url: "".concat(this.url, "/instance_identity/v1/token"),
172
175
  qs: {
173
176
  version: METADATA_SERVICE_VERSION,
174
177
  },
@@ -187,7 +190,7 @@ var VpcInstanceTokenManager = /** @class */ (function (_super) {
187
190
  _a.label = 1;
188
191
  case 1:
189
192
  _a.trys.push([1, 3, , 4]);
190
- logger_1.default.debug("Invoking VPC 'create_access_token' operation: " + parameters.options.url);
193
+ logger_1.default.debug("Invoking VPC 'create_access_token' operation: ".concat(parameters.options.url));
191
194
  return [4 /*yield*/, this.requestWrapperInstance.sendRequest(parameters)];
192
195
  case 2:
193
196
  response = _a.sent();
@@ -197,7 +200,7 @@ var VpcInstanceTokenManager = /** @class */ (function (_super) {
197
200
  return [3 /*break*/, 4];
198
201
  case 3:
199
202
  err_1 = _a.sent();
200
- logger_1.default.debug("Caught exception from VPC 'create_access_token' operation: " + err_1.message);
203
+ logger_1.default.debug("Caught exception from VPC 'create_access_token' operation: ".concat(err_1.message));
201
204
  throw err_1;
202
205
  case 4: return [2 /*return*/, token];
203
206
  }
@@ -15,6 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.readCrTokenFile = exports.readCredentialsFile = void 0;
18
19
  // Dummy for browser
19
20
  function readCredentialsFile() {
20
21
  return {};
@@ -18,6 +18,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
18
18
  return (mod && mod.__esModule) ? mod : { "default": mod };
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.readCrTokenFile = exports.constructFilepath = exports.fileExistsAtPath = exports.readCredentialsFile = void 0;
21
22
  var dotenv_1 = require("dotenv");
22
23
  var fs_1 = require("fs");
23
24
  var os_1 = require("os");
@@ -40,7 +41,7 @@ function readCredentialsFile() {
40
41
  // then at the os-dependent home directory
41
42
  var givenFilepath = process.env.IBM_CREDENTIALS_FILE || '';
42
43
  var workingDir = constructFilepath(process.cwd());
43
- var homeDir = constructFilepath(os_1.homedir());
44
+ var homeDir = constructFilepath((0, os_1.homedir)());
44
45
  var filepathToUse;
45
46
  if (givenFilepath) {
46
47
  if (fileExistsAtPath(givenFilepath)) {
@@ -63,13 +64,13 @@ function readCredentialsFile() {
63
64
  logger_1.default.info('Credential file does not exist. Will not be used');
64
65
  return {};
65
66
  }
66
- var credsFile = fs_1.readFileSync(filepathToUse);
67
- return dotenv_1.parse(credsFile);
67
+ var credsFile = (0, fs_1.readFileSync)(filepathToUse);
68
+ return (0, dotenv_1.parse)(credsFile);
68
69
  }
69
70
  exports.readCredentialsFile = readCredentialsFile;
70
71
  function fileExistsAtPath(filepath) {
71
- if (fs_1.existsSync(filepath)) {
72
- var stats = fs_1.lstatSync(filepath);
72
+ if ((0, fs_1.existsSync)(filepath)) {
73
+ var stats = (0, fs_1.lstatSync)(filepath);
73
74
  return stats.isFile() || stats.isSymbolicLink();
74
75
  }
75
76
  return false;
@@ -78,7 +79,7 @@ exports.fileExistsAtPath = fileExistsAtPath;
78
79
  function constructFilepath(filepath) {
79
80
  // ensure filepath includes the filename
80
81
  if (!filepath.endsWith(defaultCredsFilename)) {
81
- filepath = path_1.join(filepath, defaultCredsFilename);
82
+ filepath = (0, path_1.join)(filepath, defaultCredsFilename);
82
83
  }
83
84
  return filepath;
84
85
  }
@@ -90,17 +91,17 @@ function readCrTokenFile(filepath) {
90
91
  var token = '';
91
92
  var fileExists = fileExistsAtPath(filepath);
92
93
  if (fileExists) {
93
- token = fs_1.readFileSync(filepath, 'utf8');
94
- logger_1.default.debug("Successfully read CR token from file: " + filepath);
94
+ token = (0, fs_1.readFileSync)(filepath, 'utf8');
95
+ logger_1.default.debug("Successfully read CR token from file: ".concat(filepath));
95
96
  }
96
97
  if (token === '') {
97
98
  if (fileExists) {
98
- logger_1.default.error("Expected to read CR token from file but the file is empty: " + filepath);
99
+ logger_1.default.error("Expected to read CR token from file but the file is empty: ".concat(filepath));
99
100
  }
100
101
  else {
101
- logger_1.default.error("Expected to find CR token file but the file does not exist: " + filepath);
102
+ logger_1.default.error("Expected to find CR token file but the file does not exist: ".concat(filepath));
102
103
  }
103
- throw new Error("Unable to retrieve the CR token value from file: " + filepath);
104
+ throw new Error("Unable to retrieve the CR token value from file: ".concat(filepath));
104
105
  }
105
106
  return token;
106
107
  }
@@ -15,6 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.getAuthenticatorFromEnvironment = void 0;
18
19
  var authenticators_1 = require("../authenticators");
19
20
  var read_external_sources_1 = require("./read-external-sources");
20
21
  /**
@@ -33,7 +34,7 @@ function getAuthenticatorFromEnvironment(serviceName) {
33
34
  throw new Error('Service name is required.');
34
35
  }
35
36
  // construct the credentials object from the environment
36
- var credentials = read_external_sources_1.readExternalSources(serviceName);
37
+ var credentials = (0, read_external_sources_1.readExternalSources)(serviceName);
37
38
  if (credentials === null) {
38
39
  throw new Error('Unable to create an authenticator from the environment.');
39
40
  }
@@ -87,7 +88,7 @@ function getAuthenticatorFromEnvironment(serviceName) {
87
88
  authenticator = new authenticators_1.VpcInstanceAuthenticator(credentials);
88
89
  }
89
90
  else {
90
- throw new Error("Invalid value for AUTH_TYPE: " + authType);
91
+ throw new Error("Invalid value for AUTH_TYPE: ".concat(authType));
91
92
  }
92
93
  return authenticator;
93
94
  }
File without changes
@@ -15,6 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.atMostOne = exports.atLeastOne = exports.removeSuffix = exports.onlyOne = exports.getCurrentTime = exports.validateInput = exports.checkCredentials = exports.computeBasicAuthHeader = void 0;
18
19
  var helper_1 = require("../../lib/helper");
19
20
  /**
20
21
  * Compute and return a Basic Authorization header from a username and password.
@@ -24,8 +25,8 @@ var helper_1 = require("../../lib/helper");
24
25
  * @returns {string} - A Basic Auth header with format "Basic <encoded-credentials>"
25
26
  */
26
27
  function computeBasicAuthHeader(username, password) {
27
- var encodedCreds = Buffer.from(username + ":" + password).toString('base64');
28
- return "Basic " + encodedCreds;
28
+ var encodedCreds = Buffer.from("".concat(username, ":").concat(password)).toString('base64');
29
+ return "Basic ".concat(encodedCreds);
29
30
  }
30
31
  exports.computeBasicAuthHeader = computeBasicAuthHeader;
31
32
  // returns true if the string has a curly bracket or quote as the first or last character
@@ -44,7 +45,7 @@ function checkCredentials(obj, credsToCheck) {
44
45
  var errorMessage = '';
45
46
  credsToCheck.forEach(function (cred) {
46
47
  if (obj[cred] && badCharAtAnEnd(obj[cred])) {
47
- errorMessage += "The " + cred + " shouldn't start or end with curly brackets or quotes. Be sure to remove any {, }, or \"";
48
+ errorMessage += "The ".concat(cred, " shouldn't start or end with curly brackets or quotes. Be sure to remove any {, }, or \"");
48
49
  }
49
50
  });
50
51
  if (errorMessage.length) {
@@ -61,7 +62,7 @@ exports.checkCredentials = checkCredentials;
61
62
  */
62
63
  function validateInput(options, requiredOptions) {
63
64
  // check for required params
64
- var missingParamsError = helper_1.getMissingParams(options, requiredOptions);
65
+ var missingParamsError = (0, helper_1.getMissingParams)(options, requiredOptions);
65
66
  if (missingParamsError) {
66
67
  throw missingParamsError;
67
68
  }
File without changes
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ /**
3
+ * (C) Copyright IBM Corp. 2019, 2021.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ var desc = Object.getOwnPropertyDescriptor(m, k);
20
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
+ desc = { enumerable: true, get: function() { return m[k]; } };
22
+ }
23
+ Object.defineProperty(o, k2, desc);
24
+ }) : (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ o[k2] = m[k];
27
+ }));
28
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
29
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
30
+ };
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.readExternalSources = exports.getAuthenticatorFromEnvironment = void 0;
33
+ /**
34
+ * @module utils
35
+ * Helper functions used by generated SDKs.
36
+ *
37
+ * functions:
38
+ * getAuthenticatorFromEnvironment: Get authenticator from external sources.
39
+ * readExternalSources: Get config object from external sources.
40
+ */
41
+ __exportStar(require("./helpers"), exports);
42
+ __exportStar(require("./file-reading-helpers"), exports);
43
+ var get_authenticator_from_environment_1 = require("./get-authenticator-from-environment");
44
+ Object.defineProperty(exports, "getAuthenticatorFromEnvironment", { enumerable: true, get: function () { return get_authenticator_from_environment_1.getAuthenticatorFromEnvironment; } });
45
+ var read_external_sources_1 = require("./read-external-sources");
46
+ Object.defineProperty(exports, "readExternalSources", { enumerable: true, get: function () { return read_external_sources_1.readExternalSources; } });
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
5
  };
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.readExternalSources = void 0;
7
8
  /**
8
9
  * (C) Copyright IBM Corp. 2019, 2021.
9
10
  *
@@ -46,11 +47,11 @@ function getProperties(serviceName) {
46
47
  // 3. VCAP Services (Cloud Foundry)
47
48
  // only get properties from one source, return null if none found
48
49
  var properties = null;
49
- properties = filterPropertiesByServiceName(file_reading_helpers_1.readCredentialsFile(), serviceName);
50
- if (lodash_isempty_1.default(properties)) {
50
+ properties = filterPropertiesByServiceName((0, file_reading_helpers_1.readCredentialsFile)(), serviceName);
51
+ if ((0, lodash_isempty_1.default)(properties)) {
51
52
  properties = filterPropertiesByServiceName(process.env, serviceName);
52
53
  }
53
- if (lodash_isempty_1.default(properties)) {
54
+ if ((0, lodash_isempty_1.default)(properties)) {
54
55
  properties = getPropertiesFromVCAP(serviceName);
55
56
  }
56
57
  return properties;
@@ -68,11 +69,11 @@ function getProperties(serviceName) {
68
69
  */
69
70
  function filterPropertiesByServiceName(envObj, serviceName) {
70
71
  var credentials = {};
71
- var name = serviceName.toUpperCase().replace(/-/g, '_') + "_"; // append the underscore that must follow the service name
72
+ var name = "".concat(serviceName.toUpperCase().replace(/-/g, '_'), "_"); // append the underscore that must follow the service name
72
73
  // filter out properties that don't begin with the service name
73
74
  Object.keys(envObj).forEach(function (key) {
74
75
  if (key.startsWith(name)) {
75
- var propName = camelcase_1.default(key.substring(name.length)); // remove the name from the front of the string and make camelcase
76
+ var propName = (0, camelcase_1.default)(key.substring(name.length)); // remove the name from the front of the string and make camelcase
76
77
  credentials[propName] = envObj[key];
77
78
  }
78
79
  });
File without changes
@@ -13,3 +13,4 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ export {};
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes