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
package/.secrets.baseline CHANGED
@@ -3,7 +3,7 @@
3
3
  "files": "package-lock.json|^.secrets.baseline$",
4
4
  "lines": null
5
5
  },
6
- "generated_at": "2024-08-29T14:54:57Z",
6
+ "generated_at": "2024-10-10T20:59:14Z",
7
7
  "plugins_used": [
8
8
  {
9
9
  "name": "AWSKeyDetector"
@@ -70,7 +70,39 @@
70
70
  "hashed_secret": "91dfd9ddb4198affc5c194cd8ce6d338fde470e2",
71
71
  "is_secret": false,
72
72
  "is_verified": false,
73
- "line_number": 74,
73
+ "line_number": 75,
74
+ "type": "Secret Keyword",
75
+ "verified_result": null
76
+ },
77
+ {
78
+ "hashed_secret": "4f51cde3ac0a5504afa4bc06859b098366592c19",
79
+ "is_secret": false,
80
+ "is_verified": false,
81
+ "line_number": 236,
82
+ "type": "Secret Keyword",
83
+ "verified_result": null
84
+ },
85
+ {
86
+ "hashed_secret": "e87559ed7decb62d0733ae251ae58d42a55291d8",
87
+ "is_secret": false,
88
+ "is_verified": false,
89
+ "line_number": 238,
90
+ "type": "Secret Keyword",
91
+ "verified_result": null
92
+ },
93
+ {
94
+ "hashed_secret": "12f4a68ed3d0863e56497c9cdb1e2e4e91d5cb68",
95
+ "is_secret": false,
96
+ "is_verified": false,
97
+ "line_number": 302,
98
+ "type": "Secret Keyword",
99
+ "verified_result": null
100
+ },
101
+ {
102
+ "hashed_secret": "c837b75d7cd93ef9c2243ca28d6e5156259fd253",
103
+ "is_secret": false,
104
+ "is_verified": false,
105
+ "line_number": 306,
74
106
  "type": "Secret Keyword",
75
107
  "verified_result": null
76
108
  },
@@ -78,7 +110,7 @@
78
110
  "hashed_secret": "98635b2eaa2379f28cd6d72a38299f286b81b459",
79
111
  "is_secret": false,
80
112
  "is_verified": false,
81
- "line_number": 433,
113
+ "line_number": 558,
82
114
  "type": "Secret Keyword",
83
115
  "verified_result": null
84
116
  },
@@ -86,7 +118,7 @@
86
118
  "hashed_secret": "47fcf185ee7e15fe05cae31fbe9e4ebe4a06a40d",
87
119
  "is_secret": false,
88
120
  "is_verified": false,
89
- "line_number": 543,
121
+ "line_number": 668,
90
122
  "type": "Secret Keyword",
91
123
  "verified_result": null
92
124
  }
@@ -96,7 +128,7 @@
96
128
  "hashed_secret": "bc2f74c22f98f7b6ffbc2f67453dbfa99bce9a32",
97
129
  "is_secret": false,
98
130
  "is_verified": false,
99
- "line_number": 207,
131
+ "line_number": 214,
100
132
  "type": "Secret Keyword",
101
133
  "verified_result": null
102
134
  }
@@ -106,7 +138,7 @@
106
138
  "hashed_secret": "32e8612d8ca77c7ea8374aa7918db8e5df9252ed",
107
139
  "is_secret": false,
108
140
  "is_verified": false,
109
- "line_number": 62,
141
+ "line_number": 63,
110
142
  "type": "Secret Keyword",
111
143
  "verified_result": null
112
144
  }
@@ -116,7 +148,7 @@
116
148
  "hashed_secret": "fdee05598fdd57ff8e9ae29e92c25a04f2c52fa6",
117
149
  "is_secret": false,
118
150
  "is_verified": false,
119
- "line_number": 39,
151
+ "line_number": 41,
120
152
  "type": "Secret Keyword",
121
153
  "verified_result": null
122
154
  }
@@ -159,20 +191,22 @@
159
191
  "verified_result": null
160
192
  }
161
193
  ],
