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.
- package/.secrets.baseline +118 -14
- package/Authentication.md +146 -21
- package/CHANGELOG.md +14 -0
- package/README.md +4 -3
- package/auth/authenticators/authenticator.d.ts +1 -0
- package/auth/authenticators/authenticator.js +1 -0
- package/auth/authenticators/container-authenticator.d.ts +6 -0
- package/auth/authenticators/container-authenticator.js +8 -0
- package/auth/authenticators/iam-assume-authenticator.d.ts +82 -0
- package/auth/authenticators/iam-assume-authenticator.js +92 -0
- package/auth/authenticators/iam-authenticator.d.ts +6 -0
- package/auth/authenticators/iam-authenticator.js +8 -0
- package/auth/authenticators/iam-request-based-authenticator-immutable.d.ts +64 -0
- package/auth/authenticators/iam-request-based-authenticator-immutable.js +74 -0
- package/auth/authenticators/iam-request-based-authenticator.d.ts +19 -47
- package/auth/authenticators/iam-request-based-authenticator.js +28 -36
- package/auth/authenticators/index.d.ts +4 -1
- package/auth/authenticators/index.js +3 -1
- package/auth/authenticators/token-request-based-authenticator-immutable.d.ts +71 -0
- package/auth/authenticators/token-request-based-authenticator-immutable.js +91 -0
- package/auth/authenticators/token-request-based-authenticator.d.ts +4 -42
- package/auth/authenticators/token-request-based-authenticator.js +5 -43
- package/auth/token-managers/container-token-manager.d.ts +6 -0
- package/auth/token-managers/container-token-manager.js +18 -50
- package/auth/token-managers/iam-assume-token-manager.d.ts +101 -0
- package/auth/token-managers/iam-assume-token-manager.js +220 -0
- package/auth/token-managers/iam-request-based-token-manager.d.ts +3 -9
- package/auth/token-managers/iam-request-based-token-manager.js +0 -8
- package/auth/token-managers/iam-token-manager.d.ts +8 -2
- package/auth/token-managers/iam-token-manager.js +10 -2
- package/auth/token-managers/index.d.ts +4 -2
- package/auth/token-managers/index.js +6 -3
- package/auth/utils/get-authenticator-from-environment.js +3 -0
- package/auth/utils/helpers.d.ts +18 -23
- package/auth/utils/helpers.js +50 -30
- package/build/docs/ibm-cloud-sdk-core.atleastone.md +55 -0
- package/build/docs/ibm-cloud-sdk-core.atmostone.md +55 -0
- package/build/docs/ibm-cloud-sdk-core.authenticator._constructor_.md +18 -0
- package/build/docs/ibm-cloud-sdk-core.authenticator.authenticate.md +57 -0
- package/build/docs/ibm-cloud-sdk-core.authenticator.authenticationtype.md +19 -0
- package/build/docs/ibm-cloud-sdk-core.authenticator.authtype_basic.md +13 -0
- package/build/docs/ibm-cloud-sdk-core.authenticator.authtype_bearertoken.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.authenticator.authtype_container.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.authenticator.authtype_cp4d.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.authenticator.authtype_iam.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.authenticator.authtype_iam_assume.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.authenticator.authtype_mcsp.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.authenticator.authtype_noauth.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.authenticator.authtype_unknown.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.authenticator.authtype_vpc.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.authenticator.md +313 -0
- package/build/docs/ibm-cloud-sdk-core.authenticatorinterface.authenticate.md +53 -0
- package/build/docs/ibm-cloud-sdk-core.authenticatorinterface.authenticationtype.md +17 -0
- package/build/docs/ibm-cloud-sdk-core.authenticatorinterface.md +50 -0
- package/build/docs/ibm-cloud-sdk-core.baseservice._constructor_.md +49 -0
- package/build/docs/ibm-cloud-sdk-core.baseservice.baseoptions.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.baseservice.configureservice.md +53 -0
- package/build/docs/ibm-cloud-sdk-core.baseservice.convertmodel.md +85 -0
- package/build/docs/ibm-cloud-sdk-core.baseservice.createrequest.md +55 -0
- package/build/docs/ibm-cloud-sdk-core.baseservice.createrequestanddeserializeresponse.md +87 -0
- package/build/docs/ibm-cloud-sdk-core.baseservice.default_service_name.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.baseservice.default_service_url.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.baseservice.disableretries.md +17 -0
- package/build/docs/ibm-cloud-sdk-core.baseservice.enableretries.md +53 -0
- package/build/docs/ibm-cloud-sdk-core.baseservice.getauthenticator.md +19 -0
- package/build/docs/ibm-cloud-sdk-core.baseservice.gethttpclient.md +17 -0
- package/build/docs/ibm-cloud-sdk-core.baseservice.md +313 -0
- package/build/docs/ibm-cloud-sdk-core.baseservice.setdefaultheaders.md +53 -0
- package/build/docs/ibm-cloud-sdk-core.baseservice.setenablegzipcompression.md +53 -0
- package/build/docs/ibm-cloud-sdk-core.baseservice.setserviceurl.md +53 -0
- package/build/docs/ibm-cloud-sdk-core.basicauthenticator._constructor_.md +54 -0
- package/build/docs/ibm-cloud-sdk-core.basicauthenticator.authenticate.md +55 -0
- package/build/docs/ibm-cloud-sdk-core.basicauthenticator.authenticationtype.md +19 -0
- package/build/docs/ibm-cloud-sdk-core.basicauthenticator.authheader.md +13 -0
- package/build/docs/ibm-cloud-sdk-core.basicauthenticator.md +165 -0
- package/build/docs/ibm-cloud-sdk-core.basicauthenticator.requiredoptions.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.bearertokenauthenticator._constructor_.md +54 -0
- package/build/docs/ibm-cloud-sdk-core.bearertokenauthenticator.authenticate.md +55 -0
- package/build/docs/ibm-cloud-sdk-core.bearertokenauthenticator.authenticationtype.md +19 -0
- package/build/docs/ibm-cloud-sdk-core.bearertokenauthenticator.md +160 -0
- package/build/docs/ibm-cloud-sdk-core.bearertokenauthenticator.requiredoptions.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.bearertokenauthenticator.setbearertoken.md +53 -0
- package/build/docs/ibm-cloud-sdk-core.buildrequestfileobject.md +55 -0
- package/build/docs/ibm-cloud-sdk-core.checkcredentials.md +71 -0
- package/build/docs/ibm-cloud-sdk-core.cloudpakfordataauthenticator._constructor_.md +54 -0
- package/build/docs/ibm-cloud-sdk-core.cloudpakfordataauthenticator.authenticationtype.md +19 -0
- package/build/docs/ibm-cloud-sdk-core.cloudpakfordataauthenticator.md +149 -0
- package/build/docs/ibm-cloud-sdk-core.cloudpakfordataauthenticator.requiredoptions.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.cloudpakfordataauthenticator.tokenmanager.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.computebasicauthheader.md +71 -0
- package/build/docs/ibm-cloud-sdk-core.constructfilepath.md +49 -0
- package/build/docs/ibm-cloud-sdk-core.constructserviceurl.md +87 -0
- package/build/docs/ibm-cloud-sdk-core.containerauthenticator._constructor_.md +54 -0
- package/build/docs/ibm-cloud-sdk-core.containerauthenticator.authenticationtype.md +19 -0
- package/build/docs/ibm-cloud-sdk-core.containerauthenticator.getrefreshtoken.md +19 -0
- package/build/docs/ibm-cloud-sdk-core.containerauthenticator.md +186 -0
- package/build/docs/ibm-cloud-sdk-core.containerauthenticator.setcrtokenfilename.md +53 -0
- package/build/docs/ibm-cloud-sdk-core.containerauthenticator.setiamprofileid.md +53 -0
- package/build/docs/ibm-cloud-sdk-core.containerauthenticator.setiamprofilename.md +53 -0
- package/build/docs/ibm-cloud-sdk-core.containerauthenticator.tokenmanager.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.containertokenmanager._constructor_.md +54 -0
- package/build/docs/ibm-cloud-sdk-core.containertokenmanager.getcrtoken.md +19 -0
- package/build/docs/ibm-cloud-sdk-core.containertokenmanager.getrefreshtoken.md +19 -0
- package/build/docs/ibm-cloud-sdk-core.containertokenmanager.md +156 -0
- package/build/docs/ibm-cloud-sdk-core.containertokenmanager.requesttoken.md +17 -0
- package/build/docs/ibm-cloud-sdk-core.containertokenmanager.setcrtokenfilename.md +53 -0
- package/build/docs/ibm-cloud-sdk-core.containertokenmanager.setiamprofileid.md +53 -0
- package/build/docs/ibm-cloud-sdk-core.containertokenmanager.setiamprofilename.md +53 -0
- package/build/docs/ibm-cloud-sdk-core.contenttype.md +14 -0
- package/build/docs/ibm-cloud-sdk-core.cp4dtokenmanager._constructor_.md +54 -0
- package/build/docs/ibm-cloud-sdk-core.cp4dtokenmanager.md +128 -0
- package/build/docs/ibm-cloud-sdk-core.cp4dtokenmanager.requesttoken.md +15 -0
- package/build/docs/ibm-cloud-sdk-core.cp4dtokenmanager.requiredoptions.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.fileexistsatpath.md +49 -0
- package/build/docs/ibm-cloud-sdk-core.fileobject.md +80 -0
- package/build/docs/ibm-cloud-sdk-core.fileobject.options.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.fileobject.value.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.fileoptions.contenttype.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.fileoptions.filename.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.fileoptions.md +74 -0
- package/build/docs/ibm-cloud-sdk-core.filestream.md +54 -0
- package/build/docs/ibm-cloud-sdk-core.filestream.path.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.filewithmetadata.contenttype.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.filewithmetadata.data.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.filewithmetadata.filename.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.filewithmetadata.md +87 -0
- package/build/docs/ibm-cloud-sdk-core.getauthenticatorfromenvironment.md +55 -0
- package/build/docs/ibm-cloud-sdk-core.getcontenttype.md +55 -0
- package/build/docs/ibm-cloud-sdk-core.getcurrenttime.md +19 -0
- package/build/docs/ibm-cloud-sdk-core.getformat.md +69 -0
- package/build/docs/ibm-cloud-sdk-core.getmissingparams.md +73 -0
- package/build/docs/ibm-cloud-sdk-core.getnewlogger.md +59 -0
- package/build/docs/ibm-cloud-sdk-core.getqueryparam.md +71 -0
- package/build/docs/ibm-cloud-sdk-core.iamassumeauthenticator._constructor_.md +54 -0
- package/build/docs/ibm-cloud-sdk-core.iamassumeauthenticator.authenticationtype.md +19 -0
- package/build/docs/ibm-cloud-sdk-core.iamassumeauthenticator.md +130 -0
- package/build/docs/ibm-cloud-sdk-core.iamassumeauthenticator.tokenmanager.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.iamassumetokenmanager._constructor_.md +54 -0
- package/build/docs/ibm-cloud-sdk-core.iamassumetokenmanager.md +200 -0
- package/build/docs/ibm-cloud-sdk-core.iamassumetokenmanager.requesttoken.md +17 -0
- package/build/docs/ibm-cloud-sdk-core.iamassumetokenmanager.requiredoptions.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.iamassumetokenmanager.savetokeninfo.md +53 -0
- package/build/docs/ibm-cloud-sdk-core.iamassumetokenmanager.setclientidandsecret.md +69 -0
- package/build/docs/ibm-cloud-sdk-core.iamassumetokenmanager.setdisablesslverification.md +53 -0
- package/build/docs/ibm-cloud-sdk-core.iamassumetokenmanager.setheaders.md +53 -0
- package/build/docs/ibm-cloud-sdk-core.iamassumetokenmanager.setscope.md +53 -0
- package/build/docs/ibm-cloud-sdk-core.iamauthenticator._constructor_.md +54 -0
- package/build/docs/ibm-cloud-sdk-core.iamauthenticator.authenticationtype.md +19 -0
- package/build/docs/ibm-cloud-sdk-core.iamauthenticator.getrefreshtoken.md +19 -0
- package/build/docs/ibm-cloud-sdk-core.iamauthenticator.md +163 -0
- package/build/docs/ibm-cloud-sdk-core.iamauthenticator.requiredoptions.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.iamauthenticator.tokenmanager.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.iamrequestbasedauthenticator.md +90 -0
- package/build/docs/ibm-cloud-sdk-core.iamrequestbasedauthenticator.setclientidandsecret.md +69 -0
- package/build/docs/ibm-cloud-sdk-core.iamrequestbasedauthenticator.setdisablesslverification.md +53 -0
- package/build/docs/ibm-cloud-sdk-core.iamrequestbasedauthenticator.setheaders.md +53 -0
- package/build/docs/ibm-cloud-sdk-core.iamrequestbasedauthenticator.setscope.md +53 -0
- package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager._constructor_.md +54 -0
- package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager.clientid.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager.clientsecret.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager.formdata.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager.istokenexpired.md +19 -0
- package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager.md +264 -0
- package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager.refreshtoken.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager.requesttoken.md +19 -0
- package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager.savetokeninfo.md +53 -0
- package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager.scope.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager.setclientidandsecret.md +69 -0
- package/build/docs/ibm-cloud-sdk-core.iamrequestbasedtokenmanager.setscope.md +53 -0
- package/build/docs/ibm-cloud-sdk-core.iamrequestoptions.clientid.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.iamrequestoptions.clientsecret.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.iamrequestoptions.md +96 -0
- package/build/docs/ibm-cloud-sdk-core.iamrequestoptions.scope.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.iamtokenmanager._constructor_.md +54 -0
- package/build/docs/ibm-cloud-sdk-core.iamtokenmanager.getrefreshtoken.md +19 -0
- package/build/docs/ibm-cloud-sdk-core.iamtokenmanager.md +126 -0
- package/build/docs/ibm-cloud-sdk-core.iamtokenmanager.requiredoptions.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.isemptyobject.md +49 -0
- package/build/docs/ibm-cloud-sdk-core.isfiledata.md +49 -0
- package/build/docs/ibm-cloud-sdk-core.isfilewithmetadata.md +49 -0
- package/build/docs/ibm-cloud-sdk-core.ishtml.md +55 -0
- package/build/docs/ibm-cloud-sdk-core.isjsonmimetype.md +55 -0
- package/build/docs/ibm-cloud-sdk-core.jwttokenmanager._constructor_.md +49 -0
- package/build/docs/ibm-cloud-sdk-core.jwttokenmanager.md +163 -0
- package/build/docs/ibm-cloud-sdk-core.jwttokenmanager.requesttoken.md +19 -0
- package/build/docs/ibm-cloud-sdk-core.jwttokenmanager.savetokeninfo.md +53 -0
- package/build/docs/ibm-cloud-sdk-core.jwttokenmanager.tokeninfo.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.jwttokenmanager.tokenname.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.jwttokenmanageroptions.md +15 -0
- package/build/docs/ibm-cloud-sdk-core.mcspauthenticator._constructor_.md +54 -0
- package/build/docs/ibm-cloud-sdk-core.mcspauthenticator.authenticationtype.md +19 -0
- package/build/docs/ibm-cloud-sdk-core.mcspauthenticator.md +145 -0
- package/build/docs/ibm-cloud-sdk-core.mcspauthenticator.requiredoptions.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.mcspauthenticator.tokenmanager.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.mcsptokenmanager._constructor_.md +54 -0
- package/build/docs/ibm-cloud-sdk-core.mcsptokenmanager.md +128 -0
- package/build/docs/ibm-cloud-sdk-core.mcsptokenmanager.requesttoken.md +15 -0
- package/build/docs/ibm-cloud-sdk-core.mcsptokenmanager.requiredoptions.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.md +820 -0
- package/build/docs/ibm-cloud-sdk-core.noauthauthenticator.authenticate.md +49 -0
- package/build/docs/ibm-cloud-sdk-core.noauthauthenticator.authenticationtype.md +19 -0
- package/build/docs/ibm-cloud-sdk-core.noauthauthenticator.md +60 -0
- package/build/docs/ibm-cloud-sdk-core.onlyone.md +55 -0
- package/build/docs/ibm-cloud-sdk-core.qs.md +21 -0
- package/build/docs/ibm-cloud-sdk-core.readcredentialsfile.md +17 -0
- package/build/docs/ibm-cloud-sdk-core.readcrtokenfile.md +49 -0
- package/build/docs/ibm-cloud-sdk-core.readexternalsources.md +55 -0
- package/build/docs/ibm-cloud-sdk-core.removesuffix.md +71 -0
- package/build/docs/ibm-cloud-sdk-core.sdklogger.debug.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.sdklogger.error.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.sdklogger.info.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.sdklogger.md +121 -0
- package/build/docs/ibm-cloud-sdk-core.sdklogger.verbose.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.sdklogger.warn.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.streamtopromise.md +55 -0
- package/build/docs/ibm-cloud-sdk-core.striptrailingslash.md +55 -0
- package/build/docs/ibm-cloud-sdk-core.tokenmanager._constructor_.md +49 -0
- package/build/docs/ibm-cloud-sdk-core.tokenmanager.accesstoken.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.tokenmanager.disablesslverification.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.tokenmanager.expiretime.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.tokenmanager.gettoken.md +17 -0
- package/build/docs/ibm-cloud-sdk-core.tokenmanager.headers.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.tokenmanager.istokenexpired.md +17 -0
- package/build/docs/ibm-cloud-sdk-core.tokenmanager.md +352 -0
- package/build/docs/ibm-cloud-sdk-core.tokenmanager.pacedrequesttoken.md +19 -0
- package/build/docs/ibm-cloud-sdk-core.tokenmanager.refreshtime.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.tokenmanager.requesttoken.md +19 -0
- package/build/docs/ibm-cloud-sdk-core.tokenmanager.requestwrapperinstance.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.tokenmanager.savetokeninfo.md +53 -0
- package/build/docs/ibm-cloud-sdk-core.tokenmanager.setdisablesslverification.md +53 -0
- package/build/docs/ibm-cloud-sdk-core.tokenmanager.setheaders.md +53 -0
- package/build/docs/ibm-cloud-sdk-core.tokenmanager.url.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.tokenmanager.useragent.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.tokenmanageroptions.md +18 -0
- package/build/docs/ibm-cloud-sdk-core.tokenrequestbasedauthenticator.md +66 -0
- package/build/docs/ibm-cloud-sdk-core.tokenrequestbasedauthenticator.setdisablesslverification.md +53 -0
- package/build/docs/ibm-cloud-sdk-core.tokenrequestbasedauthenticator.setheaders.md +53 -0
- package/build/docs/ibm-cloud-sdk-core.tolowerkeys.md +55 -0
- package/build/docs/ibm-cloud-sdk-core.useroptions.authenticator.md +13 -0
- package/build/docs/ibm-cloud-sdk-core.useroptions.disablesslverification.md +13 -0
- package/build/docs/ibm-cloud-sdk-core.useroptions.headers.md +13 -0
- package/build/docs/ibm-cloud-sdk-core.useroptions.jar.md +13 -0
- package/build/docs/ibm-cloud-sdk-core.useroptions.md +171 -0
- package/build/docs/ibm-cloud-sdk-core.useroptions.serviceurl.md +13 -0
- package/build/docs/ibm-cloud-sdk-core.useroptions.url.md +13 -0
- package/build/docs/ibm-cloud-sdk-core.useroptions.version.md +13 -0
- package/build/docs/ibm-cloud-sdk-core.validateinput.md +73 -0
- package/build/docs/ibm-cloud-sdk-core.validateparams.md +89 -0
- package/build/docs/ibm-cloud-sdk-core.vpcinstanceauthenticator._constructor_.md +54 -0
- package/build/docs/ibm-cloud-sdk-core.vpcinstanceauthenticator.authenticationtype.md +19 -0
- package/build/docs/ibm-cloud-sdk-core.vpcinstanceauthenticator.md +158 -0
- package/build/docs/ibm-cloud-sdk-core.vpcinstanceauthenticator.setiamprofilecrn.md +53 -0
- package/build/docs/ibm-cloud-sdk-core.vpcinstanceauthenticator.setiamprofileid.md +53 -0
- package/build/docs/ibm-cloud-sdk-core.vpcinstanceauthenticator.tokenmanager.md +11 -0
- package/build/docs/ibm-cloud-sdk-core.vpcinstancetokenmanager._constructor_.md +54 -0
- package/build/docs/ibm-cloud-sdk-core.vpcinstancetokenmanager.istokenexpired.md +19 -0
- package/build/docs/ibm-cloud-sdk-core.vpcinstancetokenmanager.md +126 -0
- package/build/docs/ibm-cloud-sdk-core.vpcinstancetokenmanager.requesttoken.md +15 -0
- package/build/docs/ibm-cloud-sdk-core.vpcinstancetokenmanager.setiamprofilecrn.md +53 -0
- package/build/docs/ibm-cloud-sdk-core.vpcinstancetokenmanager.setiamprofileid.md +53 -0
- package/build/docs/index.md +29 -0
- package/docs/ibm-cloud-sdk-core.api.json +787 -404
- package/es/auth/authenticators/authenticator.d.ts +1 -0
- package/es/auth/authenticators/authenticator.js +1 -0
- package/es/auth/authenticators/container-authenticator.d.ts +6 -0
- package/es/auth/authenticators/container-authenticator.js +8 -0
- package/es/auth/authenticators/iam-assume-authenticator.d.ts +82 -0
- package/es/auth/authenticators/iam-assume-authenticator.js +70 -0
- package/es/auth/authenticators/iam-authenticator.d.ts +6 -0
- package/es/auth/authenticators/iam-authenticator.js +8 -0
- package/es/auth/authenticators/iam-request-based-authenticator-immutable.d.ts +64 -0
- package/es/auth/authenticators/iam-request-based-authenticator-immutable.js +51 -0
- package/es/auth/authenticators/iam-request-based-authenticator.d.ts +19 -47
- package/es/auth/authenticators/iam-request-based-authenticator.js +26 -35
- package/es/auth/authenticators/index.d.ts +4 -1
- package/es/auth/authenticators/index.js +1 -0
- package/es/auth/authenticators/token-request-based-authenticator-immutable.d.ts +71 -0
- package/es/auth/authenticators/token-request-based-authenticator-immutable.js +65 -0
- package/es/auth/authenticators/token-request-based-authenticator.d.ts +4 -42
- package/es/auth/authenticators/token-request-based-authenticator.js +3 -39
- package/es/auth/token-managers/container-token-manager.d.ts +6 -0
- package/es/auth/token-managers/container-token-manager.js +18 -24
- package/es/auth/token-managers/iam-assume-token-manager.d.ts +101 -0
- package/es/auth/token-managers/iam-assume-token-manager.js +164 -0
- package/es/auth/token-managers/iam-request-based-token-manager.d.ts +3 -9
- package/es/auth/token-managers/iam-request-based-token-manager.js +0 -8
- package/es/auth/token-managers/iam-token-manager.d.ts +8 -2
- package/es/auth/token-managers/iam-token-manager.js +10 -2
- package/es/auth/token-managers/index.d.ts +4 -2
- package/es/auth/token-managers/index.js +4 -2
- package/es/auth/utils/get-authenticator-from-environment.js +4 -1
- package/es/auth/utils/helpers.d.ts +18 -23
- package/es/auth/utils/helpers.js +35 -27
- package/es/tsdoc-metadata.json +11 -0
- package/etc/ibm-cloud-sdk-core.api.md +46 -28
- package/ibm-cloud-sdk-core.d.ts +264 -68
- package/package.json +2 -2
- package/temp/ibm-cloud-sdk-core.api.json +8646 -0
- package/temp/ibm-cloud-sdk-core.api.md +505 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* (C) Copyright IBM Corp. 2024.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import extend from 'extend';
|
|
17
|
+
import { JwtTokenManager } from '../token-managers/jwt-token-manager';
|
|
18
|
+
import { Authenticator } from './authenticator';
|
|
19
|
+
import logger from '../../lib/logger';
|
|
20
|
+
/**
|
|
21
|
+
* Class for common functionality shared by token-request authenticators.
|
|
22
|
+
* Token-request authenticators use token managers to retrieve, store,
|
|
23
|
+
* and refresh tokens. Not intended to be used as stand-alone authenticator,
|
|
24
|
+
* but as base class to authenticators that have their own token manager
|
|
25
|
+
* implementations.
|
|
26
|
+
*
|
|
27
|
+
* The token will be added as an Authorization header in the form:
|
|
28
|
+
*
|
|
29
|
+
* Authorization: Bearer \<bearer-token\>
|
|
30
|
+
*/
|
|
31
|
+
export class TokenRequestBasedAuthenticatorImmutable extends Authenticator {
|
|
32
|
+
/**
|
|
33
|
+
* Create a new TokenRequestBasedAuthenticatorImmutable instance with an internal JwtTokenManager.
|
|
34
|
+
*
|
|
35
|
+
* @param options - Configuration options.
|
|
36
|
+
* This should be an object containing these fields:
|
|
37
|
+
* - url: (optional) the endpoint URL for the token service
|
|
38
|
+
* - disableSslVerification: (optional) a flag that indicates whether verification of the token server's SSL certificate
|
|
39
|
+
* should be disabled or not
|
|
40
|
+
* - headers: (optional) a set of HTTP headers to be sent with each request to the token service
|
|
41
|
+
*/
|
|
42
|
+
constructor(options) {
|
|
43
|
+
super();
|
|
44
|
+
this.disableSslVerification = Boolean(options.disableSslVerification);
|
|
45
|
+
this.url = options.url;
|
|
46
|
+
// default to empty object
|
|
47
|
+
this.headers = options.headers || {};
|
|
48
|
+
this.tokenManager = new JwtTokenManager(options);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Adds bearer token information to "requestOptions". The bearer token information
|
|
52
|
+
* will be set in the Authorization property of "requestOptions.headers" in the form:
|
|
53
|
+
*
|
|
54
|
+
* Authorization: Bearer \<bearer-token\>
|
|
55
|
+
*
|
|
56
|
+
* @param requestOptions - The request to augment with authentication information.
|
|
57
|
+
*/
|
|
58
|
+
authenticate(requestOptions) {
|
|
59
|
+
return this.tokenManager.getToken().then((token) => {
|
|
60
|
+
const authHeader = { Authorization: `Bearer ${token}` };
|
|
61
|
+
requestOptions.headers = extend(true, {}, requestOptions.headers, authHeader);
|
|
62
|
+
logger.debug(`Authenticated outbound request (type=${this.authenticationType()})`);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* (C) Copyright IBM Corp. 2019,
|
|
2
|
+
* (C) Copyright IBM Corp. 2019, 2024.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -15,23 +15,9 @@
|
|
|
15
15
|
*/
|
|
16
16
|
/// <reference types="node" />
|
|
17
17
|
import { OutgoingHttpHeaders } from 'http';
|
|
18
|
-
import {
|
|
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
|
|
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
|
|
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,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* (C) Copyright IBM Corp. 2019,
|
|
2
|
+
* (C) Copyright IBM Corp. 2019, 2024.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -13,10 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import
|
|
17
|
-
import { JwtTokenManager } from '../token-managers/jwt-token-manager';
|
|
18
|
-
import { Authenticator } from './authenticator';
|
|
19
|
-
import logger from '../../lib/logger';
|
|
16
|
+
import { TokenRequestBasedAuthenticatorImmutable } from './token-request-based-authenticator-immutable';
|
|
20
17
|
/**
|
|
21
18
|
* Class for common functionality shared by token-request authenticators.
|
|
22
19
|
* TokenRequestBasedAuthenticators use token managers to retrieve, store,
|
|
@@ -28,25 +25,7 @@ import logger from '../../lib/logger';
|
|
|
28
25
|
*
|
|
29
26
|
* Authorization: Bearer \<bearer-token\>
|
|
30
27
|
*/
|
|
31
|
-
export class TokenRequestBasedAuthenticator extends
|
|
32
|
-
/**
|
|
33
|
-
* Create a new TokenRequestBasedAuthenticator instance with an internal JwtTokenManager.
|
|
34
|
-
*
|
|
35
|
-
* @param options - Configuration options.
|
|
36
|
-
* This should be an object containing these fields:
|
|
37
|
-
* - url: (optional) the endpoint URL for the token service
|
|
38
|
-
* - disableSslVerification: (optional) a flag that indicates whether verification of the token server's SSL certificate
|
|
39
|
-
* should be disabled or not
|
|
40
|
-
* - headers: (optional) a set of HTTP headers to be sent with each request to the token service
|
|
41
|
-
*/
|
|
42
|
-
constructor(options) {
|
|
43
|
-
super();
|
|
44
|
-
this.disableSslVerification = Boolean(options.disableSslVerification);
|
|
45
|
-
this.url = options.url;
|
|
46
|
-
// default to empty object
|
|
47
|
-
this.headers = options.headers || {};
|
|
48
|
-
this.tokenManager = new JwtTokenManager(options);
|
|
49
|
-
}
|
|
28
|
+
export class TokenRequestBasedAuthenticator extends TokenRequestBasedAuthenticatorImmutable {
|
|
50
29
|
/**
|
|
51
30
|
* Set the flag that indicates whether verification of the server's SSL
|
|
52
31
|
* certificate should be disabled or not.
|
|
@@ -74,19 +53,4 @@ export class TokenRequestBasedAuthenticator extends Authenticator {
|
|
|
74
53
|
this.headers = headers;
|
|
75
54
|
this.tokenManager.setHeaders(this.headers);
|
|
76
55
|
}
|
|
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) {
|
|
86
|
-
return this.tokenManager.getToken().then((token) => {
|
|
87
|
-
const authHeader = { Authorization: `Bearer ${token}` };
|
|
88
|
-
requestOptions.headers = extend(true, {}, requestOptions.headers, authHeader);
|
|
89
|
-
logger.debug(`Authenticated outbound request (type=${this.authenticationType()})`);
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
56
|
}
|
|
@@ -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
|
*/
|
|
@@ -13,15 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
16
|
import { atLeastOne } from '../utils/helpers';
|
|
26
17
|
import { readCrTokenFile } from '../utils/file-reading-helpers';
|
|
27
18
|
import { buildUserAgent } from '../../lib/build-user-agent';
|
|
@@ -95,25 +86,28 @@ export class ContainerTokenManager extends IamRequestBasedTokenManager {
|
|
|
95
86
|
setIamProfileId(iamProfileId) {
|
|
96
87
|
this.iamProfileId = iamProfileId;
|
|
97
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Returns the most recently stored refresh token.
|
|
91
|
+
*
|
|
92
|
+
* @returns the refresh token
|
|
93
|
+
*/
|
|
94
|
+
getRefreshToken() {
|
|
95
|
+
return this.refreshToken;
|
|
96
|
+
}
|
|
98
97
|
/**
|
|
99
98
|
* Request an IAM token using a compute resource token.
|
|
100
99
|
*/
|
|
101
100
|
requestToken() {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
this.formData.
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (this.iamProfileId) {
|
|
113
|
-
this.formData.profile_id = this.iamProfileId;
|
|
114
|
-
}
|
|
115
|
-
return _super.requestToken.call(this);
|
|
116
|
-
});
|
|
101
|
+
this.formData.cr_token = this.getCrToken();
|
|
102
|
+
// these member variables can be reset, set them in the form data right
|
|
103
|
+
// before making the request to ensure they're up to date
|
|
104
|
+
if (this.iamProfileName) {
|
|
105
|
+
this.formData.profile_name = this.iamProfileName;
|
|
106
|
+
}
|
|
107
|
+
if (this.iamProfileId) {
|
|
108
|
+
this.formData.profile_id = this.iamProfileId;
|
|
109
|
+
}
|
|
110
|
+
return super.requestToken();
|
|
117
111
|
}
|
|
118
112
|
/**
|
|
119
113
|
* 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,164 @@
|
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
import { onlyOne, validateInput } from '../utils/helpers';
|
|
26
|
+
import { buildUserAgent } from '../../lib/build-user-agent';
|
|
27
|
+
import { IamRequestBasedTokenManager } from './iam-request-based-token-manager';
|
|
28
|
+
import { IamTokenManager } from './iam-token-manager';
|
|
29
|
+
/**
|
|
30
|
+
* The IamAssumeTokenManager takes an api key, along with trusted profile information, and performs
|
|
31
|
+
* the necessary interactions with the IAM token service to obtain and store a suitable bearer token
|
|
32
|
+
* that "assumes" the identify of the trusted profile.
|
|
33
|
+
*/
|
|
34
|
+
export class IamAssumeTokenManager extends IamRequestBasedTokenManager {
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* Create a new IamAssumeTokenManager instance.
|
|
38
|
+
*
|
|
39
|
+
* @param options - Configuration options.
|
|
40
|
+
* This should be an object containing these fields:
|
|
41
|
+
* - apikey: (required) the IAM api key
|
|
42
|
+
* - iamProfileId: (optional) the ID of the trusted profile to use
|
|
43
|
+
* - iamProfileCrn: (optional) the CRN of the trusted profile to use
|
|
44
|
+
* - iamProfileName: (optional) the name of the trusted profile to use (must be specified with iamAccountId)
|
|
45
|
+
* - iamAccountId: (optional) the ID of the account the trusted profile is in (must be specified with iamProfileName)
|
|
46
|
+
* - url: (optional) the endpoint URL for the IAM token service (default value: "https://iam.cloud.ibm.com")
|
|
47
|
+
* - disableSslVerification: (optional) a flag that indicates whether verification of the token server's SSL certificate
|
|
48
|
+
* should be disabled or not
|
|
49
|
+
* - headers: (optional) a set of HTTP headers to be sent with each request to the token service
|
|
50
|
+
* - clientId: (optional) the "clientId" and "clientSecret" fields are used to form a Basic
|
|
51
|
+
* Authorization header to be included in each request to the token service
|
|
52
|
+
* - clientSecret: (optional) the "clientId" and "clientSecret" fields are used to form a Basic
|
|
53
|
+
* Authorization header to be included in each request to the token service
|
|
54
|
+
* - scope: (optional) the "scope" parameter to use when fetching the bearer token from the token service
|
|
55
|
+
*
|
|
56
|
+
* @throws Error: the configuration options are not valid.
|
|
57
|
+
*/
|
|
58
|
+
constructor(options) {
|
|
59
|
+
super(options);
|
|
60
|
+
this.requiredOptions = ['apikey'];
|
|
61
|
+
// This just verifies that the API key is provided and is free of common issues.
|
|
62
|
+
validateInput(options, this.requiredOptions);
|
|
63
|
+
// This validates the assume-specific fields.
|
|
64
|
+
// Only one of the following three options may be specified.
|
|
65
|
+
if (!onlyOne(options.iamProfileId, options.iamProfileCrn, options.iamProfileName)) {
|
|
66
|
+
throw new Error('Exactly one of `iamProfileName`, `iamProfileCrn`, or `iamProfileId` must be specified.');
|
|
67
|
+
}
|
|
68
|
+
// `iamAccountId` may only be specified if `iamProfileName` is also specified.
|
|
69
|
+
if (Boolean(options.iamProfileName) !== Boolean(options.iamAccountId)) {
|
|
70
|
+
throw new Error('`iamProfileName` and `iamAccountId` must be provided together, or not at all.');
|
|
71
|
+
}
|
|
72
|
+
// Set class variables from options. If they are 'undefined' in options,
|
|
73
|
+
// they won't be changed, as they are 'undefined' to begin with.
|
|
74
|
+
this.iamProfileId = options.iamProfileId;
|
|
75
|
+
this.iamProfileCrn = options.iamProfileCrn;
|
|
76
|
+
this.iamProfileName = options.iamProfileName;
|
|
77
|
+
this.iamAccountId = options.iamAccountId;
|
|
78
|
+
this.iamDelegate = options.iamDelegate;
|
|
79
|
+
// Create an instance of the IamTokenManager, which will be used to obtain
|
|
80
|
+
// an IAM access token for use in the "assume" token exchange. Most option
|
|
81
|
+
// names are shared between these token manager, and extraneous options will
|
|
82
|
+
// be ignored, so we can pass the options structure to that constructor as-is.
|
|
83
|
+
this.iamDelegate = new IamTokenManager(options);
|
|
84
|
+
// These options are used by the delegate token manager
|
|
85
|
+
// but they are not supported by this token manager.
|
|
86
|
+
this.clientId = undefined;
|
|
87
|
+
this.clientSecret = undefined;
|
|
88
|
+
this.scope = undefined;
|
|
89
|
+
// Set the grant type and user agent for this flavor of authentication.
|
|
90
|
+
this.formData.grant_type = 'urn:ibm:params:oauth:grant-type:assume';
|
|
91
|
+
this.userAgent = buildUserAgent('iam-assume-authenticator');
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Request an IAM token using a standard access token and a trusted profile.
|
|
95
|
+
*/
|
|
96
|
+
requestToken() {
|
|
97
|
+
const _super = Object.create(null, {
|
|
98
|
+
requestToken: { get: () => super.requestToken }
|
|
99
|
+
});
|
|
100
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
+
// First, retrieve a standard IAM access token from the delegate and set it in the form data.
|
|
102
|
+
this.formData.access_token = yield this.iamDelegate.getToken();
|
|
103
|
+
if (this.iamProfileCrn) {
|
|
104
|
+
this.formData.profile_crn = this.iamProfileCrn;
|
|
105
|
+
}
|
|
106
|
+
else if (this.iamProfileId) {
|
|
107
|
+
this.formData.profile_id = this.iamProfileId;
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
this.formData.profile_name = this.iamProfileName;
|
|
111
|
+
this.formData.account = this.iamAccountId;
|
|
112
|
+
}
|
|
113
|
+
return _super.requestToken.call(this);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Extend this method from the parent class to erase the refresh token from
|
|
118
|
+
* the class - we do not want to expose it for IAM Assume authentication.
|
|
119
|
+
*
|
|
120
|
+
* @param tokenResponse - the response object from JWT service request
|
|
121
|
+
*/
|
|
122
|
+
saveTokenInfo(tokenResponse) {
|
|
123
|
+
super.saveTokenInfo(tokenResponse);
|
|
124
|
+
this.refreshToken = undefined;
|
|
125
|
+
}
|
|
126
|
+
// Override the inherited "setters". This token manager does not store these options
|
|
127
|
+
// but they can adjust properties on the stored IAM delegate.
|
|
128
|
+
/**
|
|
129
|
+
* Sets the IAM "scope" value.
|
|
130
|
+
* This value is sent as the "scope" form parameter in the IAM delegate request.
|
|
131
|
+
*
|
|
132
|
+
* @param scope - a space-separated string that contains one or more scope names
|
|
133
|
+
*/
|
|
134
|
+
setScope(scope) {
|
|
135
|
+
this.iamDelegate.setScope(scope);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Sets the IAM "clientId" and "clientSecret" values for the IAM delegate.
|
|
139
|
+
*
|
|
140
|
+
* @param clientId - the client id.
|
|
141
|
+
* @param clientSecret - the client secret.
|
|
142
|
+
*/
|
|
143
|
+
setClientIdAndSecret(clientId, clientSecret) {
|
|
144
|
+
this.iamDelegate.setClientIdAndSecret(clientId, clientSecret);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Sets the "disableSslVerification" property for the IAM delegate.
|
|
148
|
+
*
|
|
149
|
+
* @param value - the new value for the disableSslVerification property
|
|
150
|
+
*/
|
|
151
|
+
setDisableSslVerification(value) {
|
|
152
|
+
super.setDisableSslVerification(value);
|
|
153
|
+
this.iamDelegate.setDisableSslVerification(value);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Sets the headers to be included in the IAM delegate's requests.
|
|
157
|
+
*
|
|
158
|
+
* @param headers - the set of headers to send with each request to the token server
|
|
159
|
+
*/
|
|
160
|
+
setHeaders(headers) {
|
|
161
|
+
super.setHeaders(headers);
|
|
162
|
+
this.iamDelegate.setHeaders(headers);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
@@ -28,9 +28,9 @@ export interface IamRequestOptions extends JwtTokenManagerOptions {
|
|
|
28
28
|
* class be extended with specific implementations.
|
|
29
29
|
*/
|
|
30
30
|
export declare class IamRequestBasedTokenManager extends JwtTokenManager {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
protected clientId: string;
|
|
32
|
+
protected clientSecret: string;
|
|
33
|
+
protected scope: string;
|
|
34
34
|
protected refreshToken: string;
|
|
35
35
|
protected formData: any;
|
|
36
36
|
/**
|
|
@@ -70,12 +70,6 @@ export declare class IamRequestBasedTokenManager extends JwtTokenManager {
|
|
|
70
70
|
* @param clientSecret - the client secret.
|
|
71
71
|
*/
|
|
72
72
|
setClientIdAndSecret(clientId: string, clientSecret: string): void;
|
|
73
|
-
/**
|
|
74
|
-
* Returns the most recently stored refresh token.
|
|
75
|
-
*
|
|
76
|
-
* @returns the refresh token
|
|
77
|
-
*/
|
|
78
|
-
getRefreshToken(): string;
|
|
79
73
|
/**
|
|
80
74
|
* Extend this method from the parent class to extract the refresh token from
|
|
81
75
|
* the request and save it.
|
|
@@ -96,14 +96,6 @@ export class IamRequestBasedTokenManager extends JwtTokenManager {
|
|
|
96
96
|
logger.warn(CLIENT_ID_SECRET_WARNING);
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
/**
|
|
100
|
-
* Returns the most recently stored refresh token.
|
|
101
|
-
*
|
|
102
|
-
* @returns the refresh token
|
|
103
|
-
*/
|
|
104
|
-
getRefreshToken() {
|
|
105
|
-
return this.refreshToken;
|
|
106
|
-
}
|
|
107
99
|
/**
|
|
108
100
|
* Extend this method from the parent class to extract the refresh token from
|
|
109
101
|
* the request and save it.
|
|
@@ -19,8 +19,8 @@ interface Options extends IamRequestOptions {
|
|
|
19
19
|
apikey: string;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
* The
|
|
23
|
-
* the IAM token service to obtain and store a suitable bearer token. Additionally, the
|
|
22
|
+
* The IamTokenManager takes an api key and performs the necessary interactions with
|
|
23
|
+
* the IAM token service to obtain and store a suitable bearer token. Additionally, the IamTokenManager
|
|
24
24
|
* will retrieve bearer tokens via basic auth using a supplied "clientId" and "clientSecret" pair.
|
|
25
25
|
*/
|
|
26
26
|
export declare class IamTokenManager extends IamRequestBasedTokenManager {
|
|
@@ -46,5 +46,11 @@ export declare class IamTokenManager extends IamRequestBasedTokenManager {
|
|
|
46
46
|
* @throws Error: the configuration options are not valid.
|
|
47
47
|
*/
|
|
48
48
|
constructor(options: Options);
|
|
49
|
+
/**
|
|
50
|
+
* Returns the most recently stored refresh token.
|
|
51
|
+
*
|
|
52
|
+
* @returns the refresh token
|
|
53
|
+
*/
|
|
54
|
+
getRefreshToken(): string;
|
|
49
55
|
}
|
|
50
56
|
export {};
|
|
@@ -17,8 +17,8 @@ import { validateInput } from '../utils/helpers';
|
|
|
17
17
|
import { buildUserAgent } from '../../lib/build-user-agent';
|
|
18
18
|
import { IamRequestBasedTokenManager } from './iam-request-based-token-manager';
|
|
19
19
|
/**
|
|
20
|
-
* The
|
|
21
|
-
* the IAM token service to obtain and store a suitable bearer token. Additionally, the
|
|
20
|
+
* The IamTokenManager takes an api key and performs the necessary interactions with
|
|
21
|
+
* the IAM token service to obtain and store a suitable bearer token. Additionally, the IamTokenManager
|
|
22
22
|
* will retrieve bearer tokens via basic auth using a supplied "clientId" and "clientSecret" pair.
|
|
23
23
|
*/
|
|
24
24
|
export class IamTokenManager extends IamRequestBasedTokenManager {
|
|
@@ -52,4 +52,12 @@ export class IamTokenManager extends IamRequestBasedTokenManager {
|
|
|
52
52
|
this.formData.response_type = 'cloud_iam';
|
|
53
53
|
this.userAgent = buildUserAgent('iam-authenticator');
|
|
54
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Returns the most recently stored refresh token.
|
|
57
|
+
*
|
|
58
|
+
* @returns the refresh token
|
|
59
|
+
*/
|
|
60
|
+
getRefreshToken() {
|
|
61
|
+
return this.refreshToken;
|
|
62
|
+
}
|
|
55
63
|
}
|
|
@@ -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, JwtTokenManagerOptions } from './jwt-token-manager';
|
|
|
42
43
|
export { TokenManager, TokenManagerOptions } 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';
|