ibm-cloud-sdk-core 5.0.2 → 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.
- package/.secrets.baseline +119 -15
- package/Authentication.md +146 -21
- package/CHANGELOG.md +7 -0
- package/README.md +3 -2
- package/auth/authenticators/authenticator.d.ts +1 -0
- package/auth/authenticators/authenticator.js +1 -0
- package/auth/authenticators/container-authenticator.d.ts +6 -0
- package/auth/authenticators/container-authenticator.js +8 -0
- package/auth/authenticators/iam-assume-authenticator.d.ts +82 -0
- package/auth/authenticators/iam-assume-authenticator.js +92 -0
- package/auth/authenticators/iam-authenticator.d.ts +6 -0
- package/auth/authenticators/iam-authenticator.js +8 -0
- package/auth/authenticators/iam-request-based-authenticator-immutable.d.ts +64 -0
- package/auth/authenticators/iam-request-based-authenticator-immutable.js +74 -0
- package/auth/authenticators/iam-request-based-authenticator.d.ts +19 -47
- package/auth/authenticators/iam-request-based-authenticator.js +28 -36
- package/auth/authenticators/index.d.ts +4 -1
- package/auth/authenticators/index.js +3 -1
- package/auth/authenticators/token-request-based-authenticator-immutable.d.ts +71 -0
- package/auth/authenticators/token-request-based-authenticator-immutable.js +91 -0
- package/auth/authenticators/token-request-based-authenticator.d.ts +4 -42
- package/auth/authenticators/token-request-based-authenticator.js +5 -43
- package/auth/token-managers/container-token-manager.d.ts +6 -0
- package/auth/token-managers/container-token-manager.js +18 -50
- package/auth/token-managers/iam-assume-token-manager.d.ts +101 -0
- package/auth/token-managers/iam-assume-token-manager.js +220 -0
- package/auth/token-managers/iam-request-based-token-manager.d.ts +3 -9
- package/auth/token-managers/iam-request-based-token-manager.js +0 -8
- package/auth/token-managers/iam-token-manager.d.ts +8 -2
- package/auth/token-managers/iam-token-manager.js +10 -2
- package/auth/token-managers/index.d.ts +4 -2
- package/auth/token-managers/index.js +6 -3
- package/auth/utils/get-authenticator-from-environment.js +3 -0
- package/auth/utils/helpers.d.ts +18 -23
- package/auth/utils/helpers.js +50 -30
- package/docs/ibm-cloud-sdk-core.api.json +787 -404
- package/es/auth/authenticators/authenticator.d.ts +1 -0
- package/es/auth/authenticators/authenticator.js +1 -0
- package/es/auth/authenticators/container-authenticator.d.ts +6 -0
- package/es/auth/authenticators/container-authenticator.js +8 -0
- package/es/auth/authenticators/iam-assume-authenticator.d.ts +82 -0
- package/es/auth/authenticators/iam-assume-authenticator.js +70 -0
- package/es/auth/authenticators/iam-authenticator.d.ts +6 -0
- package/es/auth/authenticators/iam-authenticator.js +8 -0
- package/es/auth/authenticators/iam-request-based-authenticator-immutable.d.ts +64 -0
- package/es/auth/authenticators/iam-request-based-authenticator-immutable.js +51 -0
- package/es/auth/authenticators/iam-request-based-authenticator.d.ts +19 -47
- package/es/auth/authenticators/iam-request-based-authenticator.js +26 -35
- package/es/auth/authenticators/index.d.ts +4 -1
- package/es/auth/authenticators/index.js +1 -0
- package/es/auth/authenticators/token-request-based-authenticator-immutable.d.ts +71 -0
- package/es/auth/authenticators/token-request-based-authenticator-immutable.js +65 -0
- package/es/auth/authenticators/token-request-based-authenticator.d.ts +4 -42
- package/es/auth/authenticators/token-request-based-authenticator.js +3 -39
- package/es/auth/token-managers/container-token-manager.d.ts +6 -0
- package/es/auth/token-managers/container-token-manager.js +18 -24
- package/es/auth/token-managers/iam-assume-token-manager.d.ts +101 -0
- package/es/auth/token-managers/iam-assume-token-manager.js +164 -0
- package/es/auth/token-managers/iam-request-based-token-manager.d.ts +3 -9
- package/es/auth/token-managers/iam-request-based-token-manager.js +0 -8
- package/es/auth/token-managers/iam-token-manager.d.ts +8 -2
- package/es/auth/token-managers/iam-token-manager.js +10 -2
- package/es/auth/token-managers/index.d.ts +4 -2
- package/es/auth/token-managers/index.js +4 -2
- package/es/auth/utils/get-authenticator-from-environment.js +4 -1
- package/es/auth/utils/helpers.d.ts +18 -23
- package/es/auth/utils/helpers.js +35 -27
- package/etc/ibm-cloud-sdk-core.api.md +46 -28
- package/ibm-cloud-sdk-core.d.ts +264 -68
- package/package.json +2 -2
|
@@ -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,
|
|
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
|
-
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
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
|
|
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
|
-
*
|
|
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
|
-
* @
|
|
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
|
-
|
|
53
|
+
setHeaders(headers: OutgoingHttpHeaders): void;
|
|
82
54
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* (C) Copyright IBM Corp. 2019,
|
|
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
|
|
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
|
-
*
|
|
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
|
-
* @
|
|
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.
|
|
99
|
-
|
|
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
|
-
}(
|
|
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; } });
|
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
/// <reference types="node" />
|
|
17
|
+
import { OutgoingHttpHeaders } from 'http';
|
|
18
|
+
import { JwtTokenManager } from '../token-managers/jwt-token-manager';
|
|
19
|
+
import { Authenticator } from './authenticator';
|
|
20
|
+
import { AuthenticateOptions } from './authenticator-interface';
|
|
21
|
+
/** Configuration options for token-based authentication. */
|
|
22
|
+
export type BaseOptions = {
|
|
23
|
+
/** Headers to be sent with every outbound HTTP requests to token services. */
|
|
24
|
+
headers?: OutgoingHttpHeaders;
|
|
25
|
+
/**
|
|
26
|
+
* A flag that indicates whether verification of the token server's SSL
|
|
27
|
+
* certificate should be disabled or not.
|
|
28
|
+
*/
|
|
29
|
+
disableSslVerification?: boolean;
|
|
30
|
+
/** Endpoint for HTTP token requests. */
|
|
31
|
+
url?: string;
|
|
32
|
+
/** Allow additional request config parameters */
|
|
33
|
+
[propName: string]: any;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Class for common functionality shared by token-request authenticators.
|
|
37
|
+
* Token-request authenticators use token managers to retrieve, store,
|
|
38
|
+
* and refresh tokens. Not intended to be used as stand-alone authenticator,
|
|
39
|
+
* but as base class to authenticators that have their own token manager
|
|
40
|
+
* implementations.
|
|
41
|
+
*
|
|
42
|
+
* The token will be added as an Authorization header in the form:
|
|
43
|
+
*
|
|
44
|
+
* Authorization: Bearer \<bearer-token\>
|
|
45
|
+
*/
|
|
46
|
+
export declare class TokenRequestBasedAuthenticatorImmutable extends Authenticator {
|
|
47
|
+
protected tokenManager: JwtTokenManager;
|
|
48
|
+
protected url: string;
|
|
49
|
+
protected headers: OutgoingHttpHeaders;
|
|
50
|
+
protected disableSslVerification: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Create a new TokenRequestBasedAuthenticatorImmutable instance with an internal JwtTokenManager.
|
|
53
|
+
*
|
|
54
|
+
* @param options - Configuration options.
|
|
55
|
+
* This should be an object containing these fields:
|
|
56
|
+
* - url: (optional) the endpoint URL for the token service
|
|
57
|
+
* - disableSslVerification: (optional) a flag that indicates whether verification of the token server's SSL certificate
|
|
58
|
+
* should be disabled or not
|
|
59
|
+
* - headers: (optional) a set of HTTP headers to be sent with each request to the token service
|
|
60
|
+
*/
|
|
61
|
+
constructor(options: BaseOptions);
|
|
62
|
+
/**
|
|
63
|
+
* Adds bearer token information to "requestOptions". The bearer token information
|
|
64
|
+
* will be set in the Authorization property of "requestOptions.headers" in the form:
|
|
65
|
+
*
|
|
66
|
+
* Authorization: Bearer \<bearer-token\>
|
|
67
|
+
*
|
|
68
|
+
* @param requestOptions - The request to augment with authentication information.
|
|
69
|
+
*/
|
|
70
|
+
authenticate(requestOptions: AuthenticateOptions): Promise<void>;
|
|
71
|
+
}
|