ibm-cloud-sdk-core 5.3.1 → 5.4.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 (41) hide show
  1. package/auth/authenticators/authenticator.d.ts +2 -1
  2. package/auth/authenticators/authenticator.js +1 -0
  3. package/auth/authenticators/index.d.ts +3 -1
  4. package/auth/authenticators/index.js +3 -1
  5. package/auth/authenticators/mcsp-authenticator.d.ts +2 -4
  6. package/auth/authenticators/mcsp-authenticator.js +2 -4
  7. package/auth/authenticators/mcspv2-authenticator.d.ts +95 -0
  8. package/auth/authenticators/mcspv2-authenticator.js +85 -0
  9. package/auth/token-managers/index.d.ts +6 -3
  10. package/auth/token-managers/index.js +8 -4
  11. package/auth/token-managers/jwt-token-manager.js +6 -3
  12. package/auth/token-managers/mcspv2-token-manager.d.ts +112 -0
  13. package/auth/token-managers/mcspv2-token-manager.js +176 -0
  14. package/auth/token-managers/token-manager.d.ts +1 -1
  15. package/auth/token-managers/token-manager.js +1 -1
  16. package/auth/utils/get-authenticator-from-environment.d.ts +1 -1
  17. package/auth/utils/get-authenticator-from-environment.js +4 -1
  18. package/docs/ibm-cloud-sdk-core.api.json +293 -5
  19. package/es/auth/authenticators/authenticator.d.ts +2 -1
  20. package/es/auth/authenticators/authenticator.js +1 -0
  21. package/es/auth/authenticators/index.d.ts +3 -1
  22. package/es/auth/authenticators/index.js +1 -0
  23. package/es/auth/authenticators/mcsp-authenticator.d.ts +2 -4
  24. package/es/auth/authenticators/mcsp-authenticator.js +2 -4
  25. package/es/auth/authenticators/mcspv2-authenticator.d.ts +95 -0
  26. package/es/auth/authenticators/mcspv2-authenticator.js +63 -0
  27. package/es/auth/token-managers/index.d.ts +6 -3
  28. package/es/auth/token-managers/index.js +6 -3
  29. package/es/auth/token-managers/jwt-token-manager.js +6 -3
  30. package/es/auth/token-managers/mcspv2-token-manager.d.ts +112 -0
  31. package/es/auth/token-managers/mcspv2-token-manager.js +151 -0
  32. package/es/auth/token-managers/token-manager.d.ts +1 -1
  33. package/es/auth/token-managers/token-manager.js +1 -1
  34. package/es/auth/utils/get-authenticator-from-environment.d.ts +1 -1
  35. package/es/auth/utils/get-authenticator-from-environment.js +5 -2
  36. package/es/lib/request-wrapper.d.ts +1 -1
  37. package/es/lib/request-wrapper.js +8 -3
  38. package/ibm-cloud-sdk-core.d.ts +183 -7
  39. package/lib/request-wrapper.d.ts +1 -1
  40. package/lib/request-wrapper.js +8 -3
  41. package/package.json +2 -2
@@ -1,5 +1,5 @@
1
1
  /**
2
- * (C) Copyright IBM Corp. 2019, 2023.
2
+ * (C) Copyright IBM Corp. 2019, 2025.
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.
@@ -31,6 +31,7 @@ export declare class Authenticator implements AuthenticatorInterface {
31
31
  static AUTHTYPE_NOAUTH: string;
32
32
  static AUTHTYPE_VPC: string;
33
33
  static AUTHTYPE_MCSP: string;
34
+ static AUTHTYPE_MCSPV2: string;
34
35
  static AUTHTYPE_UNKNOWN: string;
35
36
  /**
36
37
  * Create a new Authenticator instance.
@@ -53,6 +53,7 @@ var Authenticator = /** @class */ (function () {
53
53
  Authenticator.AUTHTYPE_NOAUTH = 'noAuth';
54
54
  Authenticator.AUTHTYPE_VPC = 'vpc';
55
55
  Authenticator.AUTHTYPE_MCSP = 'mcsp';
56
+ Authenticator.AUTHTYPE_MCSPV2 = 'mcspv2';
56
57
  Authenticator.AUTHTYPE_UNKNOWN = 'unknown';
57
58
  return Authenticator;
58
59
  }());
