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.
Files changed (70) hide show
  1. package/.secrets.baseline +119 -15
  2. package/Authentication.md +146 -21
  3. package/CHANGELOG.md +7 -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/container-authenticator.d.ts +6 -0
  8. package/auth/authenticators/container-authenticator.js +8 -0
  9. package/auth/authenticators/iam-assume-authenticator.d.ts +82 -0
  10. package/auth/authenticators/iam-assume-authenticator.js +92 -0
  11. package/auth/authenticators/iam-authenticator.d.ts +6 -0
  12. package/auth/authenticators/iam-authenticator.js +8 -0
  13. package/auth/authenticators/iam-request-based-authenticator-immutable.d.ts +64 -0
  14. package/auth/authenticators/iam-request-based-authenticator-immutable.js +74 -0
  15. package/auth/authenticators/iam-request-based-authenticator.d.ts +19 -47
  16. package/auth/authenticators/iam-request-based-authenticator.js +28 -36
  17. package/auth/authenticators/index.d.ts +4 -1
  18. package/auth/authenticators/index.js +3 -1
  19. package/auth/authenticators/token-request-based-authenticator-immutable.d.ts +71 -0
  20. package/auth/authenticators/token-request-based-authenticator-immutable.js +91 -0
  21. package/auth/authenticators/token-request-based-authenticator.d.ts +4 -42
  22. package/auth/authenticators/token-request-based-authenticator.js +5 -43
  23. package/auth/token-managers/container-token-manager.d.ts +6 -0
  24. package/auth/token-managers/container-token-manager.js +18 -50
  25. package/auth/token-managers/iam-assume-token-manager.d.ts +101 -0
  26. package/auth/token-managers/iam-assume-token-manager.js +220 -0
  27. package/auth/token-managers/iam-request-based-token-manager.d.ts +3 -9
  28. package/auth/token-managers/iam-request-based-token-manager.js +0 -8
  29. package/auth/token-managers/iam-token-manager.d.ts +8 -2
  30. package/auth/token-managers/iam-token-manager.js +10 -2
  31. package/auth/token-managers/index.d.ts +4 -2
  32. package/auth/token-managers/index.js +6 -3
  33. package/auth/utils/get-authenticator-from-environment.js +3 -0
  34. package/auth/utils/helpers.d.ts +18 -23
  35. package/auth/utils/helpers.js +50 -30
  36. package/docs/ibm-cloud-sdk-core.api.json +787 -404
  37. package/es/auth/authenticators/authenticator.d.ts +1 -0
  38. package/es/auth/authenticators/authenticator.js +1 -0
  39. package/es/auth/authenticators/container-authenticator.d.ts +6 -0
  40. package/es/auth/authenticators/container-authenticator.js +8 -0
  41. package/es/auth/authenticators/iam-assume-authenticator.d.ts +82 -0
  42. package/es/auth/authenticators/iam-assume-authenticator.js +70 -0
  43. package/es/auth/authenticators/iam-authenticator.d.ts +6 -0
  44. package/es/auth/authenticators/iam-authenticator.js +8 -0
  45. package/es/auth/authenticators/iam-request-based-authenticator-immutable.d.ts +64 -0
  46. package/es/auth/authenticators/iam-request-based-authenticator-immutable.js +51 -0
  47. package/es/auth/authenticators/iam-request-based-authenticator.d.ts +19 -47
  48. package/es/auth/authenticators/iam-request-based-authenticator.js +26 -35
  49. package/es/auth/authenticators/index.d.ts +4 -1
  50. package/es/auth/authenticators/index.js +1 -0
  51. package/es/auth/authenticators/token-request-based-authenticator-immutable.d.ts +71 -0
  52. package/es/auth/authenticators/token-request-based-authenticator-immutable.js +65 -0
  53. package/es/auth/authenticators/token-request-based-authenticator.d.ts +4 -42
  54. package/es/auth/authenticators/token-request-based-authenticator.js +3 -39
  55. package/es/auth/token-managers/container-token-manager.d.ts +6 -0
  56. package/es/auth/token-managers/container-token-manager.js +18 -24
  57. package/es/auth/token-managers/iam-assume-token-manager.d.ts +101 -0
  58. package/es/auth/token-managers/iam-assume-token-manager.js +164 -0
  59. package/es/auth/token-managers/iam-request-based-token-manager.d.ts +3 -9
  60. package/es/auth/token-managers/iam-request-based-token-manager.js +0 -8
  61. package/es/auth/token-managers/iam-token-manager.d.ts +8 -2
  62. package/es/auth/token-managers/iam-token-manager.js +10 -2
  63. package/es/auth/token-managers/index.d.ts +4 -2
  64. package/es/auth/token-managers/index.js +4 -2
  65. package/es/auth/utils/get-authenticator-from-environment.js +4 -1
  66. package/es/auth/utils/helpers.d.ts +18 -23
  67. package/es/auth/utils/helpers.js +35 -27
  68. package/etc/ibm-cloud-sdk-core.api.md +46 -28
  69. package/ibm-cloud-sdk-core.d.ts +264 -68
  70. package/package.json +2 -2
