ibm-cloud-sdk-core 4.1.5 → 4.2.0

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 (43) hide show
  1. package/.secrets.baseline +57 -9
  2. package/Authentication.md +73 -0
  3. package/CHANGELOG.md +7 -0
  4. package/auth/authenticators/authenticator.d.ts +2 -1
  5. package/auth/authenticators/authenticator.js +1 -0
  6. package/auth/authenticators/index.d.ts +2 -0
  7. package/auth/authenticators/index.js +3 -1
  8. package/auth/authenticators/mcsp-authenticator.d.ts +57 -0
  9. package/auth/authenticators/mcsp-authenticator.js +82 -0
  10. package/auth/token-managers/index.d.ts +5 -2
  11. package/auth/token-managers/index.js +7 -3
  12. package/auth/token-managers/mcsp-token-manager.d.ts +59 -0
  13. package/auth/token-managers/mcsp-token-manager.js +94 -0
  14. package/auth/utils/get-authenticator-from-environment.js +3 -0
  15. package/build/docs/ibm-cloud-sdk-core.authenticator.authtype_mcsp.md +11 -0
  16. package/build/docs/ibm-cloud-sdk-core.authenticator.md +1 -0
  17. package/build/docs/ibm-cloud-sdk-core.mcspauthenticator._constructor_.md +24 -0
  18. package/build/docs/ibm-cloud-sdk-core.mcspauthenticator.authenticationtype.md +19 -0
  19. package/build/docs/ibm-cloud-sdk-core.mcspauthenticator.md +34 -0
  20. package/build/docs/ibm-cloud-sdk-core.mcspauthenticator.requiredoptions.md +11 -0
  21. package/build/docs/ibm-cloud-sdk-core.mcspauthenticator.tokenmanager.md +11 -0
  22. package/build/docs/ibm-cloud-sdk-core.mcsptokenmanager._constructor_.md +24 -0
  23. package/build/docs/ibm-cloud-sdk-core.mcsptokenmanager.md +35 -0
  24. package/build/docs/ibm-cloud-sdk-core.mcsptokenmanager.requesttoken.md +15 -0
  25. package/build/docs/ibm-cloud-sdk-core.mcsptokenmanager.requiredoptions.md +11 -0
  26. package/build/docs/ibm-cloud-sdk-core.md +2 -0
  27. package/docs/ibm-cloud-sdk-core.api.json +318 -0
  28. package/es/auth/authenticators/authenticator.d.ts +2 -1
  29. package/es/auth/authenticators/authenticator.js +1 -0
  30. package/es/auth/authenticators/index.d.ts +2 -0
  31. package/es/auth/authenticators/index.js +1 -0
  32. package/es/auth/authenticators/mcsp-authenticator.d.ts +57 -0
  33. package/es/auth/authenticators/mcsp-authenticator.js +60 -0
  34. package/es/auth/token-managers/index.d.ts +5 -2
  35. package/es/auth/token-managers/index.js +5 -2
  36. package/es/auth/token-managers/mcsp-token-manager.d.ts +59 -0
  37. package/es/auth/token-managers/mcsp-token-manager.js +69 -0
  38. package/es/auth/utils/get-authenticator-from-environment.js +4 -1
  39. package/etc/ibm-cloud-sdk-core.api.md +23 -0
  40. package/ibm-cloud-sdk-core.d.ts +79 -0
  41. package/package.json +1 -1
  42. package/temp/ibm-cloud-sdk-core.api.json +318 -0
  43. package/temp/ibm-cloud-sdk-core.api.md +23 -0
package/.secrets.baseline CHANGED
@@ -3,7 +3,7 @@
3
3
  "files": "package-lock.json|^.secrets.baseline$",
4
4
  "lines": null
5
5
  },
