ibm-cloud-sdk-core 5.0.2 → 5.1.1

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 (299) hide show
  1. package/.secrets.baseline +118 -14
  2. package/Authentication.md +146 -21
  3. package/CHANGELOG.md +14 -0
  4. package/README.md +4 -3
  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/build/docs/ibm-cloud-sdk-core.atleastone.md +55 -0
  37. package/build/docs/ibm-cloud-sdk-core.atmostone.md +55 -0
  38. package/build/docs/ibm-cloud-sdk-core.authenticator._constructor_.md +18 -0
  39. package/build/docs/ibm-cloud-sdk-core.authenticator.authenticate.md +57 -0
  40. package/build/docs/ibm-cloud-sdk-core.authenticator.authenticationtype.md +19 -0
  41. package/build/docs/ibm-cloud-sdk-core.authenticator.authtype_basic.md +13 -0
  42. package/build/docs/ibm-cloud-sdk-core.authenticator.authtype_bearertoken.md +11 -0
  43. package/build/docs/ibm-cloud-sdk-core.authenticator.authtype_container.md +11 -0
  44. package/build/docs/ibm-cloud-sdk-core.authenticator.authtype_cp4d.md +11 -0
  45. package/build/docs/ibm-cloud-sdk-core.authenticator.authtype_iam.md +11 -0
  46. package/build/docs/ibm-cloud-sdk-core.authenticator.authtype_iam_assume.md +11 -0
  47. package/build/docs/ibm-cloud-sdk-core.authenticator.authtype_mcsp.md +11 -0
  48. package/build/docs/ibm-cloud-sdk-core.authenticator.authtype_noauth.md +11 -0
  49. package/build/docs/ibm-cloud-sdk-core.authenticator.authtype_unknown.md +11 -0
  50. package/build/docs/ibm-cloud-sdk-core.authenticator.authtype_vpc.md +11 -0
  51. package/build/docs/ibm-cloud-sdk-core.authenticator.md +313 -0
  52. package/build/docs/ibm-cloud-sdk-core.authenticatorinterface.authenticate.md +53 -0
  53. package/build/docs/ibm-cloud-sdk-core.authenticatorinterface.authenticationtype.md +17 -0
  54. package/build/docs/ibm-cloud-sdk-core.authenticatorinterface.md +50 -0
  55. package/build/docs/ibm-cloud-sdk-core.baseservice._constructor_.md +49 -0
  56. package/build/docs/ibm-cloud-sdk-core.baseservice.baseoptions.md +11 -0
  57. package/build/docs/ibm-cloud-sdk-core.baseservice.configureservice.md +53 -0
  58. package/build/docs/ibm-cloud-sdk-core.baseservice.convertmodel.md +85 -0
  59. package/build/docs/ibm-cloud-sdk-core.baseservice.createrequest.md +55 -0
  60. package/build/docs/ibm-cloud-sdk-core.baseservice.createrequestanddeserializeresponse.md +87 -0
  61. package/build/docs/ibm-cloud-sdk-core.baseservice.default_service_name.md +11 -0
  62. package/build/docs/ibm-cloud-sdk-core.baseservice.default_service_url.md +11 -0
  63. package/build/docs/ibm-cloud-sdk-core.baseservice.disableretries.md +17 -0
  64. package/build/docs/ibm-cloud-sdk-core.baseservice.enableretries.md +53 -0
  65. package/build/docs/ibm-cloud-sdk-core.baseservice.getauthenticator.md +19 -0
  66. package/build/docs/ibm-cloud-sdk-core.baseservice.gethttpclient.md +17 -0
  67. package/build/docs/ibm-cloud-sdk-core.baseservice.md +313 -0
  68. package/build/docs/ibm-cloud-sdk-core.baseservice.setdefaultheaders.md +53 -0
  69. package/build/docs/ibm-cloud-sdk-core.baseservice.setenablegzipcompression.md +53 -0
  70. package/build/docs/ibm-cloud-sdk-core.baseservice.setserviceurl.md +53 -0
  71. package/build/docs/ibm-cloud-sdk-core.basicauthenticator._constructor_.md +54 -0
  72. package/build/docs/ibm-cloud-sdk-core.basicauthenticator.authenticate.md +55 -0
  73. package/build/docs/ibm-cloud-sdk-core.basicauthenticator.authenticationtype.md +19 -0
  74. package/build/docs/ibm-cloud-sdk-core.basicauthenticator.authheader.md +13 -0
  75. package/build/docs/ibm-cloud-sdk-core.basicauthenticator.md +165 -0
  76. package/build/docs/ibm-cloud-sdk-core.basicauthenticator.requiredoptions.md +11 -0
  77. package/build/docs/ibm-cloud-sdk-core.bearertokenauthenticator._constructor_.md +54 -0
  78. package/build/docs/ibm-cloud-sdk-core.bearertokenauthenticator.authenticate.md +55 -0
  79. package/build/docs/ibm-cloud-sdk-core.bearertokenauthenticator.authenticationtype.md +19 -0
  80. package/build/docs/ibm-cloud-sdk-core.bearertokenauthenticator.md +160 -0
  81. package/build/docs/ibm-cloud-sdk-core.bearertokenauthenticator.requiredoptions.md +11 -0
  82. package/build/docs/ibm-cloud-sdk-core.bearertokenauthenticator.setbearertoken.md +53 -0
  83. package/build/docs/ibm-cloud-sdk-core.buildrequestfileobject.md +55 -0
  84. package/build/docs/ibm-cloud-sdk-core.checkcredentials.md +71 -0
  85. package/build/docs/ibm-cloud-sdk-core.cloudpakfordataauthenticator._constructor_.md +54 -0
  86. package/build/docs/ibm-cloud-sdk-core.cloudpakfordataauthenticator.authenticationtype.md +19 -0
  87. package/build/docs/ibm-cloud-sdk-core.cloudpakfordataauthenticator.md +149 -0
  88. package/build/docs/ibm-cloud-sdk-core.cloudpakfordataauthenticator.requiredoptions.md +11 -0
  89. package/build/docs/ibm-cloud-sdk-core.cloudpakfordataauthenticator.tokenmanager.md +11 -0
  90. package/build/docs/ibm-cloud-sdk-core.computebasicauthheader.md +71 -0
  91. package/build/docs/ibm-cloud-sdk-core.constructfilepath.md +49 -0
  92. package/build/docs/ibm-cloud-sdk-core.constructserviceurl.md +87 -0
  93. package/build/docs/ibm-cloud-sdk-core.containerauthenticator._constructor_.md +54 -0
  94. package/build/docs/ibm-cloud-sdk-core.containerauthenticator.authenticationtype.md +19 -0
  95. package/build/docs/ibm-cloud-sdk-core.containerauthenticator.getrefreshtoken.md +19 -0
  96. package/build/docs/ibm-cloud-sdk-core.containerauthenticator.md +186 -0
  97. package/build/docs/ibm-cloud-sdk-core.containerauthenticator.setcrtokenfilename.md +53 -0
  98. package/build/docs/ibm-cloud-sdk-core.containerauthenticator.setiamprofileid.md +53 -0
  99. package/build/docs/ibm-cloud-sdk-core.containerauthenticator.setiamprofilename.md +53 -0
  100. package/build/docs/ibm-cloud-sdk-core.containerauthenticator.tokenmanager.md +11 -0
  101. package/build/docs/ibm-cloud-sdk-core.containertokenmanager._constructor_.md +54 -0
  102. package/build/docs/ibm-cloud-sdk-core.containertokenmanager.getcrtoken.md +19 -0
  103. package/build/docs/ibm-cloud-sdk-core.containertokenmanager.getrefreshtoken.md +19 -0
  104. package/build/docs/ibm-cloud-sdk-core.containertokenmanager.md +156 -0
  105. package/build/docs/ibm-cloud-sdk-core.containertokenmanager.requesttoken.md +17 -0
  106. package/build/docs/ibm-cloud-sdk-core.containertokenmanager.setcrtokenfilename.md +53 -0
  107. package/build/docs/ibm-cloud-sdk-core.containertokenmanager.setiamprofileid.md +53 -0
  108. package/build/docs/ibm-cloud-sdk-core.containertokenmanager.setiamprofilename.md +53 -0
  109. package/build/docs/ibm-cloud-sdk-core.contenttype.md +14 -0
  110. package/build/docs/ibm-cloud-sdk-core.cp4dtokenmanager._constructor_.md +54 -0
  111. package/build/docs/ibm-cloud-sdk-core.cp4dtokenmanager.md +128 -0
  112. package/build/docs/ibm-cloud-sdk-core.cp4dtokenmanager.requesttoken.md +15 -0
  113. package/build/docs/ibm-cloud-sdk-core.cp4dtokenmanager.requiredoptions.md +11 -0
  114. package/build/docs/ibm-cloud-sdk-core.fileexistsatpath.md +49 -0
  115. package/build/docs/ibm-cloud-sdk-core.fileobject.md +80 -0
  116. package/build/docs/ibm-cloud-sdk-core.fileobject.options.md +11 -0
  117. package/build/docs/ibm-cloud-sdk-core.fileobject.value.md +11 -0
  118. package/build/docs/ibm-cloud-sdk-core.fileoptions.contenttype.md +11 -0
  119. package/build/docs/ibm-cloud-sdk-core.fileoptions.filename.md +11 -0
  120. package/build/docs/ibm-cloud-sdk-core.fileoptions.md +74 -0
  121. package/build/docs/ibm-cloud-sdk-core.filestream.md +54 -0
  122. package/build/docs/ibm-cloud-sdk-core.filestream.path.md +11 -0
  123. package/build/docs/ibm-cloud-sdk-core.filewithmetadata.contenttype.md +11 -0
  124. package/build/docs/ibm-cloud-sdk-core.filewithmetadata.data.md +11 -0
  125. package/build/docs/ibm-cloud-sdk-core.filewithmetadata.filename.md +11 -0
  126. package/build/docs/ibm-cloud-sdk-core.filewithmetadata.md +87 -0
  127. package/build/docs/ibm-cloud-sdk-core.getauthenticatorfromenvironment.md +55 -0
  128. package/build/docs/ibm-cloud-sdk-core.getcontenttype.md +55 -0
  129. package/build/docs/ibm-cloud-sdk-core.getcurrenttime.md +19 -0
  130. package/build/docs/ibm-cloud-sdk-core.getformat.md +69 -0
  131. package/build/docs/ibm-cloud-sdk-core.getmissingparams.md +73 -0
  132. package/build/docs/ibm-cloud-sdk-core.getnewlogger.md +59 -0
  133. package/build/docs/ibm-cloud-sdk-core.getqueryparam.md +71 -0
  134. package/build/docs/ibm-cloud-sdk-core.iamassumeauthenticator._constructor_.md +54 -0
  135. package/build/docs/ibm-cloud-sdk-core.iamassumeauthenticator.authenticationtype.md +19 -0
  136. package/build/docs/ibm-cloud-sdk-core.iamassumeauthenticator.md +130 -0
  137. package/build/docs/ibm-cloud-sdk-core.iamassumeauthenticator.tokenmanager.md +11 -0
  138. package/build/docs/ibm-cloud-sdk-core.iamassumetokenmanager._constructor_.md +54 -0
  139. package/build/docs/ibm-cloud-sdk-core.iamassumetokenmanager.md +200 -0
  140. package/build/docs/ibm-cloud-sdk-core.iamassumetokenmanager.requesttoken.md +17 -0
  141. package/build/docs/ibm-cloud-sdk-core.iamassumetokenmanager.requiredoptions.md +11 -0
  142. package/build/docs/ibm-cloud-sdk-core.iamassumetokenmanager.savetokeninfo.md +53 -0
  143. package/build/docs/ibm-cloud-sdk-core.iamassumetokenmanager.setclientidandsecret.md +69 -0
  144. package/build/docs/ibm-cloud-sdk-core.iamassumetokenmanager.setdisablesslverification.md +53 -0
  145. package/build/docs/ibm-cloud-sdk-core.iamassumetokenmanager.setheaders.md +53 -0
  146. package/build/docs/ibm-cloud-sdk-core.iamassumetokenmanager.setscope.md +53 -0
  147. package/build/docs/ibm-cloud-sdk-core.iamauthenticator._constructor_.md +54 -0
  148. package/build/docs/ibm-cloud-sdk-core.iamauthenticator.authenticationtype.md +19 -0
  149. package/build/docs/ibm-cloud-sdk-core.iamauthenticator.getrefreshtoken.md +19 -0
  150. package/build/docs/ibm-cloud-sdk-core.iamauthenticator.md +163 -0
  151. package/build/docs/ibm-cloud-sdk-core.iamauthenticator.requiredoptions.md +11 -0
  152. package/build/docs/ibm-cloud-sdk-core.iamauthenticator.tokenmanager.md +11 -0
  153. package/build/docs/ibm-cloud-sdk-core.iamrequestbasedauthenticator.md +90 -0
  154. package/build/docs/ibm-cloud-sdk-core.iamrequestbasedauthenticator.setclientidandsecret.md +69 -0
  155. package/build/docs/ibm-cloud-sdk-core.iamrequestbasedauthenticator.setdisablesslverification.md +53 -0
  156. package/build/docs/ibm-cloud-sdk-core.iamrequestbasedauthenticator.setheaders.md +53 -0
  157. package/build/docs/ibm-cloud-sdk-core.iamrequestbasedauthenticator.setscope.md +53 -0
  158. package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager._constructor_.md +54 -0
  159. package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager.clientid.md +11 -0
  160. package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager.clientsecret.md +11 -0
  161. package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager.formdata.md +11 -0
  162. package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager.istokenexpired.md +19 -0
  163. package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager.md +264 -0
  164. package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager.refreshtoken.md +11 -0
  165. package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager.requesttoken.md +19 -0
  166. package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager.savetokeninfo.md +53 -0
  167. package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager.scope.md +11 -0
  168. package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager.setclientidandsecret.md +69 -0
  169. package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager.setscope.md +53 -0
  170. package/build/docs/ibm-cloud-sdk-core.iamrequestoptions.clientid.md +11 -0
  171. package/build/docs/ibm-cloud-sdk-core.iamrequestoptions.clientsecret.md +11 -0
  172. package/build/docs/ibm-cloud-sdk-core.iamrequestoptions.md +96 -0
  173. package/build/docs/ibm-cloud-sdk-core.iamrequestoptions.scope.md +11 -0
  174. package/build/docs/ibm-cloud-sdk-core.iamtokenmanager._constructor_.md +54 -0
  175. package/build/docs/ibm-cloud-sdk-core.iamtokenmanager.getrefreshtoken.md +19 -0
  176. package/build/docs/ibm-cloud-sdk-core.iamtokenmanager.md +126 -0
  177. package/build/docs/ibm-cloud-sdk-core.iamtokenmanager.requiredoptions.md +11 -0
  178. package/build/docs/ibm-cloud-sdk-core.isemptyobject.md +49 -0
  179. package/build/docs/ibm-cloud-sdk-core.isfiledata.md +49 -0
  180. package/build/docs/ibm-cloud-sdk-core.isfilewithmetadata.md +49 -0
  181. package/build/docs/ibm-cloud-sdk-core.ishtml.md +55 -0
  182. package/build/docs/ibm-cloud-sdk-core.isjsonmimetype.md +55 -0
  183. package/build/docs/ibm-cloud-sdk-core.jwttokenmanager._constructor_.md +49 -0
  184. package/build/docs/ibm-cloud-sdk-core.jwttokenmanager.md +163 -0
  185. package/build/docs/ibm-cloud-sdk-core.jwttokenmanager.requesttoken.md +19 -0
  186. package/build/docs/ibm-cloud-sdk-core.jwttokenmanager.savetokeninfo.md +53 -0
  187. package/build/docs/ibm-cloud-sdk-core.jwttokenmanager.tokeninfo.md +11 -0
  188. package/build/docs/ibm-cloud-sdk-core.jwttokenmanager.tokenname.md +11 -0
  189. package/build/docs/ibm-cloud-sdk-core.jwttokenmanageroptions.md +15 -0
  190. package/build/docs/ibm-cloud-sdk-core.mcspauthenticator._constructor_.md +54 -0
  191. package/build/docs/ibm-cloud-sdk-core.mcspauthenticator.authenticationtype.md +19 -0
  192. package/build/docs/ibm-cloud-sdk-core.mcspauthenticator.md +145 -0
  193. package/build/docs/ibm-cloud-sdk-core.mcspauthenticator.requiredoptions.md +11 -0
  194. package/build/docs/ibm-cloud-sdk-core.mcspauthenticator.tokenmanager.md +11 -0
  195. package/build/docs/ibm-cloud-sdk-core.mcsptokenmanager._constructor_.md +54 -0
  196. package/build/docs/ibm-cloud-sdk-core.mcsptokenmanager.md +128 -0
  197. package/build/docs/ibm-cloud-sdk-core.mcsptokenmanager.requesttoken.md +15 -0
  198. package/build/docs/ibm-cloud-sdk-core.mcsptokenmanager.requiredoptions.md +11 -0
  199. package/build/docs/ibm-cloud-sdk-core.md +820 -0
  200. package/build/docs/ibm-cloud-sdk-core.noauthauthenticator.authenticate.md +49 -0
  201. package/build/docs/ibm-cloud-sdk-core.noauthauthenticator.authenticationtype.md +19 -0
  202. package/build/docs/ibm-cloud-sdk-core.noauthauthenticator.md +60 -0
  203. package/build/docs/ibm-cloud-sdk-core.onlyone.md +55 -0
  204. package/build/docs/ibm-cloud-sdk-core.qs.md +21 -0
  205. package/build/docs/ibm-cloud-sdk-core.readcredentialsfile.md +17 -0
  206. package/build/docs/ibm-cloud-sdk-core.readcrtokenfile.md +49 -0
  207. package/build/docs/ibm-cloud-sdk-core.readexternalsources.md +55 -0
  208. package/build/docs/ibm-cloud-sdk-core.removesuffix.md +71 -0
  209. package/build/docs/ibm-cloud-sdk-core.sdklogger.debug.md +11 -0
  210. package/build/docs/ibm-cloud-sdk-core.sdklogger.error.md +11 -0
  211. package/build/docs/ibm-cloud-sdk-core.sdklogger.info.md +11 -0
  212. package/build/docs/ibm-cloud-sdk-core.sdklogger.md +121 -0
  213. package/build/docs/ibm-cloud-sdk-core.sdklogger.verbose.md +11 -0
  214. package/build/docs/ibm-cloud-sdk-core.sdklogger.warn.md +11 -0
  215. package/build/docs/ibm-cloud-sdk-core.streamtopromise.md +55 -0
  216. package/build/docs/ibm-cloud-sdk-core.striptrailingslash.md +55 -0
  217. package/build/docs/ibm-cloud-sdk-core.tokenmanager._constructor_.md +49 -0
  218. package/build/docs/ibm-cloud-sdk-core.tokenmanager.accesstoken.md +11 -0
  219. package/build/docs/ibm-cloud-sdk-core.tokenmanager.disablesslverification.md +11 -0
  220. package/build/docs/ibm-cloud-sdk-core.tokenmanager.expiretime.md +11 -0
  221. package/build/docs/ibm-cloud-sdk-core.tokenmanager.gettoken.md +17 -0
  222. package/build/docs/ibm-cloud-sdk-core.tokenmanager.headers.md +11 -0
  223. package/build/docs/ibm-cloud-sdk-core.tokenmanager.istokenexpired.md +17 -0
  224. package/build/docs/ibm-cloud-sdk-core.tokenmanager.md +352 -0
  225. package/build/docs/ibm-cloud-sdk-core.tokenmanager.pacedrequesttoken.md +19 -0
  226. package/build/docs/ibm-cloud-sdk-core.tokenmanager.refreshtime.md +11 -0
  227. package/build/docs/ibm-cloud-sdk-core.tokenmanager.requesttoken.md +19 -0
  228. package/build/docs/ibm-cloud-sdk-core.tokenmanager.requestwrapperinstance.md +11 -0
  229. package/build/docs/ibm-cloud-sdk-core.tokenmanager.savetokeninfo.md +53 -0
  230. package/build/docs/ibm-cloud-sdk-core.tokenmanager.setdisablesslverification.md +53 -0
  231. package/build/docs/ibm-cloud-sdk-core.tokenmanager.setheaders.md +53 -0
  232. package/build/docs/ibm-cloud-sdk-core.tokenmanager.url.md +11 -0
  233. package/build/docs/ibm-cloud-sdk-core.tokenmanager.useragent.md +11 -0
  234. package/build/docs/ibm-cloud-sdk-core.tokenmanageroptions.md +18 -0
  235. package/build/docs/ibm-cloud-sdk-core.tokenrequestbasedauthenticator.md +66 -0
  236. package/build/docs/ibm-cloud-sdk-core.tokenrequestbasedauthenticator.setdisablesslverification.md +53 -0
  237. package/build/docs/ibm-cloud-sdk-core.tokenrequestbasedauthenticator.setheaders.md +53 -0
  238. package/build/docs/ibm-cloud-sdk-core.tolowerkeys.md +55 -0
  239. package/build/docs/ibm-cloud-sdk-core.useroptions.authenticator.md +13 -0
  240. package/build/docs/ibm-cloud-sdk-core.useroptions.disablesslverification.md +13 -0
  241. package/build/docs/ibm-cloud-sdk-core.useroptions.headers.md +13 -0
  242. package/build/docs/ibm-cloud-sdk-core.useroptions.jar.md +13 -0
  243. package/build/docs/ibm-cloud-sdk-core.useroptions.md +171 -0
  244. package/build/docs/ibm-cloud-sdk-core.useroptions.serviceurl.md +13 -0
  245. package/build/docs/ibm-cloud-sdk-core.useroptions.url.md +13 -0
  246. package/build/docs/ibm-cloud-sdk-core.useroptions.version.md +13 -0
  247. package/build/docs/ibm-cloud-sdk-core.validateinput.md +73 -0
  248. package/build/docs/ibm-cloud-sdk-core.validateparams.md +89 -0
  249. package/build/docs/ibm-cloud-sdk-core.vpcinstanceauthenticator._constructor_.md +54 -0
  250. package/build/docs/ibm-cloud-sdk-core.vpcinstanceauthenticator.authenticationtype.md +19 -0
  251. package/build/docs/ibm-cloud-sdk-core.vpcinstanceauthenticator.md +158 -0
  252. package/build/docs/ibm-cloud-sdk-core.vpcinstanceauthenticator.setiamprofilecrn.md +53 -0
  253. package/build/docs/ibm-cloud-sdk-core.vpcinstanceauthenticator.setiamprofileid.md +53 -0
  254. package/build/docs/ibm-cloud-sdk-core.vpcinstanceauthenticator.tokenmanager.md +11 -0
  255. package/build/docs/ibm-cloud-sdk-core.vpcinstancetokenmanager._constructor_.md +54 -0
  256. package/build/docs/ibm-cloud-sdk-core.vpcinstancetokenmanager.istokenexpired.md +19 -0
  257. package/build/docs/ibm-cloud-sdk-core.vpcinstancetokenmanager.md +126 -0
  258. package/build/docs/ibm-cloud-sdk-core.vpcinstancetokenmanager.requesttoken.md +15 -0
  259. package/build/docs/ibm-cloud-sdk-core.vpcinstancetokenmanager.setiamprofilecrn.md +53 -0
  260. package/build/docs/ibm-cloud-sdk-core.vpcinstancetokenmanager.setiamprofileid.md +53 -0
  261. package/build/docs/index.md +29 -0
  262. package/docs/ibm-cloud-sdk-core.api.json +787 -404
  263. package/es/auth/authenticators/authenticator.d.ts +1 -0
  264. package/es/auth/authenticators/authenticator.js +1 -0
  265. package/es/auth/authenticators/container-authenticator.d.ts +6 -0
  266. package/es/auth/authenticators/container-authenticator.js +8 -0
  267. package/es/auth/authenticators/iam-assume-authenticator.d.ts +82 -0
  268. package/es/auth/authenticators/iam-assume-authenticator.js +70 -0
  269. package/es/auth/authenticators/iam-authenticator.d.ts +6 -0
  270. package/es/auth/authenticators/iam-authenticator.js +8 -0
  271. package/es/auth/authenticators/iam-request-based-authenticator-immutable.d.ts +64 -0
  272. package/es/auth/authenticators/iam-request-based-authenticator-immutable.js +51 -0
  273. package/es/auth/authenticators/iam-request-based-authenticator.d.ts +19 -47
  274. package/es/auth/authenticators/iam-request-based-authenticator.js +26 -35
  275. package/es/auth/authenticators/index.d.ts +4 -1
  276. package/es/auth/authenticators/index.js +1 -0
  277. package/es/auth/authenticators/token-request-based-authenticator-immutable.d.ts +71 -0
  278. package/es/auth/authenticators/token-request-based-authenticator-immutable.js +65 -0
  279. package/es/auth/authenticators/token-request-based-authenticator.d.ts +4 -42
  280. package/es/auth/authenticators/token-request-based-authenticator.js +3 -39
  281. package/es/auth/token-managers/container-token-manager.d.ts +6 -0
  282. package/es/auth/token-managers/container-token-manager.js +18 -24
  283. package/es/auth/token-managers/iam-assume-token-manager.d.ts +101 -0
  284. package/es/auth/token-managers/iam-assume-token-manager.js +164 -0
  285. package/es/auth/token-managers/iam-request-based-token-manager.d.ts +3 -9
  286. package/es/auth/token-managers/iam-request-based-token-manager.js +0 -8
  287. package/es/auth/token-managers/iam-token-manager.d.ts +8 -2
  288. package/es/auth/token-managers/iam-token-manager.js +10 -2
  289. package/es/auth/token-managers/index.d.ts +4 -2
  290. package/es/auth/token-managers/index.js +4 -2
  291. package/es/auth/utils/get-authenticator-from-environment.js +4 -1
  292. package/es/auth/utils/helpers.d.ts +18 -23
  293. package/es/auth/utils/helpers.js +35 -27
  294. package/es/tsdoc-metadata.json +11 -0
  295. package/etc/ibm-cloud-sdk-core.api.md +46 -28
  296. package/ibm-cloud-sdk-core.d.ts +264 -68
  297. package/package.json +2 -2
  298. package/temp/ibm-cloud-sdk-core.api.json +8646 -0
  299. package/temp/ibm-cloud-sdk-core.api.md +505 -0