@@ -16,8 +16,8 @@
16
16
  /**
17
17
  * @module token-managers
18
18
  * The ibm-cloud-sdk-core module supports the following types of token authentication:
19
- *
20
- * Identity and Access Management (IAM)
19
+ * Identity and Access Management (IAM, grant type: apikey)
20
+ * Identity and Access Management (IAM, grant type: assume)
21
21
  * Cloud Pak for Data
22
22
  * Container (IKS, etc)
23
23
  * VPC Instance
@@ -28,6 +28,7 @@
28
28
  *
29
29
  * classes:
30
30
  * IamTokenManager: Token Manager of IAM via apikey.
31
+ * IamAssumeTokenManager: Token Manager of IAM via apikey and trusted profile.
31
32
  * Cp4dTokenManager: Token Manager of CloudPak for data.
32
33
  * ContainerTokenManager: Token manager of IAM via compute resource token.
33
34
  * VpcInstanceTokenManager: Token manager of VPC Instance Metadata Service API tokens.
@@ -42,3 +43,4 @@ export { JwtTokenManager } from './jwt-token-manager';
42
43
  export { TokenManager } from './token-manager';
43
44
  export { VpcInstanceTokenManager } from './vpc-instance-token-manager';
44
45
  export { McspTokenManager } from './mcsp-token-manager';
46
+ export { IamAssumeTokenManager } from './iam-assume-token-manager';
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { Authenticator, BasicAuthenticator, BearerTokenAuthenticator, CloudPakForDataAuthenticator, IamAuthenticator, ContainerAuthenticator, NoAuthAuthenticator, VpcInstanceAuthenticator, McspAuthenticator, } from '../authenticators';
16
+ import { Authenticator, BasicAuthenticator, BearerTokenAuthenticator, CloudPakForDataAuthenticator, IamAuthenticator, IamAssumeAuthenticator, ContainerAuthenticator, NoAuthAuthenticator, VpcInstanceAuthenticator, McspAuthenticator, } from '../authenticators';
17
17
  import { readExternalSources } from './read-external-sources';
18
18
  /**
19
19
  * Look for external configuration of authenticator.
@@ -78,6 +78,9 @@ export function getAuthenticatorFromEnvironment(serviceName) {
78
78
  else if (authType === Authenticator.AUTHTYPE_IAM.toLowerCase()) {
79
79
  authenticator = new IamAuthenticator(credentials);
80
80
  }
81
+ else if (authType === Authenticator.AUTHTYPE_IAM_ASSUME.toLowerCase()) {
82
+ authenticator = new IamAssumeAuthenticator(credentials);
83
+ }
81
84
  else if (authType === Authenticator.AUTHTYPE_CONTAINER.toLowerCase()) {
82
85
  authenticator = new ContainerAuthenticator(credentials);
83
86
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * (C) Copyright IBM Corp. 2019, 2022.
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.
@@ -43,17 +43,6 @@ export declare function validateInput(options: any, requiredOptions: string[]):
43
43
  * @returns the current time in seconds.
44
44
  */
45
45
  export declare function getCurrentTime(): number;
46
- /**
47
- * Checks for only one of two elements being defined.
48
- * Returns true if a is defined and b is undefined,
49
- * or vice versa. Returns false if both are defined
50
- * or both are undefined.
51
- *
52
- * @param a - The first object
53
- * @param b - The second object
54
- * @returns true if and only if exactly one of a or b is defined
55
- */
56
- export declare function onlyOne(a: any, b: any): boolean;
57
46
  /**
58
47
  * Removes a given suffix if it exists.
59
48
  *
@@ -64,20 +53,26 @@ export declare function onlyOne(a: any, b: any): boolean;
64
53
  */