6
- "generated_at": "2023-06-22T15:14:17Z",
6
+ "generated_at": "2023-11-09T19:29:53Z",
7
7
  "plugins_used": [
8
8
  {
9
9
  "name": "AWSKeyDetector"
@@ -70,7 +70,7 @@
70
70
  "hashed_secret": "91dfd9ddb4198affc5c194cd8ce6d338fde470e2",
71
71
  "is_secret": false,
72
72
  "is_verified": false,
73
- "line_number": 73,
73
+ "line_number": 74,
74
74
  "type": "Secret Keyword",
75
75
  "verified_result": null
76
76
  },
@@ -78,7 +78,7 @@
78
78
  "hashed_secret": "98635b2eaa2379f28cd6d72a38299f286b81b459",
79
79
  "is_secret": false,
80
80
  "is_verified": false,
81
- "line_number": 432,
81
+ "line_number": 433,
82
82
  "type": "Secret Keyword",
83
83
  "verified_result": null
84
84
  },
@@ -86,7 +86,7 @@
86
86
  "hashed_secret": "47fcf185ee7e15fe05cae31fbe9e4ebe4a06a40d",
87
87
  "is_secret": false,
88
88
  "is_verified": false,
89
- "line_number": 470,
89
+ "line_number": 543,
90
90
  "type": "Secret Keyword",
91
91
  "verified_result": null
92
92
  }
@@ -96,7 +96,7 @@
96
96
  "hashed_secret": "bc2f74c22f98f7b6ffbc2f67453dbfa99bce9a32",
97
97
  "is_secret": false,
98
98
  "is_verified": false,
99
- "line_number": 55,
99
+ "line_number": 97,
100
100
  "type": "Secret Keyword",
101
101
  "verified_result": null
102
102
  }
@@ -106,7 +106,7 @@
106
106
  "hashed_secret": "32e8612d8ca77c7ea8374aa7918db8e5df9252ed",
107
107
  "is_secret": false,
108
108
  "is_verified": false,
109
- "line_number": 62,
109
+ "line_number": 63,
110
110
  "type": "Secret Keyword",
111
111
  "verified_result": null
112
112
  }
@@ -185,6 +185,16 @@
185
185
  "verified_result": null
186
186
  }
187
187
  ],
188
+ "auth/authenticators/mcsp-authenticator.ts": [
189
+ {
190
+ "hashed_secret": "8f4bfc22c4fd7cb884f94ec175ff4a3284a174a1",
191
+ "is_secret": false,
192
+ "is_verified": false,
193
+ "line_number": 60,
194
+ "type": "Secret Keyword",
195
+ "verified_result": null
196
+ }
197
+ ],
188
198
  "auth/token-managers/container-token-manager.ts": [
189
199
  {
190
200
  "hashed_secret": "184ee1f04a018aa3b897e085516a9b657fea0f6b",
@@ -281,12 +291,30 @@
281
291
  "verified_result": null
282
292
  }
283
293
  ],
294
+ "auth/token-managers/mcsp-token-manager.ts": [
295
+ {
296
+ "hashed_secret": "8f4bfc22c4fd7cb884f94ec175ff4a3284a174a1",
297
+ "is_secret": false,
298
+ "is_verified": false,
299
+ "line_number": 78,
300
+ "type": "Secret Keyword",
301
+ "verified_result": null
302
+ },
303
+ {
304
+ "hashed_secret": "65e622227634e8876cfa733000233fb80c6f0473",
305
+ "is_secret": false,
306
+ "is_verified": false,
307
+ "line_number": 91,
308
+ "type": "Secret Keyword",
309
+ "verified_result": null
310
+ }
311
+ ],
284
312
  "auth/utils/get-authenticator-from-environment.ts": [
285
313
  {
286
314
  "hashed_secret": "6947818ac409551f11fbaa78f0ea6391960aa5b8",
287
315
  "is_secret": false,
288
316
  "is_verified": false,
289
- "line_number": 49,
317
+ "line_number": 50,
290
318
  "type": "Secret Keyword",
291
319
  "verified_result": null
292
320
  }
@@ -306,7 +334,7 @@
306
334
  "hashed_secret": "45c43fe97e3a06ab078b0eeff6fbe622cc417a25",
307
335
  "is_secret": false,
308
336
  "is_verified": false,
309
- "line_number": 279,
337
+ "line_number": 283,
310
338
  "type": "Secret Keyword",
311
339
  "verified_result": null
312
340
  }
@@ -499,6 +527,26 @@
499
527
  "verified_result": null
500
528
  }
501
529
  ],