@@ -0,0 +1,91 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
33
+ return (mod && mod.__esModule) ? mod : { "default": mod };
34
+ };
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.TokenRequestBasedAuthenticatorImmutable = void 0;
37
+ var extend_1 = __importDefault(require("extend"));
38
+ var jwt_token_manager_1 = require("../token-managers/jwt-token-manager");
39
+ var authenticator_1 = require("./authenticator");
40
+ var logger_1 = __importDefault(require("../../lib/logger"));
41
+ /**
42
+ * Class for common functionality shared by token-request authenticators.
43
+ * Token-request authenticators use token managers to retrieve, store,
44
+ * and refresh tokens. Not intended to be used as stand-alone authenticator,
45
+ * but as base class to authenticators that have their own token manager
46
+ * implementations.
47
+ *
48
+ * The token will be added as an Authorization header in the form:
49
+ *
50
+ * Authorization: Bearer \<bearer-token\>
51
+ */
52
+ var TokenRequestBasedAuthenticatorImmutable = /** @class */ (function (_super) {
53
+ __extends(TokenRequestBasedAuthenticatorImmutable, _super);
54
+ /**
55
+ * Create a new TokenRequestBasedAuthenticatorImmutable instance with an internal JwtTokenManager.
56
+ *
57
+ * @param options - Configuration options.
58
+ * This should be an object containing these fields:
59
+ * - url: (optional) the endpoint URL for the token service
60
+ * - disableSslVerification: (optional) a flag that indicates whether verification of the token server's SSL certificate
61
+ * should be disabled or not
62
+ * - headers: (optional) a set of HTTP headers to be sent with each request to the token service
63
+ */
64
+ function TokenRequestBasedAuthenticatorImmutable(options) {
65
+ var _this = _super.call(this) || this;
66
+ _this.disableSslVerification = Boolean(options.disableSslVerification);
67
+ _this.url = options.url;
68
+ // default to empty object
69
+ _this.headers = options.headers || {};
70
+ _this.tokenManager = new jwt_token_manager_1.JwtTokenManager(options);
71
+ return _this;
72
+ }
73
+ /**
74
+ * Adds bearer token information to "requestOptions". The bearer token information
75
+ * will be set in the Authorization property of "requestOptions.headers" in the form:
76
+ *
77
+ * Authorization: Bearer \<bearer-token\>
78
+ *
79
+ * @param requestOptions - The request to augment with authentication information.
80
+ */
81
+ TokenRequestBasedAuthenticatorImmutable.prototype.authenticate = function (requestOptions) {
82
+ var _this = this;
83
+ return this.tokenManager.getToken().then(function (token) {
84
+ var authHeader = { Authorization: "Bearer ".concat(token) };
85
+ requestOptions.headers = (0, extend_1.default)(true, {}, requestOptions.headers, authHeader);
86
+ logger_1.default.debug("Authenticated outbound request (type=".concat(_this.authenticationType(), ")"));
87
+ });
88
+ };
89
+ return TokenRequestBasedAuthenticatorImmutable;
90
+ }(authenticator_1.Authenticator));
91
+ exports.TokenRequestBasedAuthenticatorImmutable = TokenRequestBasedAuthenticatorImmutable;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * (C) Copyright IBM Corp. 2019, 2023.
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.
@@ -15,23 +15,9 @@
15
15
  */