@@ -39,7 +39,8 @@
39
39
  * IAMAssumeAuthenticator: Authenticator for passing IAM authentication information to service endpoint, assuming a trusted profile.
40
40
  * ContainerAuthenticator: Authenticator for passing IAM authentication to a service, based on a token living on the container.
41
41
  * VpcInstanceAuthenticator: Authenticator that uses the VPC Instance Metadata Service API to retrieve an IAM token.
42
- * McspAuthenticator: Authenticator for passing MCSP authentication to a service endpoint.
42
+ * McspAuthenticator: Authenticator for passing MCSP v1 authentication to a service endpoint.
43
+ * McspV2Authenticator: Authenticator for passing MCSP v2 authentication to a service endpoint.
43
44
  * NoAuthAuthenticator: Performs no authentication. Useful for testing purposes.
44
45
  */
45
46
  export { AuthenticatorInterface } from './authenticator-interface';
@@ -54,4 +55,5 @@ export { IamRequestBasedAuthenticator } from './iam-request-based-authenticator'
54
55
  export { TokenRequestBasedAuthenticator } from './token-request-based-authenticator';
55
56
  export { VpcInstanceAuthenticator } from './vpc-instance-authenticator';
56
57
  export { McspAuthenticator } from './mcsp-authenticator';
58
+ export { McspV2Authenticator } from './mcspv2-authenticator';
57
59
  export { IamAssumeAuthenticator } from './iam-assume-authenticator';
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.IamAssumeAuthenticator = exports.McspAuthenticator = exports.VpcInstanceAuthenticator = exports.TokenRequestBasedAuthenticator = exports.IamRequestBasedAuthenticator = exports.NoAuthAuthenticator = exports.ContainerAuthenticator = exports.IamAuthenticator = exports.CloudPakForDataAuthenticator = exports.BearerTokenAuthenticator = exports.BasicAuthenticator = exports.Authenticator = void 0;
18
+ exports.IamAssumeAuthenticator = exports.McspV2Authenticator = 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");
@@ -38,5 +38,7 @@ 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
39
  var mcsp_authenticator_1 = require("./mcsp-authenticator");
40
40
  Object.defineProperty(exports, "McspAuthenticator", { enumerable: true, get: function () { return mcsp_authenticator_1.McspAuthenticator; } });
41
+ var mcspv2_authenticator_1 = require("./mcspv2-authenticator");
42
+ Object.defineProperty(exports, "McspV2Authenticator", { enumerable: true, get: function () { return mcspv2_authenticator_1.McspV2Authenticator; } });
41
43
  var iam_assume_authenticator_1 = require("./iam-assume-authenticator");
42
44
  Object.defineProperty(exports, "IamAssumeAuthenticator", { enumerable: true, get: function () { return iam_assume_authenticator_1.IamAssumeAuthenticator; } });
@@ -1,5 +1,5 @@
1
1
  /**
2
- * (C) Copyright IBM Corp. 2023.
2
+ * (C) Copyright IBM Corp. 2023, 2025.
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.
@@ -38,8 +38,6 @@ export declare class McspAuthenticator extends TokenRequestBasedAuthenticator {
38
38
  * @param options - Configuration options for CloudPakForData authentication.
39
39
  * This should be an object containing these fields:
40
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
41
  * - apikey: (optional) the API key used to obtain a bearer token (required if password is not specified)
44
42
  * - disableSslVerification: (optional) a flag that indicates whether verification of the token server's SSL certificate
45
43
  * should be disabled or not
@@ -49,7 +47,7 @@ export declare class McspAuthenticator extends TokenRequestBasedAuthenticator {
49
47
  */
50
48
  constructor(options: Options);