162
- "auth/authenticators/iam-request-based-authenticator.ts": [
194
+ "auth/authenticators/iam-request-based-authenticator-immutable.ts": [
163
195
  {
164
196
  "hashed_secret": "f84f793e0af9ade37c8b927bc5091e98f35bf821",
165
197
  "is_secret": false,
166
198
  "is_verified": false,
167
- "line_number": 78,
199
+ "line_number": 81,
168
200
  "type": "Secret Keyword",
169
201
  "verified_result": null
170
- },
202
+ }
203
+ ],
204
+ "auth/authenticators/iam-request-based-authenticator.ts": [
171
205
  {
172
206
  "hashed_secret": "45c43fe97e3a06ab078b0eeff6fbe622cc417a25",
173
207
  "is_secret": false,
174
208
  "is_verified": false,
175
- "line_number": 89,
209
+ "line_number": 34,
176
210
  "type": "Secret Keyword",
177
211
  "verified_result": null
178
212
  },
@@ -180,7 +214,7 @@
180
214
  "hashed_secret": "99833a8b234b57b886a9aef1dba187fdd7ceece8",
181
215
  "is_secret": false,
182
216
  "is_verified": false,
183
- "line_number": 91,
217
+ "line_number": 36,
184
218
  "type": "Secret Keyword",
185
219
  "verified_result": null
186
220
  }
@@ -239,6 +273,32 @@
239
273
  "verified_result": null
240
274
  }
241
275
  ],
276
+ "auth/token-managers/iam-assume-token-manager.ts": [
277
+ {
278
+ "hashed_secret": "2ac283c95478b7355a84b60cd52c1722de2cbc3a",
279
+ "is_secret": false,
280
+ "is_verified": false,
281
+ "line_number": 111,
282
+ "type": "Secret Keyword",
283
+ "verified_result": null
284
+ },
285
+ {
286
+ "hashed_secret": "faed0c503983c5ab06e19630096d39ebfafef86a",
287
+ "is_secret": false,
288
+ "is_verified": false,
289
+ "line_number": 115,
290
+ "type": "Secret Keyword",
291
+ "verified_result": null
292
+ },
293
+ {
294
+ "hashed_secret": "45c43fe97e3a06ab078b0eeff6fbe622cc417a25",
295
+ "is_secret": false,
296
+ "is_verified": false,
297
+ "line_number": 168,
298
+ "type": "Secret Keyword",
299
+ "verified_result": null
300
+ }
301
+ ],
242
302
  "auth/token-managers/iam-request-based-token-manager.ts": [
243
303
  {
244
304
  "hashed_secret": "f84f793e0af9ade37c8b927bc5091e98f35bf821",
@@ -314,7 +374,7 @@
314
374
  "hashed_secret": "6947818ac409551f11fbaa78f0ea6391960aa5b8",
315
375
  "is_secret": false,
316
376
  "is_verified": false,
317
- "line_number": 50,
377
+ "line_number": 51,
318
378
  "type": "Secret Keyword",
319
379
  "verified_result": null
320
380
  }
@@ -334,7 +394,7 @@
334
394
  "hashed_secret": "45c43fe97e3a06ab078b0eeff6fbe622cc417a25",
335
395
  "is_secret": false,
336
396
  "is_verified": false,
337
- "line_number": 266,
397
+ "line_number": 286,
338
398
  "type": "Secret Keyword",
339
399
  "verified_result": null
340
400
  }
@@ -455,6 +515,50 @@
455
515
  "verified_result": null
456
516
  }
457
517
  ],