16
16
  /// <reference types="node" />
17
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';
18
+ import { TokenRequestBasedAuthenticatorImmutable } from './token-request-based-authenticator-immutable';
21
19
  /** 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
- };
20
+ export { BaseOptions } from './token-request-based-authenticator-immutable';
35
21
  /**
36
22
  * Class for common functionality shared by token-request authenticators.
37
23
  * TokenRequestBasedAuthenticators use token managers to retrieve, store,
@@ -43,22 +29,7 @@ export type BaseOptions = {
43
29
  *
44
30
  * Authorization: Bearer \<bearer-token\>
45
31
  */
46
- export declare class TokenRequestBasedAuthenticator extends Authenticator {
47
- protected tokenManager: JwtTokenManager;
48
- protected url: string;
49
- protected headers: OutgoingHttpHeaders;
50
- protected disableSslVerification: boolean;
51
- /**
52
- * Create a new TokenRequestBasedAuthenticator 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);
32
+ export declare class TokenRequestBasedAuthenticator extends TokenRequestBasedAuthenticatorImmutable {
62
33
  /**
63
34
  * Set the flag that indicates whether verification of the server's SSL
64
35
  * certificate should be disabled or not.
@@ -74,13 +45,4 @@ export declare class TokenRequestBasedAuthenticator extends Authenticator {
74
45
  * Overwrites previous default headers.
75
46
  */
76
47
  setHeaders(headers: OutgoingHttpHeaders): void;
77
- /**
78
- * Adds bearer token information to "requestOptions". The bearer token information
79
- * will be set in the Authorization property of "requestOptions.headers" in the form:
80
- *
81
- * Authorization: Bearer \<bearer-token\>
82
- *
83
- * @param requestOptions - The request to augment with authentication information.
84
- */
85
- authenticate(requestOptions: AuthenticateOptions): Promise<void>;
86
48
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * (C) Copyright IBM Corp. 2019, 2023.
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.
@@ -29,15 +29,9 @@ var __extends = (this && this.__extends) || (function () {
29
29
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
30
30
  };
31
31
  })();