530
+ "test/unit/mcsp-authenticator.test.js": [
531
+ {
532
+ "hashed_secret": "0c910ad3070d996b37a1c65f542b17adc3f962bc",
533
+ "is_secret": false,
534
+ "is_verified": false,
535
+ "line_number": 20,
536
+ "type": "Secret Keyword",
537
+ "verified_result": null
538
+ }
539
+ ],
540
+ "test/unit/mcsp-token-manager.test.js": [
541
+ {
542
+ "hashed_secret": "f2e7745f43b0ef0e2c2faf61d6c6a28be2965750",
543
+ "is_secret": false,
544
+ "is_verified": false,
545
+ "line_number": 30,
546
+ "type": "Secret Keyword",
547
+ "verified_result": null
548
+ }
549
+ ],
502
550
  "test/unit/read-external-sources.test.js": [
503
551
  {
504
552
  "hashed_secret": "4c65cd3f160d60f7ca28ca04fa60b9035132781c",
@@ -534,7 +582,7 @@
534
582
  }
535
583
  ]
536
584
  },
537
- "version": "0.13.1+ibm.60.dss",
585
+ "version": "0.13.1+ibm.61.dss",
538
586
  "word_list": {
539
587
  "file": null,
540
588
  "hash": null
package/Authentication.md CHANGED
@@ -6,6 +6,7 @@ The node-sdk-core project supports the following types of authentication:
6
6
  - Container Authentication
7
7
  - VPC Instance Authentication
8
8
  - Cloud Pak for Data Authentication
9
+ - Multi-Cloud Saas Platform (MCSP) Authentication
9
10
  - No Authentication (for testing)
10
11
 
11
12
  The SDK user configures the appropriate type of authentication for use with service instances.
@@ -484,6 +485,78 @@ const service = ExampleServiceV1.newInstance(options);
484
485
  ```
485
486
 
486
487
 
488
+ ## Multi-Cloud Saas Platform (MCSP) Authentication
489
+ The `McspAuthenticator` can be used in scenarios where an application needs to
490
+ interact with an IBM Cloud service that has been deployed to a non-IBM Cloud environment (e.g. AWS).
491
+ It accepts a user-supplied apikey and performs the necessary interactions with the
492
+ Multi-Cloud Saas Platform token service to obtain a suitable MCSP access token (a bearer token)
493
+ for the specified apikey.
494
+ The authenticator will also obtain a new bearer token when the current token expires.
495
+ The bearer token is then added to each outbound request in the `Authorization` header in the
496
+ form:
497
+ ```
498
+ Authorization: Bearer <bearer-token>
499
+ ```
500
+
501
+ ### Properties
502
+
503
+ - apikey: (required) the apikey to be used to obtain an MCSP access token.
504
+
505
+ - url: (required) The URL representing the MCSP token service endpoint's base URL string. Do not include the
506
+ operation path (e.g. `/siusermgr/api/1.0/apikeys/token`) as part of this property's value.
507
+
508
+ - disableSSLVerification: (optional) A flag that indicates whether verificaton of the server's SSL
509
+ certificate should be disabled or not. The default value is `false`.
510
+
511
+ - headers: (optional) A set of key/value pairs that will be sent as HTTP headers in requests
512
+ made to the MCSP token service.
513
+
514
+ ### Usage Notes
515
+ - When constructing an McspAuthenticator instance, you must specify the apikey and url properties.
516
+
517
+ - The authenticator will use the token server's `POST /siusermgr/api/1.0/apikeys/token` operation to
518
+ exchange the user-supplied apikey for an MCSP access token (the bearer token).
519
+
520
+ ### Programming example
521
+ ```js
522
+ const { McspAuthenticator } = require('ibm-cloud-sdk-core');
523
+ const ExampleServiceV1 = require('<sdk-package-name>/example-service/v1');
524
+
525
+ const authenticator = new McspAuthenticator({
526
+ apikey: 'myapikey',
527
+ url: 'https://example.mcsp.token-exchange.com',
528
+ });
529
+
530
+ const options = {
531
+ authenticator,
532
+ };
533
+
534
+ const service = new ExampleServiceV1(options);
535
+
536
+ // 'service' can now be used to invoke operations.
537
+ ```
538
+
539
+ ### Configuration example
540
+ External configuration:
541
+ ```
542
+ export EXAMPLE_SERVICE_AUTH_TYPE=mcsp
543
+ export EXAMPLE_SERVICE_APIKEY=myapikey
544
+ export EXAMPLE_SERVICE_AUTH_URL=https://example.mcsp.token-exchange.com
545
+ ```
546
+ Application code:
547
+ ```js
548
+ const ExampleServiceV1 = require('<sdk-package-name>/example-service/v1');
549
+
550
+ const options = {
551
+ serviceName: 'example_service',
552
+ };
553
+
554
+ const service = ExampleServiceV1.newInstance(options);
555
+
556
+ // 'service' can now be used to invoke operations.
557
+ ```
558
+
559
+
487
560
  ## No Auth Authentication
488
561
  The `NoAuthAuthenticator` is a placeholder authenticator which performs no actual authentication function.
489
562
  It can be used in situations where authentication needs to be bypassed, perhaps while developing
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [4.2.0](https://github.com/IBM/node-sdk-core/compare/v4.1.5...v4.2.0) (2023-11-15)
2
+
3
+
4
+ ### Features
5
+
6
+ * **McspAuthenticator:** add new authenticator for Multi-Cloud Saas Platform ([#258](https://github.com/IBM/node-sdk-core/issues/258)) ([4fe7f71](https://github.com/IBM/node-sdk-core/commit/4fe7f7191c8a93947b359034229f7f966936ae53))
7
+
1
8
  ## [4.1.5](https://github.com/IBM/node-sdk-core/compare/v4.1.4...v4.1.5) (2023-11-13)
2
9
 
3
10
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * (C) Copyright IBM Corp. 2019, 2022.
2
+ * (C) Copyright IBM Corp. 2019, 2023.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@ export declare class Authenticator implements AuthenticatorInterface {
29
29
  static AUTHTYPE_CP4D: string;
30
30
  static AUTHTYPE_NOAUTH: string;
31
31
  static AUTHTYPE_VPC: string;
32
+ static AUTHTYPE_MCSP: string;
32
33
  static AUTHTYPE_UNKNOWN: string;
33
34
  /**
34
35
  * Create a new Authenticator instance.
@@ -51,6 +51,7 @@ var Authenticator = /** @class */ (function () {
51
51
  Authenticator.AUTHTYPE_CP4D = 'cp4d';
52
52
  Authenticator.AUTHTYPE_NOAUTH = 'noAuth';
53
53
  Authenticator.AUTHTYPE_VPC = 'vpc';
54
+ Authenticator.AUTHTYPE_MCSP = 'mcsp';
54
55
  Authenticator.AUTHTYPE_UNKNOWN = 'unknown';
55
56
  return Authenticator;
56
57
  }());
@@ -37,6 +37,7 @@
37
37
  * IAMAuthenticator: Authenticator for passing IAM authentication information to service endpoint.
38
38
  * ContainerAuthenticator: Authenticator for passing IAM authentication to a service, based on a token living on the container.
39
39
  * VpcInstanceAuthenticator: Authenticator that uses the VPC Instance Metadata Service API to retrieve an IAM token.
40
+ * McspAuthenticator: Authenticator for passing MCSP authentication to a service endpoint.
40
41
  * NoAuthAuthenticator: Performs no authentication. Useful for testing purposes.
41
42
  */
42
43
  export { AuthenticatorInterface } from './authenticator-interface';
@@ -50,3 +51,4 @@ export { NoAuthAuthenticator } from './no-auth-authenticator';
50
51
  export { IamRequestBasedAuthenticator } from './iam-request-based-authenticator';
51
52
  export { TokenRequestBasedAuthenticator } from './token-request-based-authenticator';
52
53
  export { VpcInstanceAuthenticator } from './vpc-instance-authenticator';
54
+ export { McspAuthenticator } from './mcsp-authenticator';
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.VpcInstanceAuthenticator = exports.TokenRequestBasedAuthenticator = exports.IamRequestBasedAuthenticator = exports.NoAuthAuthenticator = exports.ContainerAuthenticator = exports.IamAuthenticator = exports.CloudPakForDataAuthenticator = exports.BearerTokenAuthenticator = exports.BasicAuthenticator = exports.Authenticator = void 0;
18
+ exports.McspAuthenticator = exports.VpcInstanceAuthenticator = exports.TokenRequestBasedAuthenticator = exports.IamRequestBasedAuthenticator = exports.NoAuthAuthenticator = exports.ContainerAuthenticator = exports.IamAuthenticator = exports.CloudPakForDataAuthenticator = exports.BearerTokenAuthenticator = exports.BasicAuthenticator = exports.Authenticator = void 0;
19
19
  var authenticator_1 = require("./authenticator");
20
20
  Object.defineProperty(exports, "Authenticator", { enumerable: true, get: function () { return authenticator_1.Authenticator; } });
21
21
  var basic_authenticator_1 = require("./basic-authenticator");
@@ -36,3 +36,5 @@ var token_request_based_authenticator_1 = require("./token-request-based-authent
36
36
  Object.defineProperty(exports, "TokenRequestBasedAuthenticator", { enumerable: true, get: function () { return token_request_based_authenticator_1.TokenRequestBasedAuthenticator; } });
37
37
  var vpc_instance_authenticator_1 = require("./vpc-instance-authenticator");
38
38
  Object.defineProperty(exports, "VpcInstanceAuthenticator", { enumerable: true, get: function () { return vpc_instance_authenticator_1.VpcInstanceAuthenticator; } });
39
+ var mcsp_authenticator_1 = require("./mcsp-authenticator");
40
+ Object.defineProperty(exports, "McspAuthenticator", { enumerable: true, get: function () { return mcsp_authenticator_1.McspAuthenticator; } });
@@ -0,0 +1,57 @@
1
+ /**
2
+ * (C) Copyright IBM Corp. 2023.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { McspTokenManager } from '../token-managers/mcsp-token-manager';
17
+ import { BaseOptions, TokenRequestBasedAuthenticator } from './token-request-based-authenticator';
18
+ /** Configuration options for Multi-Cloud Saas Platform (MCSP) authentication. */
19
+ export interface Options extends BaseOptions {
20
+ /** The API key used to obtain an MCSP access token. */
21
+ apikey: string;
22
+ /** The URL representing the MCSP token service endpoint. */
23
+ url: string;
24
+ }
25
+ /**
26
+ * The McspAuthenticator uses an apikey to obtain an access token from the MCSP token server.
27
+ * When the access token expires, a new access token is obtained from the token server.
28
+ * The access token will be added to outbound requests via the Authorization header
29
+ * of the form: "Authorization: Bearer <access-token>"
30
+ */
31
+ export declare class McspAuthenticator extends TokenRequestBasedAuthenticator {
32
+ protected requiredOptions: string[];
33
+ protected tokenManager: McspTokenManager;
34
+ private apikey;
35
+ /**
36
+ * Create a new McspAuthenticator instance.
37
+ *
38
+ * @param options - Configuration options for CloudPakForData authentication.
39
+ * This should be an object containing these fields:
40
+ * - url: (required) the endpoint URL for the CloudPakForData token service
41
+ * - username: (required) the username used to obtain a bearer token
42
+ * - password: (optional) the password used to obtain a bearer token (required if apikey is not specified)
43
+ * - apikey: (optional) the API key used to obtain a bearer token (required if password is not specified)
44
+ * - disableSslVerification: (optional) a flag that indicates whether verification of the token server's SSL certificate
45
+ * should be disabled or not
46
+ * - headers: (optional) a set of HTTP headers to be sent with each request to the token service
47
+ *
48
+ * @throws Error: the username, password, and/or url are not valid, or unspecified, for Cloud Pak For Data token requests.
49
+ */
50
+ constructor(options: Options);
51
+ /**
52
+ * Returns the authenticator's type ('cp4d').
53
+ *
54
+ * @returns a string that indicates the authenticator's type
55
+ */
56
+ authenticationType(): string;
57
+ }
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ /**
3
+ * (C) Copyright IBM Corp. 2023.
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 __extends = (this && this.__extends) || (function () {
18
+ var extendStatics = function (d, b) {
19
+ extendStatics = Object.setPrototypeOf ||
20
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
21
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
22
+ return extendStatics(d, b);
23
+ };
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");
27
+ extendStatics(d, b);
28
+ function __() { this.constructor = d; }
29
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
30
+ };
31
+ })();
32
+ Object.defineProperty(exports, "__esModule", { value: true });
33
+ exports.McspAuthenticator = void 0;
34
+ var authenticator_1 = require("./authenticator");
35
+ var mcsp_token_manager_1 = require("../token-managers/mcsp-token-manager");
36
+ var token_request_based_authenticator_1 = require("./token-request-based-authenticator");
37
+ /**
38
+ * The McspAuthenticator uses an apikey to obtain an access token from the MCSP token server.
39
+ * When the access token expires, a new access token is obtained from the token server.
40
+ * The access token will be added to outbound requests via the Authorization header
41
+ * of the form: "Authorization: Bearer <access-token>"
42
+ */
43
+ var McspAuthenticator = /** @class */ (function (_super) {
44
+ __extends(McspAuthenticator, _super);
45
+ /**
46
+ * Create a new McspAuthenticator instance.
47
+ *
48
+ * @param options - Configuration options for CloudPakForData authentication.
49
+ * This should be an object containing these fields:
50
+ * - url: (required) the endpoint URL for the CloudPakForData token service
51
+ * - username: (required) the username used to obtain a bearer token
52
+ * - password: (optional) the password used to obtain a bearer token (required if apikey is not specified)
53
+ * - apikey: (optional) the API key used to obtain a bearer token (required if password is not specified)
54
+ * - disableSslVerification: (optional) a flag that indicates whether verification of the token server's SSL certificate
55
+ * should be disabled or not
56
+ * - headers: (optional) a set of HTTP headers to be sent with each request to the token service
57
+ *
58
+ * @throws Error: the username, password, and/or url are not valid, or unspecified, for Cloud Pak For Data token requests.
59
+ */
60
+ function McspAuthenticator(options) {
61
+ var _this = _super.call(this, options) || this;
62
+ _this.requiredOptions = ['apikey', 'url'];
63
+ _this.apikey = options.apikey;
64
+ _this.url = options.url;
65
+ // the param names are shared between the authenticator and the token
66
+ // manager so we can just pass along the options object.
67
+ // also, the token manager will handle input validation
68
+ _this.tokenManager = new mcsp_token_manager_1.McspTokenManager(options);
69
+ return _this;
70
+ }
71
+ /**
72
+ * Returns the authenticator's type ('cp4d').
73
+ *
74
+ * @returns a string that indicates the authenticator's type
75
+ */
76
+ // eslint-disable-next-line class-methods-use-this
77
+ McspAuthenticator.prototype.authenticationType = function () {
78
+ return authenticator_1.Authenticator.AUTHTYPE_MCSP;
79
+ };
80
+ return McspAuthenticator;
81
+ }(token_request_based_authenticator_1.TokenRequestBasedAuthenticator));
82
+ exports.McspAuthenticator = McspAuthenticator;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * (C) Copyright IBM Corp. 2019, 2021.
2
+ * (C) Copyright IBM Corp. 2019, 2023.
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -21,15 +21,17 @@
21
21
  * Cloud Pak for Data
22
22
  * Container (IKS, etc)
23
23
  * VPC Instance
24
+ * Multi-Cloud Saas Platform (MCSP)
24
25
  *
25
26
  * The token managers sit inside of an authenticator and do the work to retrieve
26
- * tokens where as the authenticators add these tokens to the actual request.
27
+ * tokens, whereas the authenticators add these tokens to the actual request.
27
28
  *
28
29
  * classes:
29
30
  * IamTokenManager: Token Manager of IAM via apikey.
30
31
  * Cp4dTokenManager: Token Manager of CloudPak for data.
31
32
  * ContainerTokenManager: Token manager of IAM via compute resource token.
32
33
  * VpcInstanceTokenManager: Token manager of VPC Instance Metadata Service API tokens.
34
+ * McspTokenManager: Token Manager of MCSP via apikey.
33
35
  * JwtTokenManager: A class for shared functionality for parsing, storing, and requesting JWT tokens.
34
36
  */
35
37
  export { IamTokenManager } from './iam-token-manager';
@@ -39,3 +41,4 @@ export { IamRequestBasedTokenManager, IamRequestOptions } from './iam-request-ba
39
41
  export { JwtTokenManager, JwtTokenManagerOptions } from './jwt-token-manager';
40
42
  export { TokenManager, TokenManagerOptions } from './token-manager';
41
43
  export { VpcInstanceTokenManager } from './vpc-instance-token-manager';
44
+ export { McspTokenManager } from './mcsp-token-manager';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * (C) Copyright IBM Corp. 2019, 2021.
3
+ * (C) Copyright IBM Corp. 2019, 2023.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License");
6
6
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.VpcInstanceTokenManager = exports.TokenManager = exports.JwtTokenManager = exports.IamRequestBasedTokenManager = exports.ContainerTokenManager = exports.Cp4dTokenManager = exports.IamTokenManager = void 0;
18
+ exports.McspTokenManager = exports.VpcInstanceTokenManager = exports.TokenManager = exports.JwtTokenManager = exports.IamRequestBasedTokenManager = exports.ContainerTokenManager = exports.Cp4dTokenManager = exports.IamTokenManager = void 0;
19
19
  /**
20
20
  * @module token-managers
21
21
  * The ibm-cloud-sdk-core module supports the following types of token authentication:
@@ -24,15 +24,17 @@ exports.VpcInstanceTokenManager = exports.TokenManager = exports.JwtTokenManager
24
24
  * Cloud Pak for Data
25
25
  * Container (IKS, etc)
26
26
  * VPC Instance
27
+ * Multi-Cloud Saas Platform (MCSP)
27
28
  *
28
29
  * The token managers sit inside of an authenticator and do the work to retrieve
29
- * tokens where as the authenticators add these tokens to the actual request.
30
+ * tokens, whereas the authenticators add these tokens to the actual request.
30
31
  *
31
32
  * classes:
32
33
  * IamTokenManager: Token Manager of IAM via apikey.
33
34
  * Cp4dTokenManager: Token Manager of CloudPak for data.
34
35
  * ContainerTokenManager: Token manager of IAM via compute resource token.
35
36
  * VpcInstanceTokenManager: Token manager of VPC Instance Metadata Service API tokens.
37
+ * McspTokenManager: Token Manager of MCSP via apikey.
36
38
  * JwtTokenManager: A class for shared functionality for parsing, storing, and requesting JWT tokens.
37
39
  */
38
40
  var iam_token_manager_1 = require("./iam-token-manager");
@@ -49,3 +51,5 @@ var token_manager_1 = require("./token-manager");
49
51
  Object.defineProperty(exports, "TokenManager", { enumerable: true, get: function () { return token_manager_1.TokenManager; } });
50
52
  var vpc_instance_token_manager_1 = require("./vpc-instance-token-manager");
51
53
  Object.defineProperty(exports, "VpcInstanceTokenManager", { enumerable: true, get: function () { return vpc_instance_token_manager_1.VpcInstanceTokenManager; } });
54
+ var mcsp_token_manager_1 = require("./mcsp-token-manager");
55
+ Object.defineProperty(exports, "McspTokenManager", { enumerable: true, get: function () { return mcsp_token_manager_1.McspTokenManager; } });
@@ -0,0 +1,59 @@
1
+ /**
2
+ * (C) Copyright IBM Corp. 2023.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { JwtTokenManager, JwtTokenManagerOptions } from './jwt-token-manager';
17
+ /**
18
+ * Configuration options for MCSP token retrieval.
19
+ */
20
+ interface Options extends JwtTokenManagerOptions {
21
+ /** The API key used to obtain an access token. */
22
+ apikey: string;
23
+ /** The base endpoint URL for MCSP token requests. */
24
+ url: string;
25
+ }
26
+ /**
27
+ * This interface models the response object received from the MCSP token service.
28
+ */
29
+ export interface McspTokenData {
30
+ token: string;
31
+ token_type: string;
32
+ expires_in: number;
33
+ }
34
+ /**
35
+ * Token Manager for Multi-Cloud Saas Platform (MCSP) authenticator.
36
+ *
37
+ * The Token Manager will invoke the MCSP token service's 'POST /siusermgr/api/1.0/apikeys/token'
38
+ * operation to obtain an MCSP access token for a user-supplied apikey.
39
+ */
40
+ export declare class McspTokenManager extends JwtTokenManager {
41
+ protected requiredOptions: string[];
42
+ private apikey;
43
+ /**
44
+ * Create a new McspTokenManager instance.
45
+ *
46
+ * @param options - Configuration options
47
+ * This should be an object containing these fields:
48
+ * - url: (required) the base endpoint URL for the MCSP token service
49
+ * - apikey: (required) the API key used to obtain the MCSP access token.
50
+ * - disableSslVerification: (optional) a flag that indicates whether verification of the token server's SSL certificate
51
+ * should be disabled or not
52
+ * - headers: (optional) a set of HTTP headers to be sent with each request to the token service
53
+ *
54
+ * @throws Error: the configuration options were invalid.
55
+ */
56
+ constructor(options: Options);
57
+ protected requestToken(): Promise<any>;
58
+ }
59
+ export {};
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ /**
3
+ * (C) Copyright IBM Corp. 2023.
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 __extends = (this && this.__extends) || (function () {
18
+ var extendStatics = function (d, b) {
19
+ extendStatics = Object.setPrototypeOf ||
20
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
21
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
22
+ return extendStatics(d, b);
23
+ };
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");
27
+ extendStatics(d, b);
28
+ function __() { this.constructor = d; }
29
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
30
+ };
31
+ })();
32
+ var __importDefault = (this && this.__importDefault) || function (mod) {
33
+ return (mod && mod.__esModule) ? mod : { "default": mod };
34
+ };
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.McspTokenManager = void 0;
37
+ var extend_1 = __importDefault(require("extend"));
38
+ var helpers_1 = require("../utils/helpers");
39
+ var jwt_token_manager_1 = require("./jwt-token-manager");
40
+ /**
41
+ * This is the path associated with the operation used to obtain
42
+ * an access token from the MCSP token service.
43
+ */
44
+ var OPERATION_PATH = '/siusermgr/api/1.0/apikeys/token';
45
+ /**
46
+ * Token Manager for Multi-Cloud Saas Platform (MCSP) authenticator.
47
+ *
48
+ * The Token Manager will invoke the MCSP token service's 'POST /siusermgr/api/1.0/apikeys/token'
49
+ * operation to obtain an MCSP access token for a user-supplied apikey.
50
+ */
51
+ var McspTokenManager = /** @class */ (function (_super) {
52
+ __extends(McspTokenManager, _super);
53
+ /**
54
+ * Create a new McspTokenManager instance.
55
+ *
56
+ * @param options - Configuration options
57
+ * This should be an object containing these fields:
58
+ * - url: (required) the base endpoint URL for the MCSP token service
59
+ * - apikey: (required) the API key used to obtain the MCSP access token.
60
+ * - disableSslVerification: (optional) a flag that indicates whether verification of the token server's SSL certificate
61
+ * should be disabled or not
62
+ * - headers: (optional) a set of HTTP headers to be sent with each request to the token service
63
+ *
64
+ * @throws Error: the configuration options were invalid.
65
+ */
66
+ function McspTokenManager(options) {
67
+ var _this = _super.call(this, options) || this;
68
+ _this.requiredOptions = ['apikey', 'url'];
69
+ _this.tokenName = 'token';
70
+ (0, helpers_1.validateInput)(options, _this.requiredOptions);
71
+ _this.apikey = options.apikey;
72
+ return _this;
73
+ }
74
+ McspTokenManager.prototype.requestToken = function () {
75
+ var requiredHeaders = {
76
+ Accept: 'application/json',
77
+ 'Content-Type': 'application/json',
78
+ };
79
+ var parameters = {
80
+ options: {
81
+ url: this.url + OPERATION_PATH,
82
+ body: {
83
+ apikey: this.apikey,
84
+ },
85
+ method: 'POST',
86
+ headers: (0, extend_1.default)(true, {}, this.headers, requiredHeaders),
87
+ rejectUnauthorized: !this.disableSslVerification,
88
+ },
89
+ };
90
+ return this.requestWrapperInstance.sendRequest(parameters);
91
+ };
92
+ return McspTokenManager;
93
+ }(jwt_token_manager_1.JwtTokenManager));
94
+ exports.McspTokenManager = McspTokenManager;