65
54
  export declare function removeSuffix(str: string, suffix: string): string;
66
55
  /**
67
- * Checks for at least one of two elements being defined.
56
+ * Checks that exactly one of the arguments provided is defined.
57
+ * Returns true if one argument is defined. Returns false if no
58
+ * argument are defined or if 2 or more are defined.
68
59
  *
69
- * @param a - the first object
70
- * @param b - the second object
71
- * @returns true if a or b is defined; false if both are undefined
60
+ * @param args - The spread of arguments to check
61
+ * @returns true if and only if exactly one argument is defined
72
62
  */
73
- export declare function atLeastOne(a: any, b: any): boolean;
63
+ export declare function onlyOne(...args: any): boolean;
74
64
  /**
75
- * Verifies that both properties are not specified.
65
+ * Checks for at least one of the given elements being defined.
76
66
  *
77
- * @param a - The first object
78
- * @param b - The second object
67
+ * @param args - The spread of arguments to check
68
+ * @returns true if one or more are defined; false if all are undefined
69
+ */
70
+ export declare function atLeastOne(...args: any): boolean;
71
+ /**
72
+ * Verifies that no more than one of the given elements are defined.
73
+ * Returns true if one or none are defined, and false otherwise.
79
74
  *
80
- * @returns false if a and b are both defined, true otherwise
81
-
75
+ * @param args - The spread of arguments to check
76
+ * @returns false if more than one elements are defined, true otherwise
82
77
  */