518
+ "test/unit/iam-assume-authenticator.test.js": [
519
+ {
520
+ "hashed_secret": "9cea46b39bd44a1ef9f3e71bfe9e45c24d3300f6",
521
+ "is_secret": false,
522
+ "is_verified": false,
523
+ "line_number": 33,
524
+ "type": "Secret Keyword",
525
+ "verified_result": null
526
+ },
527
+ {
528
+ "hashed_secret": "5c5a15a8b0b3e154d77746945e563ba40100681b",
529
+ "is_secret": false,
530
+ "is_verified": false,
531
+ "line_number": 37,
532
+ "type": "Secret Keyword",
533
+ "verified_result": null
534
+ }
535
+ ],
536
+ "test/unit/iam-assume-token-manager.test.js": [
537
+ {
538
+ "hashed_secret": "a0da30f332dd7b7a26d1c0b4da5437fcd90bf49b",
539
+ "is_secret": false,
540
+ "is_verified": false,
541
+ "line_number": 33,
542
+ "type": "Secret Keyword",
543
+ "verified_result": null
544
+ },
545
+ {
546
+ "hashed_secret": "9cea46b39bd44a1ef9f3e71bfe9e45c24d3300f6",
547
+ "is_secret": false,
548
+ "is_verified": false,
549
+ "line_number": 150,
550
+ "type": "Secret Keyword",
551
+ "verified_result": null
552
+ },
553
+ {
554
+ "hashed_secret": "43ed4c2d8375dfc89e3dc8c917f404b9481d355b",
555
+ "is_secret": false,
556
+ "is_verified": false,
557
+ "line_number": 404,
558
+ "type": "Secret Keyword",
559
+ "verified_result": null
560
+ }
561
+ ],
458
562
  "test/unit/iam-authenticator.test.js": [
459
563
  {
460
564
  "hashed_secret": "257368587362aab7f1180b4a5fe550ec26053e05",
@@ -582,7 +686,7 @@
582
686
  }
583
687
  ]
584
688
  },
