ibm-cloud-sdk-core 5.0.1 → 5.1.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 (98) hide show
  1. package/.secrets.baseline +128 -24
  2. package/Authentication.md +146 -21
  3. package/CHANGELOG.md +14 -0
  4. package/README.md +3 -2
  5. package/auth/authenticators/authenticator.d.ts +1 -0
  6. package/auth/authenticators/authenticator.js +1 -0
  7. package/auth/authenticators/basic-authenticator.d.ts +1 -1
  8. package/auth/authenticators/basic-authenticator.js +3 -1
  9. package/auth/authenticators/bearer-token-authenticator.js +2 -0
  10. package/auth/authenticators/container-authenticator.d.ts +6 -0
  11. package/auth/authenticators/container-authenticator.js +8 -0
  12. package/auth/authenticators/iam-assume-authenticator.d.ts +82 -0
  13. package/auth/authenticators/iam-assume-authenticator.js +92 -0
  14. package/auth/authenticators/iam-authenticator.d.ts +6 -0
  15. package/auth/authenticators/iam-authenticator.js +8 -0
  16. package/auth/authenticators/iam-request-based-authenticator-immutable.d.ts +64 -0
  17. package/auth/authenticators/iam-request-based-authenticator-immutable.js +74 -0
  18. package/auth/authenticators/iam-request-based-authenticator.d.ts +19 -47
  19. package/auth/authenticators/iam-request-based-authenticator.js +28 -36
  20. package/auth/authenticators/index.d.ts +4 -1
  21. package/auth/authenticators/index.js +3 -1
  22. package/auth/authenticators/token-request-based-authenticator-immutable.d.ts +71 -0
  23. package/auth/authenticators/token-request-based-authenticator-immutable.js +91 -0
  24. package/auth/authenticators/token-request-based-authenticator.d.ts +4 -42
  25. package/auth/authenticators/token-request-based-authenticator.js +5 -40
  26. package/auth/token-managers/container-token-manager.d.ts +6 -0
  27. package/auth/token-managers/container-token-manager.js +18 -50
  28. package/auth/token-managers/cp4d-token-manager.js +6 -1
  29. package/auth/token-managers/iam-assume-token-manager.d.ts +101 -0
  30. package/auth/token-managers/iam-assume-token-manager.js +220 -0
  31. package/auth/token-managers/iam-request-based-token-manager.d.ts +3 -9
  32. package/auth/token-managers/iam-request-based-token-manager.js +5 -9
  33. package/auth/token-managers/iam-token-manager.d.ts +8 -2
  34. package/auth/token-managers/iam-token-manager.js +10 -2
  35. package/auth/token-managers/index.d.ts +4 -2
  36. package/auth/token-managers/index.js +6 -3
  37. package/auth/token-managers/mcsp-token-manager.js +6 -1
  38. package/auth/token-managers/token-manager.js +7 -3
  39. package/auth/token-managers/vpc-instance-token-manager.js +4 -1
  40. package/auth/utils/get-authenticator-from-environment.js +3 -0
  41. package/auth/utils/helpers.d.ts +18 -23
  42. package/auth/utils/helpers.js +50 -30
  43. package/auth/utils/read-external-sources.js +2 -0
  44. package/docs/ibm-cloud-sdk-core.api.json +787 -404
  45. package/es/auth/authenticators/authenticator.d.ts +1 -0
  46. package/es/auth/authenticators/authenticator.js +1 -0
  47. package/es/auth/authenticators/basic-authenticator.d.ts +1 -1
  48. package/es/auth/authenticators/basic-authenticator.js +3 -1
  49. package/es/auth/authenticators/bearer-token-authenticator.js +2 -0
  50. package/es/auth/authenticators/container-authenticator.d.ts +6 -0
  51. package/es/auth/authenticators/container-authenticator.js +8 -0
  52. package/es/auth/authenticators/iam-assume-authenticator.d.ts +82 -0
  53. package/es/auth/authenticators/iam-assume-authenticator.js +70 -0
  54. package/es/auth/authenticators/iam-authenticator.d.ts +6 -0
  55. package/es/auth/authenticators/iam-authenticator.js +8 -0
  56. package/es/auth/authenticators/iam-request-based-authenticator-immutable.d.ts +64 -0
  57. package/es/auth/authenticators/iam-request-based-authenticator-immutable.js +51 -0
  58. package/es/auth/authenticators/iam-request-based-authenticator.d.ts +19 -47
  59. package/es/auth/authenticators/iam-request-based-authenticator.js +26 -35
  60. package/es/auth/authenticators/index.d.ts +4 -1
  61. package/es/auth/authenticators/index.js +1 -0
  62. package/es/auth/authenticators/token-request-based-authenticator-immutable.d.ts +71 -0
  63. package/es/auth/authenticators/token-request-based-authenticator-immutable.js +65 -0
  64. package/es/auth/authenticators/token-request-based-authenticator.d.ts +4 -42
  65. package/es/auth/authenticators/token-request-based-authenticator.js +3 -37
  66. package/es/auth/token-managers/container-token-manager.d.ts +6 -0
  67. package/es/auth/token-managers/container-token-manager.js +18 -24
  68. package/es/auth/token-managers/cp4d-token-manager.js +6 -1
  69. package/es/auth/token-managers/iam-assume-token-manager.d.ts +101 -0
  70. package/es/auth/token-managers/iam-assume-token-manager.js +164 -0
  71. package/es/auth/token-managers/iam-request-based-token-manager.d.ts +3 -9
  72. package/es/auth/token-managers/iam-request-based-token-manager.js +5 -9
  73. package/es/auth/token-managers/iam-token-manager.d.ts +8 -2
  74. package/es/auth/token-managers/iam-token-manager.js +10 -2
  75. package/es/auth/token-managers/index.d.ts +4 -2
  76. package/es/auth/token-managers/index.js +4 -2
  77. package/es/auth/token-managers/mcsp-token-manager.js +6 -1
  78. package/es/auth/token-managers/token-manager.js +7 -3
  79. package/es/auth/token-managers/vpc-instance-token-manager.js +4 -1
  80. package/es/auth/utils/get-authenticator-from-environment.js +4 -1
  81. package/es/auth/utils/helpers.d.ts +18 -23
  82. package/es/auth/utils/helpers.js +35 -27
  83. package/es/auth/utils/read-external-sources.js +2 -0
  84. package/es/lib/base-service.js +2 -0
  85. package/es/lib/private-helpers.d.ts +22 -0
  86. package/es/lib/private-helpers.js +58 -0
  87. package/es/lib/request-wrapper.d.ts +43 -1
  88. package/es/lib/request-wrapper.js +113 -14
  89. package/etc/ibm-cloud-sdk-core.api.md +46 -28
  90. package/ibm-cloud-sdk-core.d.ts +306 -68
  91. package/lib/base-service.js +2 -0
  92. package/lib/private-helpers.d.ts +22 -0
  93. package/lib/private-helpers.js +62 -0
  94. package/lib/request-wrapper.d.ts +43 -1
  95. package/lib/request-wrapper.js +113 -14
  96. package/package.json +5 -4
  97. package/sdk-test-utilities/package-lock.json +8 -5
  98. package/sdk-test-utilities/package.json +3 -0