83
- export declare function atMostOne(a: any, b: any): boolean;
78
+ export declare function atMostOne(...args: any): boolean;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * (C) Copyright IBM Corp. 2019, 2022.
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.
@@ -80,19 +80,6 @@ export function validateInput(options, requiredOptions) {
80
80
  export function getCurrentTime() {
81
81
  return Math.floor(Date.now() / 1000);
82
82
  }
83
- /**
84
- * Checks for only one of two elements being defined.
85
- * Returns true if a is defined and b is undefined,
86
- * or vice versa. Returns false if both are defined
87
- * or both are undefined.
88
- *
89
- * @param a - The first object
90
- * @param b - The second object
91
- * @returns true if and only if exactly one of a or b is defined
92
- */
93
- export function onlyOne(a, b) {
94
- return Boolean((a && !b) || (b && !a));
95
- }
96
83
  /**
97
84
  * Removes a given suffix if it exists.
98
85
  *
@@ -108,24 +95,45 @@ export function removeSuffix(str, suffix) {
108
95
  return str;
109
96
  }
110
97
  /**
111
- * Checks for at least one of two elements being defined.
98
+ * Checks that exactly one of the arguments provided is defined.
99
+ * Returns true if one argument is defined. Returns false if no
100
+ * argument are defined or if 2 or more are defined.
112
101
  *
113
- * @param a - the first object
114
- * @param b - the second object
115
- * @returns true if a or b is defined; false if both are undefined
102
+ * @param args - The spread of arguments to check
103
+ * @returns true if and only if exactly one argument is defined
116
104
  */
117
- export function atLeastOne(a, b) {
118
- return Boolean(a || b);
105
+ export function onlyOne(...args) {
106
+ return countDefinedArgs(args) === 1;
119
107
  }
120
108
  /**
121
- * Verifies that both properties are not specified.
109
+ * Checks for at least one of the given elements being defined.
122
110
  *
123
- * @param a - The first object
124
- * @param b - The second object
111
+ * @param args - The spread of arguments to check
112
+ * @returns true if one or more are defined; false if all are undefined
113
+ */
114
+ export function atLeastOne(...args) {
115
+ return countDefinedArgs(args) >= 1;
116
+ }
117
+ /**
118
+ * Verifies that no more than one of the given elements are defined.
119
+ * Returns true if one or none are defined, and false otherwise.
125
120
  *
126
- * @returns false if a and b are both defined, true otherwise
127
-
121
+ * @param args - The spread of arguments to check
122
+ * @returns false if more than one elements are defined, true otherwise
128
123
  */
129
- export function atMostOne(a, b) {
130
- return Boolean(!(a && b));
124
+ export function atMostOne(...args) {
125
+ return countDefinedArgs(args) <= 1;
126
+ }
127
+ /**
128
+ * Takes a list of anything (intended to be the arguments passed to one of the
129
+ * argument checking functions above) and returns how many elements in that
130
+ * list are not undefined.
131
+ */
132
+ function countDefinedArgs(args) {
133
+ return args.reduce((total, arg) => {
134
+ if (arg) {
135
+ total += 1;
136
+ }
137
+ return total;
138
+ }, 0);
131
139
  }
@@ -13,10 +13,10 @@ import { OutgoingHttpHeaders } from 'http';
13
13
  import { Stream } from 'stream';
14
14
 
15
15
  // @public
16
- export function atLeastOne(a: any, b: any): boolean;
16
+ export function atLeastOne(...args: any): boolean;
17
17
 
18
18
  // @public
19
- export function atMostOne(a: any, b: any): boolean;
19
+ export function atMostOne(...args: any): boolean;
20
20
 
21
21
  // @public
22
22
  export class Authenticator implements AuthenticatorInterface {
@@ -34,6 +34,8 @@ export class Authenticator implements AuthenticatorInterface {
34
34
  // (undocumented)
35
35
  static AUTHTYPE_IAM: string;
36
36
  // (undocumented)
37
+ static AUTHTYPE_IAM_ASSUME: string;
38
+ // (undocumented)
37
39
  static AUTHTYPE_MCSP: string;
38
40
  // (undocumented)
39
41
  static AUTHTYPE_NOAUTH: string;
@@ -130,6 +132,7 @@ export class ContainerAuthenticator extends IamRequestBasedAuthenticator {
130
132
  // Warning: (ae-forgotten-export) The symbol "Options_8" needs to be exported by the entry point index.d.ts
131
133
  constructor(options: Options_8);
132
134
  authenticationType(): string;
135
+ getRefreshToken(): string;
133
136
  setCrTokenFilename(crTokenFilename: string): void;
134
137
  setIamProfileId(iamProfileId: string): void;
135
138
  setIamProfileName(iamProfileName: string): void;
@@ -142,6 +145,7 @@ export class ContainerTokenManager extends IamRequestBasedTokenManager {
142
145
  // Warning: (ae-forgotten-export) The symbol "Options_7" needs to be exported by the entry point index.d.ts
143
146
  constructor(options: Options_7);
144
147
  protected getCrToken(): string;
148
+ getRefreshToken(): string;
145
149
  protected requestToken(): Promise<any>;
146
150
  setCrTokenFilename(crTokenFilename: string): void;
147
151
  setIamProfileId(iamProfileId: string): void;
@@ -224,11 +228,37 @@ export function getNewLogger(moduleName: string): SDKLogger;
224
228
  // @public
225
229
  export function getQueryParam(urlStr: string, param: string): string;
226
230
 
231
+ // Warning: (ae-forgotten-export) The symbol "IamRequestBasedAuthenticatorImmutable" needs to be exported by the entry point index.d.ts
232
+ //
233
+ // @public
234
+ export class IamAssumeAuthenticator extends IamRequestBasedAuthenticatorImmutable {
235
+ // Warning: (ae-forgotten-export) The symbol "Options_14" needs to be exported by the entry point index.d.ts
236
+ constructor(options: Options_14);
237
+ authenticationType(): string;
238
+ // (undocumented)
239
+ protected tokenManager: IamAssumeTokenManager;
240
+ }
241
+
242
+ // @public
243
+ export class IamAssumeTokenManager extends IamRequestBasedTokenManager {
244
+ // Warning: (ae-forgotten-export) The symbol "Options_13" needs to be exported by the entry point index.d.ts
245
+ constructor(options: Options_13);
246
+ protected requestToken(): Promise<any>;
247
+ // (undocumented)
248
+ protected requiredOptions: string[];
249
+ protected saveTokenInfo(tokenResponse: any): void;
250
+ setClientIdAndSecret(clientId: string, clientSecret: string): void;
251
+ setDisableSslVerification(value: boolean): void;
252
+ setHeaders(headers: OutgoingHttpHeaders): void;
253
+ setScope(scope: string): void;
254
+ }
255
+
227
256
  // @public
228
257
  export class IamAuthenticator extends IamRequestBasedAuthenticator {
229
258
  // Warning: (ae-forgotten-export) The symbol "Options_6" needs to be exported by the entry point index.d.ts
230
259
  constructor(options: Options_6);
231
260
  authenticationType(): string;
261
+ getRefreshToken(): string;
232
262
  // (undocumented)
233
263
  protected requiredOptions: string[];
234
264
  // (undocumented)
@@ -236,33 +266,29 @@ export class IamAuthenticator extends IamRequestBasedAuthenticator {
236
266
  }
237
267
 
238
268
  // @public
239
- export class IamRequestBasedAuthenticator extends TokenRequestBasedAuthenticator {
240
- // Warning: (ae-forgotten-export) The symbol "IamRequestOptions_2" needs to be exported by the entry point index.d.ts
241
- constructor(options: IamRequestOptions_2);
242
- // (undocumented)
243
- protected clientId: string;
244
- // (undocumented)
245
- protected clientSecret: string;
246
- getRefreshToken(): string;
247
- // (undocumented)
248
- protected scope: string;
269
+ export class IamRequestBasedAuthenticator extends IamRequestBasedAuthenticatorImmutable {
249
270
  setClientIdAndSecret(clientId: string, clientSecret: string): void;
271
+ setDisableSslVerification(value: boolean): void;
272
+ setHeaders(headers: OutgoingHttpHeaders): void;
250
273
  setScope(scope: string): void;
251
- // (undocumented)
252
- protected tokenManager: IamRequestBasedTokenManager;
253
274
  }
254
275
 
255
276
  // @public
256
277
  export class IamRequestBasedTokenManager extends JwtTokenManager {
257
278
  constructor(options: IamRequestOptions);
258
279
  // (undocumented)
280
+ protected clientId: string;
281
+ // (undocumented)
282
+ protected clientSecret: string;
283
+ // (undocumented)
259
284
  protected formData: any;
260
- getRefreshToken(): string;
261
285
  protected isTokenExpired(): boolean;
262
286
  // (undocumented)
263
287
  protected refreshToken: string;
264
288
  protected requestToken(): Promise<any>;
265
289
  protected saveTokenInfo(tokenResponse: any): void;
290
+ // (undocumented)
291
+ protected scope: string;
266
292
  setClientIdAndSecret(clientId: string, clientSecret: string): void;
267
293
  setScope(scope: string): void;
268
294
  }
@@ -281,6 +307,7 @@ export interface IamRequestOptions extends JwtTokenManagerOptions {
281
307
  export class IamTokenManager extends IamRequestBasedTokenManager {
282
308
  // Warning: (ae-forgotten-export) The symbol "Options_5" needs to be exported by the entry point index.d.ts
283
309
  constructor(options: Options_5);
310
+ getRefreshToken(): string;
284
311
  // (undocumented)
285
312
  protected requiredOptions: string[];
286
313
  }
@@ -343,7 +370,7 @@ export class NoAuthAuthenticator extends Authenticator {
343
370
  }
344
371
 
345
372
  // @public
346
- export function onlyOne(a: any, b: any): boolean;
373
+ export function onlyOne(...args: any): boolean;
347
374
 
348
375
  // @public
349
376
  export const qs: {
@@ -420,21 +447,12 @@ export type TokenManagerOptions = {
420
447
  [propName: string]: any;
421
448
  };
422
449
 
450
+ // Warning: (ae-forgotten-export) The symbol "TokenRequestBasedAuthenticatorImmutable" needs to be exported by the entry point index.d.ts
451
+ //
423
452
  // @public
424
- export class TokenRequestBasedAuthenticator extends Authenticator {
425
- // Warning: (ae-forgotten-export) The symbol "BaseOptions" needs to be exported by the entry point index.d.ts
426
- constructor(options: BaseOptions);
427
- authenticate(requestOptions: AuthenticateOptions): Promise<void>;
428
- // (undocumented)
429
- protected disableSslVerification: boolean;
430
- // (undocumented)
431
- protected headers: OutgoingHttpHeaders;
453
+ export class TokenRequestBasedAuthenticator extends TokenRequestBasedAuthenticatorImmutable {
432
454
  setDisableSslVerification(value: boolean): void;
433
455
  setHeaders(headers: OutgoingHttpHeaders): void;
434
- // (undocumented)
435
- protected tokenManager: JwtTokenManager;
436
- // (undocumented)
437
- protected url: string;
438
456
  }
439
457
 
440
458
  // @public