585
- "version": "0.13.1+ibm.62.dss",
689
+ "version": "0.13.1+ibm.56.dss",
586
690
  "word_list": {
587
691
  "file": null,
588
692
  "hash": null
package/Authentication.md CHANGED
@@ -2,7 +2,8 @@
2
2
  The node-sdk-core project supports the following types of authentication:
3
3
  - Basic Authentication
4
4
  - Bearer Token Authentication
5
- - Identity and Access Management (IAM) Authentication
5
+ - Identity and Access Management (IAM) Authentication (grant type: apikey)
6
+ - Identity and Access Management (IAM) Authentication (grant type: assume)
6
7
  - Container Authentication
7
8
  - VPC Instance Authentication
8
9
  - Cloud Pak for Data Authentication
@@ -16,7 +17,7 @@ which authentication types are supported for that service.
16
17
 
17
18
  The node-sdk-core allows an authenticator to be specified in one of two ways:
18
19
  1. programmatically - the SDK user invokes the appropriate function(s) to create an instance of the
19
- desired authenticator and then passes the authenticator instance when constructing an instance of the service.
20
+ desired authenticator and then passes the authenticator instance when constructing an instance of the service client.
20
21
  2. configuration - the SDK user provides external configuration information (in the form of environment variables
21
22
  or a credentials file) to indicate the type of authenticator, along with the configuration of the necessary properties
22
23
  for that authenticator. The SDK user then invokes the configuration-based authenticator factory to construct an instance
@@ -28,7 +29,7 @@ which will include the following:
28
29
  - The properties associated with the authenticator
29
30
  - An example of how to construct the authenticator programmatically
30
31
  - An example of how to configure the authenticator through the use of external
31
- configuration information. The configuration examples below will use
32
+ configuration information. The configuration examples below will use
32
33
  environment variables, although the same properties could be specified in a
33
34
  credentials file instead.
34
35
 
@@ -143,16 +144,16 @@ const service = ExampleServiceV1.newInstance(options);
143
144
 
144
145
  Note that the use of external configuration is not as useful with the `BearerTokenAuthenticator` as it
145
146
  is for other authenticator types because bearer tokens typically need to be obtained and refreshed
146
- programmatically since they normally have a relatively short lifespan before they expire. This
147
+ programmatically since they normally have a relatively short lifespan before they expire. This
147
148
  authenticator type is intended for situations in which the application will be managing the bearer
148
149
  token itself in terms of initial acquisition and refreshing as needed.
149
150
 
150
151
 
151
- ## Identity and Access Management (IAM) Authentication
152
- The `IamAuthenticator` will accept a user-supplied api key and will perform
152
+ ## Identity and Access Management (IAM) Authentication (grant type: apikey)
153
+ The `IamAuthenticator` will accept a user-supplied apikey and will perform
153
154
  the necessary interactions with the IAM token service to obtain a suitable
154
- bearer token for the specified api key. The authenticator will also obtain
155
- a new bearer token when the current token expires. The bearer token is
155
+ bearer token for the specified apikey. The authenticator will also obtain
156
+ a new bearer token when the current token expires. The bearer token is
156
157
  then added to each outbound request in the `Authorization` header in the
157
158
  form:
158
159
  ```
@@ -161,7 +162,7 @@ form:
161
162
 
162
163
  ### Properties
163
164
 
164
- - apikey: (required) the IAM api key
165
+ - apikey: (required) the IAM apikey to be used to obtain an IAM access token.
165
166
 
166
167
  - url: (optional) The base endpoint URL of the IAM token service.
167
168
  The default value of this property is the "prod" IAM token service endpoint
@@ -178,13 +179,13 @@ endpoint as well (`https://iam.test.cloud.ibm.com`).
178
179
 
179
180
  - clientId/clientSecret: (optional) The `clientId` and `clientSecret` fields are used to form a
180
181
  "basic auth" Authorization header for interactions with the IAM token server. If neither field
181
- is specified, then no Authorization header will be sent with token server requests. These fields
182
+ is specified, then no Authorization header will be sent with token server requests. These fields
182
183
  are optional, but must be specified together.
183
184
 
184
185
  - scope: (optional) the scope to be associated with the IAM access token.
185
186
  If not specified, then no scope wil be associated with the access token.
186
187
 
187
- - disableSslVerification: (optional) A flag that indicates whether verificaton of the server's SSL
188
+ - disableSslVerification: (optional) A flag that indicates whether verification of the server's SSL
188
189
  certificate should be disabled or not. The default value is `false`.
189
190
 
190
191
  - headers: (optional) A set of key/value pairs that will be sent as HTTP headers in requests
@@ -228,6 +229,130 @@ const service = ExampleServiceV1.newInstance(options);
228
229
  ```
229
230
 
230
231
 
232
+ ## Identity and Access Management (IAM) Authentication (grant type: assume)
233
+ The `IamAssumeAuthenticator` performs a two-step token fetch sequence to obtain
234
+ a bearer token that allows the application to assume the identity of a trusted profile:
235
+ 1. First, the authenticator obtains an initial bearer token using grant type
236
+ `urn:ibm:params:oauth:grant-type:apikey`.
237
+ This initial token will reflect the identity associated with the input apikey.
238
+ 2. Second, the authenticator uses the grant type `urn:ibm:params:oauth:grant-type:assume` to obtain a bearer token
239
+ that reflects the identity of the trusted profile, passing in the initial bearer token
240
+ from the first step, along with the trusted profile-related inputs.
241
+
242
+ The authenticator will also obtain a new bearer token when the current token expires.
243
+ The bearer token is then added to each outbound request in the `Authorization` header in the
244
+ form:
245
+ ```
246
+ Authorization: Bearer <bearer-token>
247
+ ```
248
+
249
+ ### Properties
250
+
251
+ - apikey: (required) the IAM apikey to be used to obtain the initial IAM access token.
252
+
253
+ - iamProfileCrn: (optional) the Cloud Resource Name (CRN) associated with the trusted profile
254
+ for which an access token should be fetched.
255
+ Exactly one of iamProfileCrn, iamProfileId or iamProfileName must be specified.
256
+
257
+ - iamProfileId: (optional) the ID associated with the trusted profile
258
+ for which an access token should be fetched.
259
+ Exactly one of iamProfileCrn, iamProfileId or iamProfileName must be specified.
260
+
261
+ - iamProfileName: (optional) the name associated with the trusted profile
262
+ for which an access token should be fetched. When specifying this property, you must also
263
+ specify the iamAccountId property as well.
264
+ Exactly one of iamProfileCrn, iamProfileId or iamProfileName must be specified.
265
+
266
+ - iamAccountId: (optional) the ID associated with the IAM account that contains the trusted profile
267
+ referenced by the iamProfileName property. The imaAccountId property must be specified if and only if
268
+ the iamProfileName property is specified.
269
+
270
+ - url: (optional) The base endpoint URL of the IAM token service.
271
+ The default value of this property is the "prod" IAM token service endpoint
272
+ (`https://iam.cloud.ibm.com`).
273
+ Make sure that you use an IAM token service endpoint that is appropriate for the
274
+ location of the service being used by your application.
275
+ For example, if you are using an instance of a service in the "production" environment
276
+ (e.g. `https://resource-controller.cloud.ibm.com`),
277
+ then the default "prod" IAM token service endpoint should suffice.
278
+ However, if your application is using an instance of a service in the "staging" environment
279
+ (e.g. `https://resource-controller.test.cloud.ibm.com`),
280
+ then you would also need to configure the authenticator to use the IAM token service "staging"
281
+ endpoint as well (`https://iam.test.cloud.ibm.com`).
282
+
283
+ - clientId/clientSecret: (optional) The `clientId` and `clientSecret` fields are used to form a
284
+ "basic auth" Authorization header for interactions with the IAM token server when fetching the
285
+ initial IAM access token. These fields are optional, but must be specified together.
286
+
287
+ - scope: (optional) the scope to be used when obtaining the initial IAM access token.
288
+ If not specified, then no scope will be associated with the access token.
289
+
290
+ - disableSslVerification: (optional) A flag that indicates whether verification of the server's SSL
291
+ certificate should be disabled or not. The default value is `false`.
292
+
293
+ - headers: (optional) A set of key/value pairs that will be sent as HTTP headers in requests
294
+ made to the IAM token service.
295
+
296
+ ### Usage Notes
297
+ - The IamAssumeAuthenticator is used to obtain an access token (a bearer token) from the IAM token service
298
+ that allows an application to "assume" the identity of a trusted profile.
299
+
300
+ - The authenticator first uses the apikey, url, clientId/clientSecret, scope, disableSslVerification, and headers
301
+ properties to obtain an initial access token by invoking the IAM `getToken`
302
+ (grant_type=`urn:ibm:params:oauth:grant-type:apikey`) operation.
303
+
304
+ - The authenticator then uses the initial access token along with the url, iamProfileCrn, iamProfileId,
305
+ iamProfileName, iamAccountId, disableSSLVerification, and headers properties to obtain an access token by invoking
306
+ the IAM `getToken` (grant_type=`urn:ibm:params:oauth:grant-type:assume`) operation.
307
+ The access token resulting from this second step will reflect the identity of the specified trusted profile.
308
+
309
+ - When providing the trusted profile information, you must specify exactly one of: iamProfileCrn, iamProfileId
310
+ or iamProfileName. If you specify iamProfileCrn or iamProfileId, then the trusted profile must exist in the same account that is
311
+ associated with the input apikey. If you specify iamProfileName, then you must also specify the iamAccountId property
312
+ to indicate the IAM account in which the named trusted profile can be found.
313
+
314
+ ### Programming example
315
+ ```js
316
+ const { IamAssumeAuthenticator } = require('ibm-cloud-sdk-core');
317
+ const ExampleServiceV1 = require('<sdk-package-name>/example-service/v1');
318
+
319
+ // Create the authenticator.
320
+ const authenticator = new IamAssumeAuthenticator({
321
+ apikey: 'myapikey',
322
+ iamProfileId: 'myprofile-1',
323
+ });
324
+
325
+ const options = {
326
+ authenticator,
327
+ };
328
+
329
+ // Create the service instance.
330
+ const service = new ExampleServiceV1(options);
331
+
332
+ // 'service' can now be used to invoke operations.
333
+ ```
334
+
335
+ ### Configuration example
336
+ External configuration:
337
+ ```
338
+ export EXAMPLE_SERVICE_AUTH_TYPE=iamAssume
339
+ export EXAMPLE_SERVICE_APIKEY=myapikey
340
+ export EXAMPLE_SERVICE_IAM_PROFILE_ID=myprofile-1
341
+ ```
342
+ Application code:
343
+ ```js
344
+ const ExampleServiceV1 = require('<sdk-package-name>/example-service/v1');
345
+
346
+ const options = {
347
+ serviceName: 'example_service',
348
+ };
349
+
350
+ const service = ExampleServiceV1.newInstance(options);
351
+
352
+ // 'service' can now be used to invoke operations.
353
+ ```
354
+
355
+
231
356
  ## Container Authentication
232
357
  The `ContainerAuthenticator` is intended to be used by application code
233
358
  running inside a compute resource managed by the IBM Kubernetes Service (IKS)
@@ -236,7 +361,7 @@ within the compute resource's local file system.
236
361
  The CR token is similar to an IAM apikey except that it is managed automatically by
237
362
  the compute resource provider (IKS).
238
363
  This allows the application developer to:
239
- - avoid storing credentials in application code, configuraton files or a password vault
364
+ - avoid storing credentials in application code, configuration files or a password vault
240
365
  - avoid managing or rotating credentials
241
366
 
242
367
  The `ContainerAuthenticator` will retrieve the CR token from
@@ -280,13 +405,13 @@ endpoint as well (`https://iam.test.cloud.ibm.com`).
280
405
 
281
406
  - clientId/clientSecret: (optional) The `clientId` and `clientSecret` fields are used to form a
282
407
  "basic auth" Authorization header for interactions with the IAM token service. If neither field
283
- is specified, then no Authorization header will be sent with token server requests. These fields
408
+ is specified, then no Authorization header will be sent with token server requests. These fields
284
409
  are optional, but must be specified together.
285
410
 
286
411
  - scope: (optional) the scope to be associated with the IAM access token.
287
412
  If not specified, then no scope will be associated with the access token.
288
413
 
289
- - disableSslVerification: (optional) A flag that indicates whether verificaton of the server's SSL
414
+ - disableSslVerification: (optional) A flag that indicates whether verification of the server's SSL
290
415
  certificate should be disabled or not. The default value is `false`.
291
416
 
292
417
  - headers: (optional) A set of key/value pairs that will be sent as HTTP headers in requests
@@ -342,7 +467,7 @@ The compute resource identity feature allows you to assign a trusted IAM profile
342
467
  This, in turn, allows applications running within the compute resource to take on this identity when interacting with
343
468
  IAM-secured IBM Cloud services.
344
469
  This results in a simplified security model that allows the application developer to:
345
- - avoid storing credentials in application code, configuraton files or a password vault
470
+ - avoid storing credentials in application code, configuration files or a password vault
346
471
  - avoid managing or rotating credentials
347
472
 
348
473
  The `VpcInstanceAuthenticator` will invoke the appropriate operations on the compute resource's locally-available
@@ -361,11 +486,11 @@ The IAM access token is added to each outbound request in the `Authorization` he
361
486
  - iamProfileId: (optional) the id of the linked trusted IAM profile to be used when obtaining the IAM access token.
362
487
 
363
488
  - url: (optional) The VPC Instance Metadata Service's base URL.
364
- The default value of this property is `http://169.254.169.254`. However, if the VPC Instance Metadata Service is configured
489
+ The default value of this property is `http://169.254.169.254`. However, if the VPC Instance Metadata Service is configured
365
490
  with the HTTP Secure Protocol setting (`https`), then you should configure this property to be `https://api.metadata.cloud.ibm.com`.
366
491
 
367
492
  Usage Notes:
368
- 1. At most one of `iamProfileCrn` or `iamProfileId` may be specified. The specified value must map
493
+ 1. At most one of `iamProfileCrn` or `iamProfileId` may be specified. The specified value must map
369
494
  to a trusted IAM profile that has been linked to the compute resource (virtual server instance).
370
495
 
371
496
  2. If both `iamProfileCrn` and `iamProfileId` are specified, then an error occurs.
@@ -413,11 +538,11 @@ const service = ExampleServiceV1.newInstance(options);
413
538
  ```
414
539
 
415
540
 
416
- ## Cloud Pak for Data Authentication
541
+ ## Cloud Pak for Data Authentication
417
542
  The `CloudPakForDataAuthenticator` will accept a user-supplied username value, along with either a
418
543
  password or apikey, and will
419
544
  perform the necessary interactions with the Cloud Pak for Data token service to obtain a suitable
420
- bearer token. The authenticator will also obtain a new bearer token when the current token expires.
545
+ bearer token. The authenticator will also obtain a new bearer token when the current token expires.
421
546
  The bearer token is then added to each outbound request in the `Authorization` header in the
422
547
  form:
423
548
  ```
@@ -436,7 +561,7 @@ Exactly one of password or apikey should be specified.
436
561
  - url: (required) The URL representing the Cloud Pak for Data token service endpoint's base URL string.
437
562
  This value should not include the `/v1/authorize` path portion.
438
563
 
439
- - disableSslVerification: (optional) A flag that indicates whether verificaton of the server's SSL
564
+ - disableSslVerification: (optional) A flag that indicates whether verification of the server's SSL
440
565
  certificate should be disabled or not. The default value is `false`.
441
566
 
442
567
  - headers: (optional) A set of key/value pairs that will be sent as HTTP headers in requests
@@ -505,7 +630,7 @@ form:
505
630
  - url: (required) The URL representing the MCSP token service endpoint's base URL string. Do not include the
506
631
  operation path (e.g. `/siusermgr/api/1.0/apikeys/token`) as part of this property's value.
507
632
 
508
- - disableSSLVerification: (optional) A flag that indicates whether verificaton of the server's SSL
633
+ - disableSSLVerification: (optional) A flag that indicates whether verification of the server's SSL
509
634
  certificate should be disabled or not. The default value is `false`.
510
635
 
511
636
  - headers: (optional) A set of key/value pairs that will be sent as HTTP headers in requests
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [5.1.0](https://github.com/IBM/node-sdk-core/compare/v5.0.2...v5.1.0) (2024-10-15)
2
+
3
+
4
+ ### Features
5
+
6
+ * **IamAssumeAuthenticator:** add new authentication type for iam assume ([#287](https://github.com/IBM/node-sdk-core/issues/287)) ([addebfc](https://github.com/IBM/node-sdk-core/commit/addebfca36f0b45a1e4df18605984a66073413bb))
7
+
1
8
  ## [5.0.2](https://github.com/IBM/node-sdk-core/compare/v5.0.1...v5.0.2) (2024-09-03)
2
9
 
3
10
 
package/README.md CHANGED
@@ -30,7 +30,8 @@ class YourSDK extends BaseService { ... }
30
30
  The node-sdk-core project supports the following types of authentication:
31
31
  - Basic Authentication
32
32
  - Bearer Token Authentication
33
- - Identity and Access Management (IAM) Authentication
33
+ - Identity and Access Management (IAM) Authentication (grant type: apikey)
34
+ - Identity and Access Management (IAM) Authentication (grant type: assume)
34
35
  - Container Authentication
35
36
  - VPC Instance Authentication
36
37
  - Cloud Pak for Data Authentication
@@ -79,7 +80,7 @@ To see the output from all of the debugging levels you can use:
79
80
 
80
81
  ``DEBUG=ibm-cloud-sdk-core*``
81
82
 
82
- The debug logger can be configured to be used for more than one library. In example, you can set a comma-separated string:
83
+ The debug logger can be configured to be used for more than one library. For example, you can set a comma-separated string:
83
84
 
84
85
  ``DEBUG=ibm-cloud-sdk-core:debug,other-lib:debug``
85
86
 
@@ -25,6 +25,7 @@ export declare class Authenticator implements AuthenticatorInterface {
25
25
  static AUTHTYPE_BASIC: string;
26
26
  static AUTHTYPE_BEARERTOKEN: string;
27
27
  static AUTHTYPE_IAM: string;
28
+ static AUTHTYPE_IAM_ASSUME: string;
28
29
  static AUTHTYPE_CONTAINER: string;
29
30
  static AUTHTYPE_CP4D: string;
30
31
  static AUTHTYPE_NOAUTH: string;
@@ -47,6 +47,7 @@ var Authenticator = /** @class */ (function () {
47
47
  Authenticator.AUTHTYPE_BASIC = 'basic';
48
48
  Authenticator.AUTHTYPE_BEARERTOKEN = 'bearerToken';
49
49
  Authenticator.AUTHTYPE_IAM = 'iam';
50
+ Authenticator.AUTHTYPE_IAM_ASSUME = 'iamAssume';
50
51
  Authenticator.AUTHTYPE_CONTAINER = 'container';
51
52
  Authenticator.AUTHTYPE_CP4D = 'cp4d';
52
53
  Authenticator.AUTHTYPE_NOAUTH = 'noAuth';
@@ -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;