@@ -37,6 +37,7 @@ exports.BearerTokenAuthenticator = void 0;
37
37
  var extend_1 = __importDefault(require("extend"));
38
38
  var helpers_1 = require("../utils/helpers");
39
39
  var authenticator_1 = require("./authenticator");
40
+ var logger_1 = __importDefault(require("../../lib/logger"));
40
41
  /**
41
42
  * The BearerTokenAuthenticator will set a user-provided bearer token
42
43
  * in requests.
@@ -84,6 +85,7 @@ var BearerTokenAuthenticator = /** @class */ (function (_super) {
84
85
  return new Promise(function (resolve) {
85
86
  var authHeader = { Authorization: "Bearer ".concat(_this.bearerToken) };
86
87
  requestOptions.headers = (0, extend_1.default)(true, {}, requestOptions.headers, authHeader);
88
+ logger_1.default.debug("Authenticated outbound request (type=".concat(_this.authenticationType(), ")"));
87
89
  resolve();
88
90
  });
89
91
  };
@@ -81,4 +81,10 @@ export declare class ContainerAuthenticator extends IamRequestBasedAuthenticator
81
81
  * @returns a string that indicates the authenticator's type
82
82
  */
83
83
  authenticationType(): string;
84
+ /**
85
+ * Return the most recently stored refresh token.
86
+ *
87
+ * @returns the refresh token string
88
+ */
89
+ getRefreshToken(): string;
84
90
  }