32
- var __importDefault = (this && this.__importDefault) || function (mod) {
33
- return (mod && mod.__esModule) ? mod : { "default": mod };
34
- };
35
32
  Object.defineProperty(exports, "__esModule", { value: true });
36
33
  exports.TokenRequestBasedAuthenticator = void 0;
37
- var extend_1 = __importDefault(require("extend"));
38
- var jwt_token_manager_1 = require("../token-managers/jwt-token-manager");
39
- var authenticator_1 = require("./authenticator");
40
- var logger_1 = __importDefault(require("../../lib/logger"));
34
+ var token_request_based_authenticator_immutable_1 = require("./token-request-based-authenticator-immutable");
41
35
  /**
42
36
  * Class for common functionality shared by token-request authenticators.
43
37
  * TokenRequestBasedAuthenticators use token managers to retrieve, store,
@@ -51,24 +45,8 @@ var logger_1 = __importDefault(require("../../lib/logger"));
51
45
  */
52
46
  var TokenRequestBasedAuthenticator = /** @class */ (function (_super) {
53
47
  __extends(TokenRequestBasedAuthenticator, _super);
54
- /**
55
- * Create a new TokenRequestBasedAuthenticator instance with an internal JwtTokenManager.
56
- *
57
- * @param options - Configuration options.
58
- * This should be an object containing these fields:
59
- * - url: (optional) the endpoint URL for the token service
60
- * - disableSslVerification: (optional) a flag that indicates whether verification of the token server's SSL certificate
61
- * should be disabled or not
62
- * - headers: (optional) a set of HTTP headers to be sent with each request to the token service
63
- */
64
- function TokenRequestBasedAuthenticator(options) {
65
- var _this = _super.call(this) || this;
66
- _this.disableSslVerification = Boolean(options.disableSslVerification);
67
- _this.url = options.url;
68
- // default to empty object
69
- _this.headers = options.headers || {};
70
- _this.tokenManager = new jwt_token_manager_1.JwtTokenManager(options);
71
- return _this;
48
+ function TokenRequestBasedAuthenticator() {
49
+ return _super !== null && _super.apply(this, arguments) || this;
72
50
  }
73
51
  /**
74
52
  * Set the flag that indicates whether verification of the server's SSL
@@ -97,22 +75,6 @@ var TokenRequestBasedAuthenticator = /** @class */ (function (_super) {
97
75
  this.headers = headers;
98
76
  this.tokenManager.setHeaders(this.headers);
99
77
  };
100
- /**
101
- * Adds bearer token information to "requestOptions". The bearer token information
102
- * will be set in the Authorization property of "requestOptions.headers" in the form:
103
- *
104
- * Authorization: Bearer \<bearer-token\>
105
- *
106
- * @param requestOptions - The request to augment with authentication information.
107
- */
108
- TokenRequestBasedAuthenticator.prototype.authenticate = function (requestOptions) {
109
- var _this = this;
110
- return this.tokenManager.getToken().then(function (token) {
111
- var authHeader = { Authorization: "Bearer ".concat(token) };
112
- requestOptions.headers = (0, extend_1.default)(true, {}, requestOptions.headers, authHeader);
113
- logger_1.default.debug("Authenticated outbound request (type=".concat(_this.authenticationType(), ")"));
114
- });
115
- };
116
78
  return TokenRequestBasedAuthenticator;
117
- }(authenticator_1.Authenticator));
79
+ }(token_request_based_authenticator_immutable_1.TokenRequestBasedAuthenticatorImmutable));
118
80
  exports.TokenRequestBasedAuthenticator = TokenRequestBasedAuthenticator;
