パッケージの詳細

ibm-cloud-sdk-core

IBM1.2mApache-2.05.3.2

Core functionality to support SDKs generated with IBM's OpenAPI SDK Generator.

ibm, sdk, openapi, core

readme

Build Status npm-version semantic-release CLA assistant

IBM Node.js SDK Core

This project contains core functionality required by Node.js code generated by the IBM Cloud OpenAPI SDK Generator (openapi-sdkgen).

Installation

`npm install ibm-cloud-sdk-core`

Prerequisites

  • Node.js version 18 or newer

Usage

This package exports a single object containing a number of modules as top level properties.

Example:

// this is TypeScript, since the `openapi-sdkgen` project generates TypeScript
import { BaseService } from 'ibm-cloud-sdk-core';

class YourSDK extends BaseService { ... }

Authentication

The node-sdk-core project supports the following types of authentication:

  • Basic Authentication
  • Bearer Token Authentication
  • Identity and Access Management (IAM) Authentication (grant type: apikey)
  • Identity and Access Management (IAM) Authentication (grant type: assume)
  • Container Authentication
  • VPC Instance Authentication
  • Cloud Pak for Data Authentication
  • No Authentication (for testing)

There are two ways to create an authenticator:

  1. Creating an instance and providing credentials programmatically
  2. Using the getAuthenticatorFromEnvironment function to create an authenticator from externally-provided configuration

For more information about the various authentication types and how to use them with your services, click here.

Examples

Programmatic

import { IamAuthenticator } from 'ibm-cloud-sdk-core';

const authenticator = new IamAuthenticator({
  apikey: '{apikey}',
});

External configuration

import { getAuthenticatorFromEnvironment } from 'ibm-cloud-sdk-core';

// env vars
// MY_SERVICE_AUTH_TYPE=iam
// MY_SERVICE_APIKEY=<apikey>
const iamAuthenticator = getAuthenticatorFromEnvironment('my-service');

Logging

This package uses debug for logging.

  • Logging is disabled by default.
  • Logging has been configured to use log levels which are assumed to be numerically ascending from most important to least important.
  • In order to see the log output, set the environment variable DEBUG including the desired log level.
    • DEBUG=ibm-cloud-sdk-core:error enables error logs
    • DEBUG=ibm-cloud-sdk-core:warning enables warning logs and below
    • DEBUG=ibm-cloud-sdk-core:info enables info logs and below
    • DEBUG=ibm-cloud-sdk-core:verbose enables verbose logs and below
    • DEBUG=ibm-cloud-sdk-core:debug enables debug logs and below

To see the output from all of the debugging levels you can use:

DEBUG=ibm-cloud-sdk-core*

The debug logger can be configured to be used for more than one library. For example, you can set a comma-separated string:

DEBUG=ibm-cloud-sdk-core:debug,other-lib:debug

Cookie Jar Support

By default, cookies are not supported in the SDK requests. If your SDK would benefit from this functionality, simply edit your code to instantiate a cookie jar (or instruct your users to do so) and pass it in the object containing configuration options to the BaseService class, as shown below. If the Boolean value true is given for the jar field, the SDK core will create a default instance of a Tough Cookie.

import tough = require('tough-cookie');

class MyClass extends BaseService {
  constructor(options: MyOptions) {
    // pass the cookie jar object or simply pass the value `true`
    // and a tough-cookie instance will be created by default
    options.jar = new tough.CookieJar();
    super(options);
  }
}

Issues

If you encounter an issue with this project, you are welcome to submit a bug report. Before opening a new issue, please search for similar issues. It's possible that someone has already reported it.

Tests

Run all test suites:

npm test

Contributing

See CONTRIBUTING.

License

This library is licensed under Apache 2.0. Full license text is available in LICENSE.

更新履歴

5.3.2 (2025-03-10)