@@ -113,6 +113,14 @@ var ContainerAuthenticator = /** @class */ (function (_super) {
113
113
  ContainerAuthenticator.prototype.authenticationType = function () {
114
114
  return authenticator_1.Authenticator.AUTHTYPE_CONTAINER;
115
115
  };
116
+ /**
117
+ * Return the most recently stored refresh token.
118
+ *
119
+ * @returns the refresh token string
120
+ */
121
+ ContainerAuthenticator.prototype.getRefreshToken = function () {
122
+ return this.tokenManager.getRefreshToken();
123
+ };
116
124
  return ContainerAuthenticator;
117
125
  }(iam_request_based_authenticator_1.IamRequestBasedAuthenticator));
118
126
  exports.ContainerAuthenticator = ContainerAuthenticator;
@@ -0,0 +1,82 @@
1
+ /**
2
+ * (C) Copyright IBM Corp. 2024.
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 { IamAssumeTokenManager } from '../token-managers';
17
+ import { IamRequestOptions, IamRequestBasedAuthenticatorImmutable } from './iam-request-based-authenticator-immutable';
18
+ /** Configuration options for IAM Assume authentication. */
19
+ export interface Options extends IamRequestOptions {
20
+ /** The IAM api key */
21
+ apikey: string;
22
+ /**
23
+ * Specify exactly one of [iamProfileId, iamProfileCrn, or iamProfileName] to
24
+ * identify the trusted profile whose identity should be used. If iamProfileId
25
+ * or iamProfileCrn is used, the trusted profile must exist in the same account.
26
+ * If and only if iamProfileName is used, then iamAccountId must also be
27
+ * specified to indicate the account that contains the trusted profile.
28
+ */
29
+ iamProfileId?: string;
30
+ iamProfileCrn?: string;
31
+ iamProfileName?: string;
32
+ /**
33
+ * If and only if iamProfileName is used to specify the trusted profile, then
34
+ * iamAccountId must also be specified to indicate the account that contains
35
+ * the trusted profile.
36
+ */
37
+ iamAccountId?: string;
38
+ }
39
+ /**
40
+ * The IamAssumeAuthenticator obtains an IAM access token using the IAM "get-token"
41
+ * operation's "assume" grant type. The authenticator obtains an initial IAM access
42
+ * token from a user-supplied apikey, then exchanges this initial IAM access token
43
+ * for another IAM access token that has "assumed the identity" of the specified
44
+ * trusted profile.
45
+ *
46
+ * The bearer token will be sent as an Authorization header in the form:
47
+ *
48
+ * Authorization: Bearer \<bearer-token\>
49
+ */
50
+ export declare class IamAssumeAuthenticator extends IamRequestBasedAuthenticatorImmutable {
51
+ protected tokenManager: IamAssumeTokenManager;
52
+ /**
53
+ *
54
+ * Create a new IamAssumeAuthenticator instance.
55
+ *
56
+ * @param options - Configuration options for IAM authentication.
57
+ * This should be an object containing these fields:
58
+ * - apikey: (required) the IAM api key for initial token request
59
+ * - iamProfileId: (optional) the ID of the trusted profile to use
60
+ * - iamProfileCrn: (optional) the CRN of the trusted profile to use
61
+ * - iamProfileName: (optional) the name of the trusted profile to use (must be specified with iamAccountId)
62
+ * - iamAccountId: (optional) the ID of the account the trusted profile is in (must be specified with iamProfileName)
63
+ * - url: (optional) the endpoint URL for the token service
64
+ * - disableSslVerification: (optional) a flag that indicates whether verification of the token server's SSL certificate
65
+ * should be disabled or not
66
+ * - headers: (optional) a set of HTTP headers to be sent with each request to the token service
67
+ * - clientId: (optional) the "clientId" and "clientSecret" fields are used to form a Basic
68
+ * Authorization header to be included in each request to the token service
69
+ * - clientSecret: (optional) the "clientId" and "clientSecret" fields are used to form a Basic
70
+ * Authorization header to be included in each request to the token service
71
+ * - scope: (optional) the "scope" parameter to use when fetching the bearer token from the token service
72
+ *
73
+ * @throws Error: the configuration options are not valid.
74
+ */
75
+ constructor(options: Options);
76
+ /**
77
+ * Returns the authenticator's type ('iamAssume').
78
+ *
79
+ * @returns a string that indicates the authenticator's type
80
+ */
81
+ authenticationType(): string;
82
+ }
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ /**
3
+ * (C) Copyright IBM Corp. 2024.
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.IamAssumeAuthenticator = void 0;
34
+ var authenticator_1 = require("./authenticator");
35
+ var token_managers_1 = require("../token-managers");
36
+ var iam_request_based_authenticator_immutable_1 = require("./iam-request-based-authenticator-immutable");
37
+ /**
38
+ * The IamAssumeAuthenticator obtains an IAM access token using the IAM "get-token"
39
+ * operation's "assume" grant type. The authenticator obtains an initial IAM access
40
+ * token from a user-supplied apikey, then exchanges this initial IAM access token
41
+ * for another IAM access token that has "assumed the identity" of the specified
42
+ * trusted profile.
43
+ *
44
+ * The bearer token will be sent as an Authorization header in the form:
45
+ *
46
+ * Authorization: Bearer \<bearer-token\>
47
+ */
48
+ var IamAssumeAuthenticator = /** @class */ (function (_super) {
49
+ __extends(IamAssumeAuthenticator, _super);
50
+ /**
51
+ *
52
+ * Create a new IamAssumeAuthenticator instance.
53
+ *
54
+ * @param options - Configuration options for IAM authentication.
55
+ * This should be an object containing these fields:
56
+ * - apikey: (required) the IAM api key for initial token request
57
+ * - iamProfileId: (optional) the ID of the trusted profile to use
58
+ * - iamProfileCrn: (optional) the CRN of the trusted profile to use
59
+ * - iamProfileName: (optional) the name of the trusted profile to use (must be specified with iamAccountId)
60
+ * - iamAccountId: (optional) the ID of the account the trusted profile is in (must be specified with iamProfileName)
61
+ * - url: (optional) the endpoint URL for the token service
62
+ * - disableSslVerification: (optional) a flag that indicates whether verification of the token server's SSL certificate
63
+ * should be disabled or not
64
+ * - headers: (optional) a set of HTTP headers to be sent with each request to the token service
65
+ * - clientId: (optional) the "clientId" and "clientSecret" fields are used to form a Basic
66
+ * Authorization header to be included in each request to the token service
67
+ * - clientSecret: (optional) the "clientId" and "clientSecret" fields are used to form a Basic
68
+ * Authorization header to be included in each request to the token service
69
+ * - scope: (optional) the "scope" parameter to use when fetching the bearer token from the token service
70
+ *
71
+ * @throws Error: the configuration options are not valid.
72
+ */
73
+ function IamAssumeAuthenticator(options) {
74
+ var _this = _super.call(this, options) || this;
75
+ // The param names are shared between the authenticator and the token
76
+ // manager so we can just pass along the options object. This will
77
+ // also perform input validation on the options.
78
+ _this.tokenManager = new token_managers_1.IamAssumeTokenManager(options);
79
+ return _this;
80
+ }
81
+ /**
82
+ * Returns the authenticator's type ('iamAssume').
83
+ *
84
+ * @returns a string that indicates the authenticator's type
85
+ */
86
+ // eslint-disable-next-line class-methods-use-this
87
+ IamAssumeAuthenticator.prototype.authenticationType = function () {
88
+ return authenticator_1.Authenticator.AUTHTYPE_IAM_ASSUME;
89
+ };
90
+ return IamAssumeAuthenticator;
91
+ }(iam_request_based_authenticator_immutable_1.IamRequestBasedAuthenticatorImmutable));
92
+ exports.IamAssumeAuthenticator = IamAssumeAuthenticator;
@@ -61,4 +61,10 @@ export declare class IamAuthenticator extends IamRequestBasedAuthenticator {
61
61
  * @returns a string that indicates the authenticator's type
62
62
  */
63
63
  authenticationType(): string;
64
+ /**
65
+ * Return the most recently stored refresh token.
66
+ *
67
+ * @returns the refresh token string
68
+ */
69
+ getRefreshToken(): string;
64
70
  }