@@ -65,6 +65,12 @@ export declare class ContainerTokenManager extends IamRequestBasedTokenManager {
65
65
  * @param iamProfileId - the ID of the IAM trusted profile
66
66
  */
67
67
  setIamProfileId(iamProfileId: string): void;
68
+ /**
69
+ * Returns the most recently stored refresh token.
70
+ *
71
+ * @returns the refresh token
72
+ */
73
+ getRefreshToken(): string;
68
74
  /**
69
75
  * Request an IAM token using a compute resource token.
70
76
  */
@@ -29,42 +29,6 @@ var __extends = (this && this.__extends) || (function () {
29
29
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
30
30
  };
31
31
  })();
32
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
33
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
34
- return new (P || (P = Promise))(function (resolve, reject) {
35
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
36
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
37
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
38
- step((generator = generator.apply(thisArg, _arguments || [])).next());
39
- });
40
- };
41
- var __generator = (this && this.__generator) || function (thisArg, body) {
42
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
43
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
44
- function verb(n) { return function (v) { return step([n, v]); }; }
45
- function step(op) {
46
- if (f) throw new TypeError("Generator is already executing.");
47
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
48
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
49
- if (y = 0, t) op = [op[0] & 2, t.value];
50
- switch (op[0]) {
51
- case 0: case 1: t = op; break;
52
- case 4: _.label++; return { value: op[1], done: false };
53
- case 5: _.label++; y = op[1]; op = [0]; continue;
54
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
55
- default:
56
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
57
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
58
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
59
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
60
- if (t[2]) _.ops.pop();
61
- _.trys.pop(); continue;
62
- }
63
- op = body.call(thisArg, _);
64
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
65
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
66
- }
67
- };
68
32
  Object.defineProperty(exports, "__esModule", { value: true });
