ibm-cloud-sdk-core 2.15.0 → 2.15.1

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [2.15.1](https://github.com/IBM/node-sdk-core/compare/v2.15.0...v2.15.1) (2021-10-15)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * use correct authenticator type constants ([#170](https://github.com/IBM/node-sdk-core/issues/170)) ([ae19adc](https://github.com/IBM/node-sdk-core/commit/ae19adcc25a3257a7c336390f83033960844615e))
7
+
1
8
  # [2.15.0](https://github.com/IBM/node-sdk-core/compare/v2.14.4...v2.15.0) (2021-10-15)
2
9
 
3
10
 
@@ -48,11 +48,11 @@ var Authenticator = /** @class */ (function () {
48
48
  * Constants that define the various authenticator types.
49
49
  */
50
50
  Authenticator.AUTHTYPE_BASIC = 'basic';
51
- Authenticator.AUTHTYPE_BEARERTOKEN = 'bearertoken';
51
+ Authenticator.AUTHTYPE_BEARERTOKEN = 'bearerToken';
52
52
  Authenticator.AUTHTYPE_IAM = 'iam';
53
53
  Authenticator.AUTHTYPE_CONTAINER = 'container';
54
54
  Authenticator.AUTHTYPE_CP4D = 'cp4d';
55
- Authenticator.AUTHTYPE_NOAUTH = 'noauth';
55
+ Authenticator.AUTHTYPE_NOAUTH = 'noAuth';
56
56
  Authenticator.AUTHTYPE_UNKNOWN = 'unknown';
57
57
  return Authenticator;
58
58
  }());
@@ -58,32 +58,33 @@ function getAuthenticatorFromEnvironment(serviceName) {
58
58
  authType = credentials.authtype;
59
59
  }
60
60
  if (!authType || typeof authType !== 'string') {
61
- authType = credentials.apikey ? 'iam' : 'container';
61
+ authType = credentials.apikey ? authenticators_1.Authenticator.AUTHTYPE_IAM : authenticators_1.Authenticator.AUTHTYPE_CONTAINER;
62
62
  }
63
- // create and return the appropriate authenticator
63
+ // Create and return the appropriate authenticator.
64
64
  var authenticator;
65
- // fold authType to lower case for case insensitivity
66
- switch (authType.toLowerCase()) {
67
- case authenticators_1.Authenticator.AUTHTYPE_NOAUTH:
68
- authenticator = new authenticators_1.NoAuthAuthenticator();
69
- break;
70
- case authenticators_1.Authenticator.AUTHTYPE_BASIC:
71
- authenticator = new authenticators_1.BasicAuthenticator(credentials);
72
- break;
73
- case authenticators_1.Authenticator.AUTHTYPE_BEARERTOKEN:
74
- authenticator = new authenticators_1.BearerTokenAuthenticator(credentials);
75
- break;
76
- case authenticators_1.Authenticator.AUTHTYPE_CP4D:
77
- authenticator = new authenticators_1.CloudPakForDataAuthenticator(credentials);
78
- break;
79
- case authenticators_1.Authenticator.AUTHTYPE_IAM:
80
- authenticator = new authenticators_1.IamAuthenticator(credentials);
81
- break;
82
- case authenticators_1.Authenticator.AUTHTYPE_CONTAINER:
83
- authenticator = new authenticators_1.ContainerAuthenticator(credentials);
84
- break;
85
- default:
86
- throw new Error("Invalid value for AUTH_TYPE: " + authType);
65
+ // Compare the authType against our constants case-insensitively to
66
+ // determine which authenticator type needs to be constructed.
67
+ authType = authType.toLowerCase();
68
+ if (authType === authenticators_1.Authenticator.AUTHTYPE_NOAUTH.toLowerCase()) {
69
+ authenticator = new authenticators_1.NoAuthAuthenticator();
70
+ }
71
+ else if (authType === authenticators_1.Authenticator.AUTHTYPE_BASIC.toLowerCase()) {
72
+ authenticator = new authenticators_1.BasicAuthenticator(credentials);
73
+ }
74
+ else if (authType === authenticators_1.Authenticator.AUTHTYPE_BEARERTOKEN.toLowerCase()) {
75
+ authenticator = new authenticators_1.BearerTokenAuthenticator(credentials);
76
+ }
77
+ else if (authType === authenticators_1.Authenticator.AUTHTYPE_CP4D.toLowerCase()) {
78
+ authenticator = new authenticators_1.CloudPakForDataAuthenticator(credentials);
79
+ }
80
+ else if (authType === authenticators_1.Authenticator.AUTHTYPE_IAM.toLowerCase()) {
81
+ authenticator = new authenticators_1.IamAuthenticator(credentials);
82
+ }
83
+ else if (authType === authenticators_1.Authenticator.AUTHTYPE_CONTAINER.toLowerCase()) {
84
+ authenticator = new authenticators_1.ContainerAuthenticator(credentials);
85
+ }
86
+ else {
87
+ throw new Error("Invalid value for AUTH_TYPE: " + authType);
87
88
  }
88
89
  return authenticator;
89
90
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ibm-cloud-sdk-core",
3
- "version": "2.15.0",
3
+ "version": "2.15.1",
4
4
  "description": "Core functionality to support SDKs generated with IBM's OpenAPI SDK Generator.",
5
5
  "main": "index",
6
6
  "repository": {