Bug Fixes

  • downgrade node types to align with minimum supported node version (#301) (519d516)

5.3.1 (2025-03-10)

Bug Fixes

5.3.0 (2025-03-07)

Features

  • ContainerAuthenticator: add support for code engine workload (#296) (f8e2b43)

5.2.0 (2025-03-06)

Features

  • add support for accepting axios options in sendRequest (#299) (ddd81aa)

5.1.4 (2025-03-05)

Bug Fixes

  • update node types to align with required node versions (#298) (c4d67d7)

5.1.3 (2025-02-17)

Bug Fixes

5.1.2 (2025-01-29)

Bug Fixes

  • deps: update axios to resolve vulnerability (#292) (9838134)

5.1.1 (2025-01-10)

Bug Fixes

  • enable github workflows (dda9ef1)

5.1.0 (2024-10-15)

Features

  • IamAssumeAuthenticator: add new authentication type for iam assume (#287) (addebfc)

5.0.2 (2024-09-03)

Bug Fixes

  • logging: improve node core's debug logging (#286) (7bcb404)

5.0.1 (2024-08-14)

Bug Fixes

  • deps: update axios to resolve vulnerability (#282) (83d9473)
  • deps: update axios to resolve vulnerability (#283) (3500bf2)

5.0.0 (2024-06-18)

Bug Fixes

  • remove test utilities and dependency from package (901ece0)

Build System

  • bump minimum node version to v18 (3d8fef5)

BREAKING CHANGES

  • SDK test helpers are no longer exposed in this package.

To continue using the test helpers, which SDK unit tests still rely on, install the new "@ibm-cloud/sdk-test-utilities" package as a development dependency.

Signed-off-by: Dustin Popp dustinpopp@ibm.com

  • Node v18 or above is now required to use this package.

Signed-off-by: Dustin Popp dustinpopp@ibm.com

4.3.3 (2024-06-04)

Bug Fixes

  • revert "fix(deps): remove expect as redundant development dependency" (362e20a)

4.3.2 (2024-06-03)

Bug Fixes

  • deps: remove expect as redundant development dependency (b57b491)

4.3.1 (2024-05-21)

Bug Fixes

  • deps: bump braces and micromatch to avoid vulnerabilities (#274) (1ecac01)

4.3.0 (2024-04-17)

Features

  • send user-agent header with auth token requests (#272) (a558274)

4.2.5 (2024-03-29)

Bug Fixes

  • deps: update axios to resolve vulnerability (#269) (4a2c7a5)

4.2.4 (2024-02-28)

Bug Fixes

4.2.3 (2024-02-01)

Bug Fixes

  • token-manager: handle request errors when refreshing tokens (#267) (2909804)

4.2.2 (2024-01-04)

Bug Fixes

4.2.1 (2024-01-02)

Bug Fixes

  • deps: bump axios to 1.6.3 to avoid ReDOS vulnerability (#263) (b08f9de)

4.2.0 (2023-11-15)

Features

  • McspAuthenticator: add new authenticator for Multi-Cloud Saas Platform (#258) (4fe7f71)

4.1.5 (2023-11-13)

Bug Fixes

4.1.4 (2023-10-31)

Bug Fixes

  • deps: resolve vulnerability in axios version (#256) (9bc0358)

4.1.3 (2023-10-19)

Bug Fixes

  • bump @babel/traverse to avoid CVE-2023-45133 (#253) (c95f5b2)

4.1.2 (2023-09-27)

Bug Fixes

  • harden checks for cookies in error responses (#252) (36f7bfe)

4.1.1 (2023-09-20)

Bug Fixes

4.1.0 (2023-07-06)

Features

  • add logic for serializing/deserializing model objects (#247) (2397eae)

4.0.9 (2023-06-22)

Bug Fixes

4.0.8 (2023-05-22)

Bug Fixes

  • refresh dependencies and address import cycles (#244) (72aa8d5)

4.0.7 (2023-05-22)

Bug Fixes

  • ContainerAuthenticator: add sa-token as default CR token filename (#241) (91f9932)

4.0.6 (2023-05-18)

Bug Fixes

  • use consistent message for JSON.parse() errors (#243) (3cc7bab)

4.0.5 (2023-03-01)

Bug Fixes

  • correctly handle empty response bodies (#239) (d0c9cb3)

4.0.4 (2023-02-27)

Bug Fixes

  • return json error response body as object (#238) (6f201b7)

4.0.3 (2023-01-09)

Bug Fixes

  • VpcInstanceAuthenticator: use correct version string (4a1411a)

4.0.2 (2022-12-30)

Bug Fixes

  • auth: revert to using decode instead verify for jwt (#227) (cf3d641)

4.0.1 (2022-12-29)

Bug Fixes

  • auth: migrate to secure usage of jwt for token authentication (#225) (10e0728)

4.0.0 (2022-12-20)

Bug Fixes

  • axios 1.x in request-wrapper (9ba195b)

Build System

  • deps-dev: update typescript to 4.9.4 (1764e22)

Features

  • update minimum Node.js version to 14 (5021118)

BREAKING CHANGES

  • deps-dev: Minimum typescript version is 4. Upgrade to typescript 4.x.

  • Minimum Node.js version is 14. Upgrade to at least Node.js 14.

  • For assistance migrating to v4 - see the migration guide.

3.2.1 (2022-10-21)

Bug Fixes

  • allow for synchronous building of file requests (#211) (dcce4ea)

3.2.0 (2022-10-12)

Features

  • add method getNewLogger to public API (#210) (07b99de)

3.1.0 (2022-07-28)

Features

  • add setDefaultHeaders method on base service class (#207) (29bec13)

3.0.1 (2022-07-28)

Bug Fixes

3.0.0 (2022-07-28)

Bug Fixes

BREAKING CHANGES

  • two synchronous public functions are now asynchronous

The function getContentType formerly returned a string but now returns a Promise that resolves to a string. The function buildRequestFileObject formerly returned a FileObject but now returns a Promise that resolves to a FileObject.

2.17.15 (2022-07-05)

Bug Fixes

  • ensure dist/docs is a directory during build (#202) (1b3ef62)

2.17.14 (2022-05-02)

Bug Fixes

2.17.13 (2022-04-04)

Bug Fixes

  • bump dependencies to avoid minimist vulnerability (#195) (4de8a9d)

2.17.12 (2022-03-16)

Bug Fixes

  • update minimum Node version in package.json (#192) (dfbebee)

2.17.11 (2022-03-16)

Bug Fixes

  • update axios to remove vulnerability (90e0417)
  • use correct type for cookie jar option (59a440a)

2.17.10 (2022-02-10)

Bug Fixes

2.17.9 (2022-01-19)

Bug Fixes

  • bump version of follow-redirects to avoid vulnerability (#189) (b88c67a)

2.17.8 (2022-01-18)

Bug Fixes

  • avoid errors during logging of requests/responses (#188) (d05ea1a)

2.17.7 (2022-01-14)

Bug Fixes

  • remove 'module' entry from package.json (#187) (3a0aea5)

2.17.6 (2022-01-05)

Bug Fixes

2.17.5 (2021-12-17)

Bug Fixes

  • avoid Buffer re-encode during compression (#184) (8b82f36)

2.17.4 (2021-12-16)

Bug Fixes

  • don't always convert bytes to text in streamToPromise (#182) (7fe261b)

2.17.3 (2021-12-13)

Bug Fixes

  • bump dependencies to avoid vulnerability alerts (#183) (aef2c6a)

2.17.2 (2021-12-08)

Bug Fixes

  • VpcInstanceAuthenticator: omit request body for default profile scenario (#181) (1e3fb2d)

2.17.1 (2021-12-06)

Bug Fixes

2.17.0 (2021-11-08)

Features

  • VpcInstanceAuthenticator: add support for new VPC authentication flow (#172) (8bbe704)

2.16.0 (2021-10-20)

Features

  • add support for retrieving refresh tokens from iam-based authenticators (#173) (e7f11fc)

2.15.1 (2021-10-15)

Bug Fixes

  • use correct authenticator type constants (#170) (ae19adc)

2.15.0 (2021-10-15)

Features

  • add authenticationType method to authenticators (#169) (2850c4f)

2.14.4 (2021-09-22)

Bug Fixes

2.14.3 (2021-09-09)

Bug Fixes

2.14.2 (2021-09-09)

Bug Fixes

  • build: bump axios to 0.21.4 to avoid vulnerabilities (#160) (12a6c5b)

2.14.1 (2021-08-31)

Performance Improvements

  • use maxContentLength -1 instead of Infinity (#158) (adbbb3b)

2.14.0 (2021-08-27)

Features

  • add enableRetries and disableRetries (#156) (d6f12e7)

2.13.0 (2021-08-18)

Features

  • add method getHttpClient to get underlying axios instance of base service (#155) (2aede01)

2.12.2 (2021-08-13)

Bug Fixes

  • support 'AUTHTYPE' as alias for 'AUTH_TYPE' config property (#153) (fccf209)

2.12.1 (2021-08-11)

Bug Fixes

  • use typescript 3.8.x to build the published code (#152) (4362a37)

2.12.0 (2021-08-10)

Features

  • add support for new ContainerAuthenticator (#151) (b01c011)

2.11.3 (2021-06-14)

Bug Fixes

  • build: revert inadvertently-committed directories (#147) (1fb6295)

2.11.2 (2021-06-10)

Bug Fixes

  • remove default limit on request body length (#145) (abf604a)

2.11.1 (2021-06-07)

Bug Fixes

  • change constructServiceURL from method to function (#141) (cd2d28c)

2.11.0 (2021-05-27)

Features

  • add BaseService.constructServiceURL method (#138) (0e73bde)

2.10.4 (2021-05-10)

Bug Fixes

2.10.3 (2021-04-01)

Bug Fixes

  • stub sdk-test-helpers in browser environments (#132) (006991b)

2.10.2 (2021-03-31)

Bug Fixes

  • deps: update dependencies to avoid vulnerabilities (#131) (b931472)

2.10.1 (2021-03-16)

Bug Fixes

  • enable symbolic-link credentials files (#129) (4b87d42)

2.10.0 (2021-03-13)

Features

  • add getQueryParam utility method to support pagination (#128) (d4f067a)

2.9.0 (2021-03-12)

Features

  • support username/apikey use-case in CloudPakForDataAuthenticator (#126) (a7ca3a0)

2.8.2 (2021-03-12)

Bug Fixes

  • persist enableGzipCompression setting on the base service (#127) (1398044)

2.8.1 (2021-03-09)

Bug Fixes

2.8.0 (2021-02-19)

Features

  • iam-authenticator: expose refresh token with a getter - getRefreshToken() (#122) (d3c4611)

2.7.2 (2021-02-10)

Bug Fixes

2.7.1 (2021-01-07)

Bug Fixes

  • build: upgrade semantic-release to latest (17.3.1) (#120) (3e3c099)
  • change description inside package.json (#119) (30aeda9)

2.7.0 (2020-10-06)

Features

  • add support for compressing request bodies (#111) (7692d71)

2.6.0 (2020-09-25)

Features

  • upgrade axios and re-enable gzipping responses (#110) (9e94251)

2.5.0 (2020-09-18)

Features

  • IAM Authenticator: add support for optional 'scope' property (#109) (1c258b7)

2.4.5 (2020-08-12)

Bug Fixes

2.4.4 (2020-08-06)

Bug Fixes

  • use extend with deep copy where necessary (#106) (566b81f)

2.4.3 (2020-08-05)

Bug Fixes

  • support disableSslVerification when user provides custom httpsAgent (#104) (ef39327)

2.4.2 (2020-07-22)

Bug Fixes

  • move test utilities to lib/ and rely directly on expect (#101) (57ca4c2)

2.4.1 (2020-05-14)

Bug Fixes

  • Remove trailing slash from url for extra cases (#95) (bcaa168)

2.4.0 (2020-05-05)

Features

  • token-manager: Introduce a token-manager class for token handling (#89) (23c5f3f)

2.3.2 (2020-05-04)

Bug Fixes

  • flag required params as missing when explicitly undefined, null, or an empty string (#90) (414b674)

2.3.1 (2020-05-01)

Bug Fixes

  • Strip trailing slashes in sendRequest (#92) (3d8f568)

2.3.0 (2020-03-23)

Features

2.2.0 (2020-03-05)

Features

  • Pace requests to token server for new auth tokens (#83) (b14dc4e)

2.1.0 (2020-02-14)

Features

  • Pace token refresh requests to avoid rate-limiting (#79) (d908c0d)

2.0.4 (2020-01-30)

Bug Fixes

  • use consistent fields between success and error response objects (#78) (902d712)

2.0.3 (2020-01-16)

Bug Fixes

  • use constant defined by generated sdks for url (#77) (cb3cc81)

2.0.2 (2020-01-09)

Bug Fixes

  • export unitTestUtils functions as a module (#76) (a148da9)

2.0.1 (2019-12-06)

Bug Fixes

2.0.0 (2019-11-19)

Features

  • changes to node-sdk-core to work with service factory feature (#72) (cde4cd6)

BREAKING CHANGES

  • The BaseService will no longer look for configurations externally by default. A new factory method is provided to create an instance from external configuration.

  • feat: changes to node-sdk-core to work with service factory feature

  • BaseService constructor will no longer call configureService.

  • updated test to reflect base service constructor does not call configureService

  • added test for getting credentials from vcap

  • removed name and serviceVersion because they are not referenced anymore

  • added comment for vcap parsing function. removed vcap_services dependency

  • added debug messages for when returning empty credential

1.3.0 (2019-10-22)

Features

  • adding configureService method for external config options (#66) (7324919)

1.2.0 (2019-10-15)

Features

  • export unit test utility methods to be used in SDKs (#65) (0305974)

1.1.0 (2019-10-14)

Features

1.0.0 (2019-10-03)

Bug Fixes

  • Move check for serviceUrl to createRequest (#47) (6f04739)
  • parse result from response in token managers (6bbe423)
  • provide bundlers alternate file for browser support (#58) (88a9d16)

Build System

  • drop support for Node versions 6 and 8 (#33) (d47c737)

Code Refactoring

  • look for credentials file in working dir before home dir (#46) (c5556de)
  • return detailed response as second callback argument (#34) (dc24154)

Features

  • add setServiceUrl method as a setter for the serviceUrl property (#41) (cfb188f)
  • add specific error handling for SSL errors with cloud private instances (#54) (056ec9a)
  • export UserOptions interface from the BaseService (#50) (4f0075a)
  • implement new authenticators to handle sdk authentication (#37) (f876b6d)
  • refactor core to use Promises instead of callbacks (#55) (9ec8afd)

BREAKING CHANGES

  • None of the authenticators or request methods take callbacks as arguments anymore - they return Promises instead.
  • Users that have credential files in both the working directory and the home directory will see a change in which one is used.
  • The internal property url no longer exists on the baseOptions object, it has been renamed to serviceUrl
  • The old style of passing credentials to the base service will no longer work. An Authenticator instance MUST be passed in to the base service constructor.
  • token managers no longer support user access tokens. use BearerTokenAuthenticator instead
  • The class names of the token managers have changed.
  • Icp4dTokenManagerV1 renamed to Cp4dTokenManager
  • IamTokenManagerV1 renamed to IamTokenManager
  • JwtTokenManagerV1 renamed to JwtTokenManager
  • The public method setAuthorizationInfo is renamed to setClientIdAndSecret
  • The response body is no longer the 2nd callback argument, the detailed response is. The body is located under the result property. The data property is removed.
  • This SDK may no longer work with applications running on Node 6 or 8.

0.3.6 (2019-09-16)

Bug Fixes

  • Fix handling of array form parameters. (#43) (bad8960)

0.3.5 (2019-08-07)

Bug Fixes

  • share service request wrapper instance with token managers (#36) (e7609e2)

0.3.4 (2019-08-05)

Bug Fixes

  • extend constructor options type to allow additional properties (#35) (70af0c9)

0.3.3 (2019-07-17)

Bug Fixes

  • add deprecation notice for node versions 6 and 8 (#32) (9e3c667)

0.3.2 (2019-06-23)

Bug Fixes

  • read iam client id and secret from environment variables (#30) (2247d0a)

0.3.1 (2019-06-06)

Bug Fixes

  • expose the body in the detailed response under the field result (f4aa4f9)

0.3.0 (2019-06-05)

Features

  • add IcpTokenManagerV1 as a top-level export of the package (cfa3e1b)
  • add new token manager for ICP4D (ee1ddad)
  • add new token manager for ICP4D (#26) (2097a64)
  • carry disable_ssl_verification through to token managers (4f2f789)

0.2.8 (2019-05-30)

Bug Fixes

  • default request body size to Infinity (6cea2b9)

0.2.7 (2019-05-24)

Bug Fixes

  • remove node request objects from detailed response (9ac5673)
  • remove node request objects from detailed response (#25) (192d8cf)

0.2.6 (2019-05-21)

Bug Fixes

  • temporarily disable gzipping until axios bug fix is released (b26a310)

0.2.5 (2019-05-15)

Bug Fixes

  • allow users to debug axios traffic (fd41509)

0.2.4 (2019-05-07)

Bug Fixes

  • IAM: renamed UserOptions iam_secret to iam_client_secret to be consistent with other cores (f755c9c)

0.2.3 (2019-05-07)

Bug Fixes

  • do not read credentials file in webpack override scenario (9af4567)
  • do not read credentials file in webpack override scenario (#19) (ec64ae1)

0.2.2 (2019-05-01)

Bug Fixes

  • carry user options from constructor to axios parameters (65d55ec)

0.2.1 (2019-04-29)

Bug Fixes

  • allow iam client id and secret to be read from constructor (#17) (3c88edb)

0.2.0 (2019-04-19)

Features

  • allow IAM clientid/secret to be configured (#14) (ff8f2e7)