69
33
  exports.ContainerTokenManager = void 0;
70
34
  var helpers_1 = require("../utils/helpers");
@@ -143,24 +107,28 @@ var ContainerTokenManager = /** @class */ (function (_super) {
143
107
  ContainerTokenManager.prototype.setIamProfileId = function (iamProfileId) {
144
108
  this.iamProfileId = iamProfileId;
145
109
  };
110
+ /**
111
+ * Returns the most recently stored refresh token.
112
+ *
113
+ * @returns the refresh token
114
+ */
115
+ ContainerTokenManager.prototype.getRefreshToken = function () {
116
+ return this.refreshToken;
117
+ };
146
118
  /**
147
119
  * Request an IAM token using a compute resource token.
148
120
  */
149
121
  ContainerTokenManager.prototype.requestToken = function () {
150
- return __awaiter(this, void 0, void 0, function () {
151
- return __generator(this, function (_a) {
152
- this.formData.cr_token = this.getCrToken();
153
- // these member variables can be reset, set them in the form data right
154
- // before making the request to ensure they're up to date
155
- if (this.iamProfileName) {
156
- this.formData.profile_name = this.iamProfileName;
157
- }
158
- if (this.iamProfileId) {
159
- this.formData.profile_id = this.iamProfileId;
160
- }
161
- return [2 /*return*/, _super.prototype.requestToken.call(this)];
162
- });
163
- });
122
+ this.formData.cr_token = this.getCrToken();
123
+ // these member variables can be reset, set them in the form data right
124
+ // before making the request to ensure they're up to date
125
+ if (this.iamProfileName) {
126
+ this.formData.profile_name = this.iamProfileName;
127
+ }
128
+ if (this.iamProfileId) {
129
+ this.formData.profile_id = this.iamProfileId;
130
+ }
131
+ return _super.prototype.requestToken.call(this);
164
132
  };
165
133
  /**
166
134
  * Retrieves the CR token from a file using this search order:
@@ -0,0 +1,101 @@
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 { IamRequestBasedTokenManager, IamRequestOptions } from './iam-request-based-token-manager';
19
+ /** Configuration options for IAM Assume token retrieval. */
20
+ interface Options extends IamRequestOptions {
21
+ apikey: string;
22
+ iamProfileId?: string;
23
+ iamProfileCrn?: string;
24
+ iamProfileName?: string;
25
+ iamAccountId?: string;
26
+ }
27
+ /**
28
+ * The IamAssumeTokenManager takes an api key, along with trusted profile information, and performs
29
+ * the necessary interactions with the IAM token service to obtain and store a suitable bearer token
30
+ * that "assumes" the identify of the trusted profile.
31
+ */
32
+ export declare class IamAssumeTokenManager extends IamRequestBasedTokenManager {
33
+ protected requiredOptions: string[];
34
+ private iamProfileId;
35
+ private iamProfileCrn;
36
+ private iamProfileName;
37
+ private iamAccountId;
38
+ private iamDelegate;
39
+ /**
40
+ *
41
+ * Create a new IamAssumeTokenManager instance.
42
+ *
43
+ * @param options - Configuration options.
44
+ * This should be an object containing these fields:
45
+ * - apikey: (required) the IAM api key
46
+ * - iamProfileId: (optional) the ID of the trusted profile to use
47
+ * - iamProfileCrn: (optional) the CRN of the trusted profile to use
48
+ * - iamProfileName: (optional) the name of the trusted profile to use (must be specified with iamAccountId)
49
+ * - iamAccountId: (optional) the ID of the account the trusted profile is in (must be specified with iamProfileName)
50
+ * - url: (optional) the endpoint URL for the IAM token service (default value: "https://iam.cloud.ibm.com")
51
+ * - disableSslVerification: (optional) a flag that indicates whether verification of the token server's SSL certificate
52
+ * should be disabled or not
53
+ * - headers: (optional) a set of HTTP headers to be sent with each request to the token service
54
+ * - clientId: (optional) the "clientId" and "clientSecret" fields are used to form a Basic
55
+ * Authorization header to be included in each request to the token service
56
+ * - clientSecret: (optional) the "clientId" and "clientSecret" fields are used to form a Basic
57
+ * Authorization header to be included in each request to the token service
58
+ * - scope: (optional) the "scope" parameter to use when fetching the bearer token from the token service
59
+ *
60
+ * @throws Error: the configuration options are not valid.
61
+ */
62
+ constructor(options: Options);
63
+ /**
64
+ * Request an IAM token using a standard access token and a trusted profile.
65
+ */
66
+ protected requestToken(): Promise<any>;
67
+ /**
68
+ * Extend this method from the parent class to erase the refresh token from
69
+ * the class - we do not want to expose it for IAM Assume authentication.
70
+ *
71
+ * @param tokenResponse - the response object from JWT service request
72
+ */
73
+ protected saveTokenInfo(tokenResponse: any): void;
74
+ /**
75
+ * Sets the IAM "scope" value.
76
+ * This value is sent as the "scope" form parameter in the IAM delegate request.
77
+ *
78
+ * @param scope - a space-separated string that contains one or more scope names
79
+ */
80
+ setScope(scope: string): void;
81
+ /**
82
+ * Sets the IAM "clientId" and "clientSecret" values for the IAM delegate.
83
+ *
84
+ * @param clientId - the client id.
85
+ * @param clientSecret - the client secret.
86
+ */
87
+ setClientIdAndSecret(clientId: string, clientSecret: string): void;
88
+ /**
89
+ * Sets the "disableSslVerification" property for the IAM delegate.
90
+ *
91
+ * @param value - the new value for the disableSslVerification property
92
+ */
93
+ setDisableSslVerification(value: boolean): void;
94
+ /**
95
+ * Sets the headers to be included in the IAM delegate's requests.
96
+ *
97
+ * @param headers - the set of headers to send with each request to the token server
98
+ */
99
+ setHeaders(headers: OutgoingHttpHeaders): void;
100
+ }
101
+ export {};
@@ -0,0 +1,220 @@
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
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
33
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
34
+ return new (P || (P = Promise))(function (resolve, reject) {
35
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
36
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
37
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
38
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
39
+ });
40
+ };
41
+ var __generator = (this && this.__generator) || function (thisArg, body) {
42
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
43
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
44
+ function verb(n) { return function (v) { return step([n, v]); }; }
45
+ function step(op) {
46
+ if (f) throw new TypeError("Generator is already executing.");
47
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
48
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
49
+ if (y = 0, t) op = [op[0] & 2, t.value];
50
+ switch (op[0]) {
51
+ case 0: case 1: t = op; break;
52
+ case 4: _.label++; return { value: op[1], done: false };
53
+ case 5: _.label++; y = op[1]; op = [0]; continue;
54
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
55
+ default:
56
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
57
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
58
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
59
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
60
+ if (t[2]) _.ops.pop();
61
+ _.trys.pop(); continue;
62
+ }
63
+ op = body.call(thisArg, _);
64
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
65
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
66
+ }
67
+ };
68
+ Object.defineProperty(exports, "__esModule", { value: true });
69
+ exports.IamAssumeTokenManager = void 0;
70
+ var helpers_1 = require("../utils/helpers");
71
+ var build_user_agent_1 = require("../../lib/build-user-agent");
72
+ var iam_request_based_token_manager_1 = require("./iam-request-based-token-manager");
73
+ var iam_token_manager_1 = require("./iam-token-manager");
74
+ /**
75
+ * The IamAssumeTokenManager takes an api key, along with trusted profile information, and performs
76
+ * the necessary interactions with the IAM token service to obtain and store a suitable bearer token
77
+ * that "assumes" the identify of the trusted profile.
78
+ */
79
+ var IamAssumeTokenManager = /** @class */ (function (_super) {
80
+ __extends(IamAssumeTokenManager, _super);
81
+ /**
82
+ *
83
+ * Create a new IamAssumeTokenManager instance.
84
+ *
85
+ * @param options - Configuration options.
86
+ * This should be an object containing these fields:
87
+ * - apikey: (required) the IAM api key
88
+ * - iamProfileId: (optional) the ID of the trusted profile to use
89
+ * - iamProfileCrn: (optional) the CRN of the trusted profile to use
90
+ * - iamProfileName: (optional) the name of the trusted profile to use (must be specified with iamAccountId)
91
+ * - iamAccountId: (optional) the ID of the account the trusted profile is in (must be specified with iamProfileName)
92
+ * - url: (optional) the endpoint URL for the IAM token service (default value: "https://iam.cloud.ibm.com")
93
+ * - disableSslVerification: (optional) a flag that indicates whether verification of the token server's SSL certificate
94
+ * should be disabled or not
95
+ * - headers: (optional) a set of HTTP headers to be sent with each request to the token service
96
+ * - clientId: (optional) the "clientId" and "clientSecret" fields are used to form a Basic
97
+ * Authorization header to be included in each request to the token service
98
+ * - clientSecret: (optional) the "clientId" and "clientSecret" fields are used to form a Basic
99
+ * Authorization header to be included in each request to the token service
100
+ * - scope: (optional) the "scope" parameter to use when fetching the bearer token from the token service
101
+ *
102
+ * @throws Error: the configuration options are not valid.
103
+ */
104
+ function IamAssumeTokenManager(options) {
105
+ var _this = _super.call(this, options) || this;
106
+ _this.requiredOptions = ['apikey'];
107
+ // This just verifies that the API key is provided and is free of common issues.
108
+ (0, helpers_1.validateInput)(options, _this.requiredOptions);
109
+ // This validates the assume-specific fields.
110
+ // Only one of the following three options may be specified.
111
+ if (!(0, helpers_1.onlyOne)(options.iamProfileId, options.iamProfileCrn, options.iamProfileName)) {
112
+ throw new Error('Exactly one of `iamProfileName`, `iamProfileCrn`, or `iamProfileId` must be specified.');
113
+ }
114
+ // `iamAccountId` may only be specified if `iamProfileName` is also specified.
115
+ if (Boolean(options.iamProfileName) !== Boolean(options.iamAccountId)) {
116
+ throw new Error('`iamProfileName` and `iamAccountId` must be provided together, or not at all.');
117
+ }
118
+ // Set class variables from options. If they are 'undefined' in options,
119
+ // they won't be changed, as they are 'undefined' to begin with.
120
+ _this.iamProfileId = options.iamProfileId;
121
+ _this.iamProfileCrn = options.iamProfileCrn;
122
+ _this.iamProfileName = options.iamProfileName;
123
+ _this.iamAccountId = options.iamAccountId;
124
+ _this.iamDelegate = options.iamDelegate;
125
+ // Create an instance of the IamTokenManager, which will be used to obtain
126
+ // an IAM access token for use in the "assume" token exchange. Most option
127
+ // names are shared between these token manager, and extraneous options will
128
+ // be ignored, so we can pass the options structure to that constructor as-is.
129
+ _this.iamDelegate = new iam_token_manager_1.IamTokenManager(options);
130
+ // These options are used by the delegate token manager
131
+ // but they are not supported by this token manager.
132
+ _this.clientId = undefined;
133
+ _this.clientSecret = undefined;
134
+ _this.scope = undefined;
135
+ // Set the grant type and user agent for this flavor of authentication.
136
+ _this.formData.grant_type = 'urn:ibm:params:oauth:grant-type:assume';
137
+ _this.userAgent = (0, build_user_agent_1.buildUserAgent)('iam-assume-authenticator');
138
+ return _this;
139
+ }
140
+ /**
141
+ * Request an IAM token using a standard access token and a trusted profile.
142
+ */
143
+ IamAssumeTokenManager.prototype.requestToken = function () {
144
+ return __awaiter(this, void 0, void 0, function () {
145
+ var _a;
146
+ return __generator(this, function (_b) {
147
+ switch (_b.label) {
148
+ case 0:
149
+ // First, retrieve a standard IAM access token from the delegate and set it in the form data.
150
+ _a = this.formData;
151
+ return [4 /*yield*/, this.iamDelegate.getToken()];
152
+ case 1:
153
+ // First, retrieve a standard IAM access token from the delegate and set it in the form data.
154
+ _a.access_token = _b.sent();
155
+ if (this.iamProfileCrn) {
156
+ this.formData.profile_crn = this.iamProfileCrn;
157
+ }
158
+ else if (this.iamProfileId) {
159
+ this.formData.profile_id = this.iamProfileId;
160
+ }
161
+ else {
162
+ this.formData.profile_name = this.iamProfileName;
163
+ this.formData.account = this.iamAccountId;
164
+ }
165
+ return [2 /*return*/, _super.prototype.requestToken.call(this)];
166
+ }
167
+ });
168
+ });
169
+ };
170
+ /**
171
+ * Extend this method from the parent class to erase the refresh token from
172
+ * the class - we do not want to expose it for IAM Assume authentication.
173
+ *
174
+ * @param tokenResponse - the response object from JWT service request
175
+ */
176
+ IamAssumeTokenManager.prototype.saveTokenInfo = function (tokenResponse) {
177
+ _super.prototype.saveTokenInfo.call(this, tokenResponse);
178
+ this.refreshToken = undefined;
179
+ };
180
+ // Override the inherited "setters". This token manager does not store these options
181
+ // but they can adjust properties on the stored IAM delegate.
182
+ /**
183
+ * Sets the IAM "scope" value.
184
+ * This value is sent as the "scope" form parameter in the IAM delegate request.
185
+ *
186
+ * @param scope - a space-separated string that contains one or more scope names
187
+ */
188
+ IamAssumeTokenManager.prototype.setScope = function (scope) {
189
+ this.iamDelegate.setScope(scope);
190
+ };
191
+ /**
192
+ * Sets the IAM "clientId" and "clientSecret" values for the IAM delegate.
193
+ *
194
+ * @param clientId - the client id.
195
+ * @param clientSecret - the client secret.
196
+ */
197
+ IamAssumeTokenManager.prototype.setClientIdAndSecret = function (clientId, clientSecret) {
198
+ this.iamDelegate.setClientIdAndSecret(clientId, clientSecret);
199
+ };
200
+ /**
201
+ * Sets the "disableSslVerification" property for the IAM delegate.
202
+ *
203
+ * @param value - the new value for the disableSslVerification property
204
+ */
205
+ IamAssumeTokenManager.prototype.setDisableSslVerification = function (value) {
206
+ _super.prototype.setDisableSslVerification.call(this, value);
207
+ this.iamDelegate.setDisableSslVerification(value);
208
+ };
209
+ /**
210
+ * Sets the headers to be included in the IAM delegate's requests.
211
+ *
212
+ * @param headers - the set of headers to send with each request to the token server
213
+ */
214
+ IamAssumeTokenManager.prototype.setHeaders = function (headers) {
215
+ _super.prototype.setHeaders.call(this, headers);
216
+ this.iamDelegate.setHeaders(headers);
217
+ };
218
+ return IamAssumeTokenManager;
219
+ }(iam_request_based_token_manager_1.IamRequestBasedTokenManager));
220
+ exports.IamAssumeTokenManager = IamAssumeTokenManager;