@@ -86,6 +86,14 @@ var IamAuthenticator = /** @class */ (function (_super) {
86
86
  IamAuthenticator.prototype.authenticationType = function () {
87
87
  return authenticator_1.Authenticator.AUTHTYPE_IAM;
88
88
  };
89
+ /**
90
+ * Return the most recently stored refresh token.
91
+ *
92
+ * @returns the refresh token string
93
+ */
94
+ IamAuthenticator.prototype.getRefreshToken = function () {
95
+ return this.tokenManager.getRefreshToken();
96
+ };
89
97
  return IamAuthenticator;
90
98
  }(iam_request_based_authenticator_1.IamRequestBasedAuthenticator));
91
99
  exports.IamAuthenticator = IamAuthenticator;
@@ -0,0 +1,64 @@
1
+ /**
2
+ * (C) Copyright IBM Corp. 2024.
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 { IamRequestBasedTokenManager } from '../token-managers/iam-request-based-token-manager';
17
+ import { BaseOptions, TokenRequestBasedAuthenticatorImmutable } from './token-request-based-authenticator-immutable';
18
+ /** Configuration options for IAM Request based authentication. */
19
+ export interface IamRequestOptions extends BaseOptions {
20
+ /**
21
+ * The `clientId` and `clientSecret` fields are used to form a "basic"
22
+ * authorization header for IAM token requests.
23
+ */
24
+ clientId?: string;
25
+ /**
26
+ * The `clientId` and `clientSecret` fields are used to form a "basic"
27
+ * authorization header for IAM token requests.
28
+ */
29
+ clientSecret?: string;
30
+ /**
31
+ * The "scope" parameter to use when fetching the bearer token from the IAM token server.
32
+ */
33
+ scope?: string;
34
+ }
35
+ /**
36
+ * The IamRequestBasedAuthenticatorImmutable provides shared configuration and functionality
37
+ * for authenticators that interact with the IAM token service. This authenticator
38
+ * is not meant for use on its own.
39
+ */
40
+ export declare class IamRequestBasedAuthenticatorImmutable extends TokenRequestBasedAuthenticatorImmutable {
41
+ protected tokenManager: IamRequestBasedTokenManager;
42
+ protected clientId: string;
43
+ protected clientSecret: string;
44
+ protected scope: string;
45
+ /**
46
+ *
47
+ * Create a new IamRequestBasedAuthenticatorImmutable instance.
48
+ *
49
+ * @param options - Configuration options for IAM authentication.
50
+ * This should be an object containing these fields:
51
+ * - url: (optional) the endpoint URL for the token service
52
+ * - disableSslVerification: (optional) a flag that indicates whether verification of the token server's SSL certificate
53
+ * should be disabled or not
54
+ * - headers: (optional) a set of HTTP headers to be sent with each request to the token service
55
+ * - clientId: (optional) the "clientId" and "clientSecret" fields are used to form a Basic
56
+ * Authorization header to be included in each request to the token service
57
+ * - clientSecret: (optional) the "clientId" and "clientSecret" fields are used to form a Basic
58
+ * Authorization header to be included in each request to the token service
59
+ * - scope: (optional) the "scope" parameter to use when fetching the bearer token from the token service
60
+ *
61
+ * @throws Error: the configuration options are not valid.
62
+ */
63
+ constructor(options: IamRequestOptions);
64
+ }
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ /**
3
+ * (C) Copyright IBM Corp. 2024.
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.IamRequestBasedAuthenticatorImmutable = void 0;
34
+ var iam_request_based_token_manager_1 = require("../token-managers/iam-request-based-token-manager");
35
+ var token_request_based_authenticator_immutable_1 = require("./token-request-based-authenticator-immutable");
36
+ /**
37
+ * The IamRequestBasedAuthenticatorImmutable provides shared configuration and functionality
38
+ * for authenticators that interact with the IAM token service. This authenticator
39
+ * is not meant for use on its own.
40
+ */
41
+ var IamRequestBasedAuthenticatorImmutable = /** @class */ (function (_super) {
42
+ __extends(IamRequestBasedAuthenticatorImmutable, _super);
43
+ /**
44
+ *
45
+ * Create a new IamRequestBasedAuthenticatorImmutable instance.
46
+ *
47
+ * @param options - Configuration options for IAM authentication.
48
+ * This should be an object containing these fields:
49
+ * - url: (optional) the endpoint URL for the token service
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
+ * - clientId: (optional) the "clientId" and "clientSecret" fields are used to form a Basic
54
+ * Authorization header to be included in each request to the token service
55
+ * - clientSecret: (optional) the "clientId" and "clientSecret" fields are used to form a Basic
56
+ * Authorization header to be included in each request to the token service
57
+ * - scope: (optional) the "scope" parameter to use when fetching the bearer token from the token service
58
+ *
59
+ * @throws Error: the configuration options are not valid.
60
+ */
61
+ function IamRequestBasedAuthenticatorImmutable(options) {
62
+ var _this = this;
63
+ // all parameters are optional
64
+ options = options || {};
65
+ _this = _super.call(this, options) || this;
66
+ _this.clientId = options.clientId;
67
+ _this.clientSecret = options.clientSecret;
68
+ _this.scope = options.scope;
69
+ _this.tokenManager = new iam_request_based_token_manager_1.IamRequestBasedTokenManager(options);
70
+ return _this;
71
+ }
72
+ return IamRequestBasedAuthenticatorImmutable;
73
+ }(token_request_based_authenticator_immutable_1.TokenRequestBasedAuthenticatorImmutable));
74
+ exports.IamRequestBasedAuthenticatorImmutable = IamRequestBasedAuthenticatorImmutable;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * (C) Copyright IBM Corp. 2019, 202e.
2
+ * (C) Copyright IBM Corp. 2019, 2024.
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.
@@ -13,54 +13,17 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { IamRequestBasedTokenManager } from '../token-managers/iam-request-based-token-manager';
17
- import { BaseOptions, TokenRequestBasedAuthenticator } from './token-request-based-authenticator';
18
- /** Configuration options for IAM Request based authentication. */
19
- export interface IamRequestOptions extends BaseOptions {
20
- /**
21
- * The `clientId` and `clientSecret` fields are used to form a "basic"
22
- * authorization header for IAM token requests.
23
- */
24
- clientId?: string;
25
- /**
26
- * The `clientId` and `clientSecret` fields are used to form a "basic"
27
- * authorization header for IAM token requests.
28
- */
29
- clientSecret?: string;
30
- /**
31
- * The "scope" parameter to use when fetching the bearer token from the IAM token server.
32
- */
33
- scope?: string;
34
- }
16
+ /// <reference types="node" />
17
+ import { OutgoingHttpHeaders } from 'http';
18
+ import { IamRequestBasedAuthenticatorImmutable } from './iam-request-based-authenticator-immutable';
19
+ /** Shared configuration options for IAM Request based authentication. */
20
+ export { IamRequestOptions } from './iam-request-based-authenticator-immutable';
35
21
  /**
36
22
  * The IamRequestBasedAuthenticator provides shared configuration and functionality
37
23
  * for authenticators that interact with the IAM token service. This authenticator
38
24
  * is not meant for use on its own.
39
25
  */