51
49
  /**
52
- * Returns the authenticator's type ('cp4d').
50
+ * Returns the authenticator's type ('mcsp').
53
51
  *
54
52
  * @returns a string that indicates the authenticator's type
55
53
  */
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * (C) Copyright IBM Corp. 2023.
3
+ * (C) Copyright IBM Corp. 2023, 2025.
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.
@@ -48,8 +48,6 @@ var McspAuthenticator = /** @class */ (function (_super) {
48
48
  * @param options - Configuration options for CloudPakForData authentication.
49
49
  * This should be an object containing these fields:
50
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
51
  * - apikey: (optional) the API key used to obtain a bearer token (required if password is not specified)
54
52
  * - disableSslVerification: (optional) a flag that indicates whether verification of the token server's SSL certificate
55
53
  * should be disabled or not
@@ -69,7 +67,7 @@ var McspAuthenticator = /** @class */ (function (_super) {
69
67
  return _this;
70
68
  }
71
69
  /**
72
- * Returns the authenticator's type ('cp4d').
70
+ * Returns the authenticator's type ('mcsp').
73
71
  *
74
72
  * @returns a string that indicates the authenticator's type
75
73
  */
@@ -0,0 +1,95 @@
1
+ /**
2
+ * (C) Copyright IBM Corp. 2025.
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 { BaseOptions, TokenRequestBasedAuthenticator } from './token-request-based-authenticator';
17
+ import { McspV2TokenManager } from '../token-managers/mcspv2-token-manager';
18
+ /** Configuration options for Multi-Cloud Saas Platform (MCSP) v2 authentication. */
19
+ export interface Options extends BaseOptions {
20
+ /**
21
+ * (required) The API key used to obtain an MCSP access token.
22
+ */
23
+ apikey: string;
24
+ /**
25
+ * (required) The URL representing the MCSP token service endpoint.
26
+ */
27
+ url: string;
28
+ /**
29
+ * (required) The scope collection type of item(s).
30
+ * Valid values are: "accounts", "subscriptions", "services".
31
+ */
32
+ scopeCollectionType: string;
33
+ /**
34
+ * (required) The scope identifier of item(s).
35
+ */
36
+ scopeId: string;
37
+ /**
38
+ * (optional) A flag to include builtin actions in the "actions" claim in the MCSP access token (default: false).
39
+ */
40
+ includeBuiltinActions?: boolean;
41
+ /**
42
+ * (optional) A flag to include custom actions in the "actions" claim in the MCSP access token (default: false).
43
+ */
44
+ includeCustomActions?: boolean;
45
+ /**
46
+ * (optional) A flag to include the "roles" claim in the MCSP access token (default: true).
47
+ */
48
+ includeRoles?: boolean;
49
+ /**
50
+ * (optional) A flag to add a prefix with the scope level where the role is defined in the "roles" claim (default: false).
51
+ */
52
+ prefixRoles?: boolean;
53
+ /**
54
+ * (optional) A map (object) containing keys and values to be injected into the access token as the "callerExt" claim.
55
+ * The keys used in this map must be enabled in the apikey by setting the "callerExtClaimNames" property when the apikey is created.
56
+ * This property is typically only used in scenarios involving an apikey with identityType `SERVICEID`.
57
+ */
58
+ callerExtClaim?: object;
59
+ }
60
+ /**
61
+ * The McspV2Authenticator invokes the MCSP v2 token-exchange operation (POST /api/2.0/\{scopeCollectionType\}/\{scopeId\}/apikeys/token)
62
+ * to obtain an access token for an apikey, and adds the access token to requests via an Authorization header
63
+ * of the form: "Authorization: Bearer <access-token>"
64
+ */
65
+ export declare class McspV2Authenticator extends TokenRequestBasedAuthenticator {
66
+ protected tokenManager: McspV2TokenManager;
67
+ /**
68
+ * Create a new McspV2Authenticator instance.
69
+ *
70
+ * @param options - Configuration options for MCSP v2 authentication.
71
+ * This should be an object containing these fields:
72
+ * - url: (required) the endpoint URL for the CloudPakForData token service.
73
+ * - apikey: (optional) the API key used to obtain a bearer token (required if password is not specified).
74
+ * - scopeCollectionType: (required) The scope collection type of item(s). Valid values are: "accounts", "subscriptions", "services".
75
+ * - scopeId: (required) the scope identifier of item(s).
76
+ * - includeBuiltinActions: (optional) a flag to include builtin actions in the "actions" claim in the MCSP access token (default: false).
77
+ * - includeCustomActions: (optional) a flag to include custom actions in the "actions" claim in the MCSP access token (default: false).
78
+ * - includeRoles: (optional) a flag to include the "roles" claim in the MCSP access token (default: true).
79
+ * - prefixRoles: (optional) a flag to add a prefix with the scope level where the role is defined in the "roles" claim (default: false).
80
+ * - callerExtClaim: (optional) a map (object) containing keys and values to be injected into the access token as the "callerExt" claim.
81
+ * The keys used in this map must be enabled in the apikey by setting the "callerExtClaimNames" property when the apikey is created.
82
+ * This property is typically only used in scenarios involving an apikey with identityType `SERVICEID`.
83
+ * - disableSslVerification: (optional) a flag to disable verification of the token server's SSL certificate; defaults to false.
84
+ * - headers: (optional) a set of HTTP headers to be sent with each request to the token service.
85
+ *
86
+ * @throws Error: the input configuration failed validation
87
+ */
88
+ constructor(options: Options);
89
+ /**
90
+ * Returns the authenticator's type ('mcspv2').
91
+ *
92
+ * @returns a string that indicates the authenticator's type
93
+ */
94
+ authenticationType(): string;
95
+ }
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ /**
3
+ * (C) Copyright IBM Corp. 2025.
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.McspV2Authenticator = void 0;
34
+ var authenticator_1 = require("./authenticator");
35
+ var token_request_based_authenticator_1 = require("./token-request-based-authenticator");
36
+ var mcspv2_token_manager_1 = require("../token-managers/mcspv2-token-manager");
37
+ /**
38
+ * The McspV2Authenticator invokes the MCSP v2 token-exchange operation (POST /api/2.0/\{scopeCollectionType\}/\{scopeId\}/apikeys/token)
39
+ * to obtain an access token for an apikey, and adds the access token to requests via an Authorization header
40
+ * of the form: "Authorization: Bearer <access-token>"
41
+ */
42
+ var McspV2Authenticator = /** @class */ (function (_super) {
43
+ __extends(McspV2Authenticator, _super);
44
+ /**
45
+ * Create a new McspV2Authenticator instance.
46
+ *
47
+ * @param options - Configuration options for MCSP v2 authentication.
48
+ * This should be an object containing these fields:
49
+ * - url: (required) the endpoint URL for the CloudPakForData token service.
50
+ * - apikey: (optional) the API key used to obtain a bearer token (required if password is not specified).
51
+ * - scopeCollectionType: (required) The scope collection type of item(s). Valid values are: "accounts", "subscriptions", "services".
52
+ * - scopeId: (required) the scope identifier of item(s).
53
+ * - includeBuiltinActions: (optional) a flag to include builtin actions in the "actions" claim in the MCSP access token (default: false).
54
+ * - includeCustomActions: (optional) a flag to include custom actions in the "actions" claim in the MCSP access token (default: false).
55
+ * - includeRoles: (optional) a flag to include the "roles" claim in the MCSP access token (default: true).
56
+ * - prefixRoles: (optional) a flag to add a prefix with the scope level where the role is defined in the "roles" claim (default: false).
57
+ * - callerExtClaim: (optional) a map (object) containing keys and values to be injected into the access token as the "callerExt" claim.
58
+ * The keys used in this map must be enabled in the apikey by setting the "callerExtClaimNames" property when the apikey is created.
59
+ * This property is typically only used in scenarios involving an apikey with identityType `SERVICEID`.
60
+ * - disableSslVerification: (optional) a flag to disable verification of the token server's SSL certificate; defaults to false.
61
+ * - headers: (optional) a set of HTTP headers to be sent with each request to the token service.
62
+ *
63
+ * @throws Error: the input configuration failed validation
64
+ */
65
+ function McspV2Authenticator(options) {
66
+ var _this = _super.call(this, options) || this;
67
+ // All we really need to do is construct the token manager, passing in
68
+ // our Options object since it contains the same fields as the
69
+ // token manager's Options interface.
70
+ // Note that the token manager handles input validation.
71
+ _this.tokenManager = new mcspv2_token_manager_1.McspV2TokenManager(options);
72
+ return _this;
73
+ }
74
+ /**
75
+ * Returns the authenticator's type ('mcspv2').
76
+ *
77
+ * @returns a string that indicates the authenticator's type
78
+ */
79
+ // eslint-disable-next-line class-methods-use-this
80
+ McspV2Authenticator.prototype.authenticationType = function () {
81
+ return authenticator_1.Authenticator.AUTHTYPE_MCSPV2;
82
+ };
83
+ return McspV2Authenticator;
84
+ }(token_request_based_authenticator_1.TokenRequestBasedAuthenticator));
85
+ exports.McspV2Authenticator = McspV2Authenticator;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * (C) Copyright IBM Corp. 2019, 2023.
2
+ * (C) Copyright IBM Corp. 2019, 2025.
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,7 +21,8 @@
21
21
  * Cloud Pak for Data
22
22
  * Container (IKS, etc)
23
23
  * VPC Instance
24
- * Multi-Cloud Saas Platform (MCSP)
24
+ * Multi-Cloud Saas Platform (MCSP) V1
25
+ * Multi-Cloud Saas Platform (MCSP) V2
25
26
  *
26
27
  * The token managers sit inside of an authenticator and do the work to retrieve
27
28
  * tokens, whereas the authenticators add these tokens to the actual request.
@@ -32,7 +33,8 @@
32
33
  * Cp4dTokenManager: Token Manager of CloudPak for data.
33
34
  * ContainerTokenManager: Token manager of IAM via compute resource token.
34
35
  * VpcInstanceTokenManager: Token manager of VPC Instance Metadata Service API tokens.
35
- * McspTokenManager: Token Manager of MCSP via apikey.
36
+ * McspTokenManager: Token Manager of MCSP v1 via apikey.
37
+ * McspV2TokenManager: Token Manager of MCSP v2 via apikey.
36
38
  * JwtTokenManager: A class for shared functionality for parsing, storing, and requesting JWT tokens.
37
39
  */
38
40
  export { IamTokenManager } from './iam-token-manager';
@@ -43,4 +45,5 @@ export { JwtTokenManager, JwtTokenManagerOptions } from './jwt-token-manager';
43
45
  export { TokenManager, TokenManagerOptions } from './token-manager';
44
46
  export { VpcInstanceTokenManager } from './vpc-instance-token-manager';
45
47
  export { McspTokenManager } from './mcsp-token-manager';
48
+ export { McspV2TokenManager } from './mcspv2-token-manager';
46
49
  export { IamAssumeTokenManager } from './iam-assume-token-manager';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * (C) Copyright IBM Corp. 2019, 2023.
3
+ * (C) Copyright IBM Corp. 2019, 2025.
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.IamAssumeTokenManager = exports.McspTokenManager = exports.VpcInstanceTokenManager = exports.TokenManager = exports.JwtTokenManager = exports.IamRequestBasedTokenManager = exports.ContainerTokenManager = exports.Cp4dTokenManager = exports.IamTokenManager = void 0;
18
+ exports.IamAssumeTokenManager = exports.McspV2TokenManager = 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,7 +24,8 @@ exports.IamAssumeTokenManager = exports.McspTokenManager = exports.VpcInstanceTo
24
24
  * Cloud Pak for Data
25
25
  * Container (IKS, etc)
26
26
  * VPC Instance
27
- * Multi-Cloud Saas Platform (MCSP)
27
+ * Multi-Cloud Saas Platform (MCSP) V1
28
+ * Multi-Cloud Saas Platform (MCSP) V2
28
29
  *
29
30
  * The token managers sit inside of an authenticator and do the work to retrieve
30
31
  * tokens, whereas the authenticators add these tokens to the actual request.
@@ -35,7 +36,8 @@ exports.IamAssumeTokenManager = exports.McspTokenManager = exports.VpcInstanceTo
35
36
  * Cp4dTokenManager: Token Manager of CloudPak for data.
36
37
  * ContainerTokenManager: Token manager of IAM via compute resource token.
37
38
  * VpcInstanceTokenManager: Token manager of VPC Instance Metadata Service API tokens.
38
- * McspTokenManager: Token Manager of MCSP via apikey.
39
+ * McspTokenManager: Token Manager of MCSP v1 via apikey.
40
+ * McspV2TokenManager: Token Manager of MCSP v2 via apikey.
39
41
  * JwtTokenManager: A class for shared functionality for parsing, storing, and requesting JWT tokens.
40
42
  */
41
43
  var iam_token_manager_1 = require("./iam-token-manager");
@@ -54,5 +56,7 @@ var vpc_instance_token_manager_1 = require("./vpc-instance-token-manager");
54
56
  Object.defineProperty(exports, "VpcInstanceTokenManager", { enumerable: true, get: function () { return vpc_instance_token_manager_1.VpcInstanceTokenManager; } });
55
57
  var mcsp_token_manager_1 = require("./mcsp-token-manager");
56
58
  Object.defineProperty(exports, "McspTokenManager", { enumerable: true, get: function () { return mcsp_token_manager_1.McspTokenManager; } });
59
+ var mcspv2_token_manager_1 = require("./mcspv2-token-manager");
60
+ Object.defineProperty(exports, "McspV2TokenManager", { enumerable: true, get: function () { return mcspv2_token_manager_1.McspV2TokenManager; } });
57
61
  var iam_assume_token_manager_1 = require("./iam-assume-token-manager");
58
62
  Object.defineProperty(exports, "IamAssumeTokenManager", { enumerable: true, get: function () { return iam_assume_token_manager_1.IamAssumeTokenManager; } });
@@ -32,7 +32,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
32
32
  Object.defineProperty(exports, "__esModule", { value: true });
33
33
  exports.JwtTokenManager = void 0;
34
34
  /**
35
- * (C) Copyright IBM Corp. 2019, 2024.
35
+ * (C) Copyright IBM Corp. 2019, 2025.
36
36
  *
37
37
  * Licensed under the Apache License, Version 2.0 (the "License");
38
38
  * you may not use this file except in compliance with the License.
@@ -106,8 +106,9 @@ var JwtTokenManager = /** @class */ (function (_super) {
106
106
  logger_1.default.error(err);
107
107
  throw new Error(err);
108
108
  }
109
- // the time of expiration is found by decoding the JWT access token
110
- // 'exp' is the time of expire and 'iat' is the time of token retrieval
109
+ // The expiration time is found by decoding the JWT access token.
110
+ // 'exp' is the "expiration time" claim.
111
+ // 'iat' is the 'issued at' claim.
111
112
  var exp = decodedResponse.exp, iat = decodedResponse.iat;
112
113
  // There are no required claims in JWT
113
114
  if (!exp || !iat) {
@@ -118,6 +119,8 @@ var JwtTokenManager = /** @class */ (function (_super) {
118
119
  var fractionOfTtl = 0.8;
119
120
  var timeToLive = exp - iat;
120
121
  this.expireTime = exp;
122
+ // The refresh time represents the time when the token has effectively
123
+ // existed for 80% of its time to live.
121
124
  this.refreshTime = exp - timeToLive * (1.0 - fractionOfTtl);
122
125
  }
123
126
  this.tokenInfo = __assign({}, responseBody);
@@ -0,0 +1,112 @@
1
+ /**
2
+ * (C) Copyright IBM Corp. 2025.
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 v2 token retrieval.
19
+ */
20
+ interface Options extends JwtTokenManagerOptions {
21
+ /**
22
+ * (required) The API key used to obtain an MCSP access token.
23
+ */
24
+ apikey: string;
25
+ /**
26
+ * (required) The URL representing the MCSP token service endpoint.
27
+ */
28
+ url: string;
29
+ /**
30
+ * (required) The scope collection type of item(s).
31
+ * Valid values are: "accounts", "subscriptions", "services".
32
+ */
33
+ scopeCollectionType: string;
34
+ /**
35
+ * (required) The scope identifier of item(s).
36
+ */
37
+ scopeId: string;
38
+ /**
39
+ * (optional) A flag to include builtin actions in the "actions" claim in the MCSP access token (default: false).
40
+ */
41
+ includeBuiltinActions?: boolean;
42
+ /**
43
+ * (optional) A flag to include custom actions in the "actions" claim in the MCSP access token (default: false).
44
+ */
45
+ includeCustomActions?: boolean;
46
+ /**
47
+ * (optional) A flag to include the "roles" claim in the MCSP access token (default: true).
48
+ */
49
+ includeRoles?: boolean;
50
+ /**
51
+ * (optional) A flag to add a prefix with the scope level where the role is defined in the "roles" claim (default: false).
52
+ */
53
+ prefixRoles?: boolean;
54
+ /**
55
+ * (optional) A map (object) containing keys and values to be injected into the access token as the "callerExt" claim.
56
+ * The keys used in this map must be enabled in the apikey by setting the "callerExtClaimNames" property when the apikey is created.
57
+ * This property is typically only used in scenarios involving an apikey with identityType `SERVICEID`.
58
+ */
59
+ callerExtClaim?: object;
60
+ }
61
+ /**
62
+ * Token Manager for Multi-Cloud Saas Platform (MCSP) V2 authentication.
63
+ *
64
+ * The McspV2TokenManager will invoke the MCSP token service's 'POST /api/2.0/\{scopeCollectionType\}/\{scopeId\}/apikeys/token'
65
+ * operation to obtain an MCSP access token for an apikey.
66
+ */
67
+ export declare class McspV2TokenManager extends JwtTokenManager {
68
+ protected requiredOptions: string[];
69
+ private apikey;
70
+ private scopeCollectionType;
71
+ private scopeId;
72
+ private includeBuiltinActions;
73
+ private includeCustomActions;
74
+ private includeRoles;
75
+ private prefixRoles;
76
+ private callerExtClaim;
77
+ /**
78
+ * Create a new McspV2TokenManager instance.
79
+ *
80
+ * @param options - Configuration options.
81
+ * This should be an object containing these fields:
82
+ * - url: (required) the endpoint URL for the CloudPakForData token service.
83
+ * - apikey: (optional) the API key used to obtain a bearer token (required if password is not specified).
84
+ * - scopeCollectionType: (required) The scope collection type of item(s). Valid values are: "accounts", "subscriptions", "services".
85
+ * - scopeId: (required) the scope identifier of item(s).
86
+ * - includeBuiltinActions: (optional) a flag to include builtin actions in the "actions" claim in the MCSP access token (default: false).
87
+ * - includeCustomActions: (optional) a flag to include custom actions in the "actions" claim in the MCSP access token (default: false).
88
+ * - includeRoles: (optional) a flag to include the "roles" claim in the MCSP access token (default: true).
89
+ * - prefixRoles: (optional) a flag to add a prefix with the scope level where the role is defined in the "roles" claim (default: false).
90
+ * - callerExtClaim: (optional) a map (object) containing keys and values to be injected into the access token as the "callerExt" claim.
91
+ * The keys used in this map must be enabled in the apikey by setting the "callerExtClaimNames" property when the apikey is created.
92
+ * This property is typically only used in scenarios involving an apikey with identityType `SERVICEID`.
93
+ * - disableSslVerification: (optional) a flag to disable verification of the token server's SSL certificate; defaults to false.
94
+ * - headers: (optional) a set of HTTP headers to be sent with each request to the token service.
95
+ *
96
+ * @throws Error: the input configuration failed validation
97
+ */
98
+ constructor(options: Options);
99
+ private PATH_TEMPLATE;
100
+ protected requestToken(): Promise<any>;
101
+ /**
102
+ * Parses the Options configuration property named by 'fieldName' as a boolean value.
103
+ * The value in the Options object could be either boolean or string and this function
104
+ * will do its best to parse it correctly.
105
+ * @param options - the Options object containing the configuration
106
+ * @param fieldName - the name of the field to parse as a boolean
107
+ * @param defaultValue - the default value to use in case the specified field is not present in Options
108
+ * @returns boolean the boolean value to be used for the configuration property
109
+ */
110
+ private static parseBoolean;
111
+ }
112
+ export {};