40
- export declare class IamRequestBasedAuthenticator extends TokenRequestBasedAuthenticator {
41
- protected tokenManager: IamRequestBasedTokenManager;
42
- protected clientId: string;
43
- protected clientSecret: string;
44
- protected scope: string;
45
- /**
46
- *
47
- * Create a new IamRequestBasedAuthenticator instance.
48
- *
49
- * @param options - Configuration options for IAM authentication.
50
- * This should be an object containing these fields:
51
- * - url: (optional) the endpoint URL for the token service
52
- * - disableSslVerification: (optional) a flag that indicates whether verification of the token server's SSL certificate
53
- * should be disabled or not
54
- * - headers: (optional) a set of HTTP headers to be sent with each request to the token service
55
- * - clientId: (optional) the "clientId" and "clientSecret" fields are used to form a Basic
56
- * Authorization header to be included in each request to the token service
57
- * - clientSecret: (optional) the "clientId" and "clientSecret" fields are used to form a Basic
58
- * Authorization header to be included in each request to the token service
59
- * - scope: (optional) the "scope" parameter to use when fetching the bearer token from the token service
60
- *
61
- * @throws Error: the configuration options are not valid.
62
- */
63
- constructor(options: IamRequestOptions);
26
+ export declare class IamRequestBasedAuthenticator extends IamRequestBasedAuthenticatorImmutable {
64
27
  /**
65
28
  * Setter for the mutually inclusive "clientId" and the "clientSecret" fields.
66
29
  * @param clientId - the "clientId" value used to form a Basic Authorization header for IAM token requests
@@ -74,9 +37,18 @@ export declare class IamRequestBasedAuthenticator extends TokenRequestBasedAuthe
74
37
  */
75
38
  setScope(scope: string): void;
76
39
  /**
77
- * Return the most recently stored refresh token.
40
+ * Set the flag that indicates whether verification of the server's SSL
41
+ * certificate should be disabled or not.
42
+ *
43
+ * @param value - a flag that indicates whether verification of the
44
+ * token server's SSL certificate should be disabled or not.
45
+ */
46
+ setDisableSslVerification(value: boolean): void;
47
+ /**
48
+ * Set headers.
78
49
  *
79
- * @returns the refresh token string
50
+ * @param headers - a set of HTTP headers to be sent with each outbound token server request.
51
+ * Overwrites previous default headers.
80
52
  */
81
- getRefreshToken(): string;
53
+ setHeaders(headers: OutgoingHttpHeaders): void;
82
54
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * (C) Copyright IBM Corp. 2019, 202e.
3
+ * (C) Copyright IBM Corp. 2019, 2024.
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.
@@ -31,8 +31,7 @@ var __extends = (this && this.__extends) || (function () {
31
31
  })();
32
32
  Object.defineProperty(exports, "__esModule", { value: true });
33
33
  exports.IamRequestBasedAuthenticator = void 0;
34
- var iam_request_based_token_manager_1 = require("../token-managers/iam-request-based-token-manager");
35
- var token_request_based_authenticator_1 = require("./token-request-based-authenticator");
34
+ var iam_request_based_authenticator_immutable_1 = require("./iam-request-based-authenticator-immutable");
36
35
  /**
37
36
  * The IamRequestBasedAuthenticator provides shared configuration and functionality
38
37
  * for authenticators that interact with the IAM token service. This authenticator
@@ -40,34 +39,8 @@ var token_request_based_authenticator_1 = require("./token-request-based-authent
40
39
  */
41
40
  var IamRequestBasedAuthenticator = /** @class */ (function (_super) {
42
41
  __extends(IamRequestBasedAuthenticator, _super);
43
- /**
44
- *
45
- * Create a new IamRequestBasedAuthenticator instance.
46
- *
47
- * @param options - Configuration options for IAM authentication.
48
- * This should be an object containing these fields:
49
- * - url: (optional) the endpoint URL for the token service
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
- * - clientId: (optional) the "clientId" and "clientSecret" fields are used to form a Basic
54
- * Authorization header to be included in each request to the token service
55
- * - clientSecret: (optional) the "clientId" and "clientSecret" fields are used to form a Basic
56
- * Authorization header to be included in each request to the token service
57
- * - scope: (optional) the "scope" parameter to use when fetching the bearer token from the token service
58
- *
59
- * @throws Error: the configuration options are not valid.
60
- */
61
- function IamRequestBasedAuthenticator(options) {
62
- var _this = this;
63
- // all parameters are optional
64
- options = options || {};
65
- _this = _super.call(this, options) || this;
66
- _this.clientId = options.clientId;
67
- _this.clientSecret = options.clientSecret;
68
- _this.scope = options.scope;
69
- _this.tokenManager = new iam_request_based_token_manager_1.IamRequestBasedTokenManager(options);
70
- return _this;
42
+ function IamRequestBasedAuthenticator() {
43
+ return _super !== null && _super.apply(this, arguments) || this;
71
44
  }
72
45
  /**
73
46
  * Setter for the mutually inclusive "clientId" and the "clientSecret" fields.
@@ -91,13 +64,32 @@ var IamRequestBasedAuthenticator = /** @class */ (function (_super) {
91
64
  this.tokenManager.setScope(scope);
92
65
  };
93
66
  /**
94
- * Return the most recently stored refresh token.
67
+ * Set the flag that indicates whether verification of the server's SSL
68
+ * certificate should be disabled or not.
69
+ *
70
+ * @param value - a flag that indicates whether verification of the
71
+ * token server's SSL certificate should be disabled or not.
72
+ */
73
+ IamRequestBasedAuthenticator.prototype.setDisableSslVerification = function (value) {
74
+ // if they try to pass in a non-boolean value,
75
+ // use the "truthy-ness" of the value
76
+ this.disableSslVerification = Boolean(value);
77
+ this.tokenManager.setDisableSslVerification(this.disableSslVerification);
78
+ };
79
+ /**
80
+ * Set headers.
95
81
  *
96
- * @returns the refresh token string
82
+ * @param headers - a set of HTTP headers to be sent with each outbound token server request.
83
+ * Overwrites previous default headers.
97
84
  */
98
- IamRequestBasedAuthenticator.prototype.getRefreshToken = function () {
99
- return this.tokenManager.getRefreshToken();
85
+ IamRequestBasedAuthenticator.prototype.setHeaders = function (headers) {
86
+ if (typeof headers !== 'object') {
87
+ // do nothing, for now
88
+ return;
89
+ }
90
+ this.headers = headers;
91
+ this.tokenManager.setHeaders(this.headers);
100
92
  };
101
93
  return IamRequestBasedAuthenticator;
102
- }(token_request_based_authenticator_1.TokenRequestBasedAuthenticator));
94
+ }(iam_request_based_authenticator_immutable_1.IamRequestBasedAuthenticatorImmutable));
103
95
  exports.IamRequestBasedAuthenticator = IamRequestBasedAuthenticator;
@@ -19,7 +19,8 @@
19
19
  *
20
20
  * Basic Authentication
21
21
  * Bearer Token
22
- * Identity and Access Management (IAM)
22
+ * Identity and Access Management (IAM, grant type: apikey)
23
+ * Identity and Access Management (IAM, grant type: assume)
23
24
  * Container (IKS, etc)
24
25
  * VPC Instance
25
26
  * Cloud Pak for Data
@@ -35,6 +36,7 @@
35
36
  * BearerTokenAuthenticator: Authenticator for passing supplied bearer token to service endpoint.
36
37
  * CloudPakForDataAuthenticator: Authenticator for passing CP4D authentication information to service endpoint.
37
38
  * IAMAuthenticator: Authenticator for passing IAM authentication information to service endpoint.
39
+ * IAMAssumeAuthenticator: Authenticator for passing IAM authentication information to service endpoint, assuming a trusted profile.
38
40
  * ContainerAuthenticator: Authenticator for passing IAM authentication to a service, based on a token living on the container.
39
41
  * VpcInstanceAuthenticator: Authenticator that uses the VPC Instance Metadata Service API to retrieve an IAM token.
40
42
  * McspAuthenticator: Authenticator for passing MCSP authentication to a service endpoint.
@@ -52,3 +54,4 @@ export { IamRequestBasedAuthenticator } from './iam-request-based-authenticator'
52
54
  export { TokenRequestBasedAuthenticator } from './token-request-based-authenticator';
53
55
  export { VpcInstanceAuthenticator } from './vpc-instance-authenticator';
54
56
  export { McspAuthenticator } from './mcsp-authenticator';
57
+ 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.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.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,3 +38,5 @@ 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 iam_assume_authenticator_1 = require("./iam-assume-authenticator");
42
+ Object.defineProperty(exports, "IamAssumeAuthenticator", { enumerable: true, get: function () { return iam_assume_authenticator_1.IamAssumeAuthenticator; } });