Socket
Socket
Sign inDemoInstall

ibm-cloud-sdk-core

Package Overview
Dependencies
Maintainers
0
Versions
143
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ibm-cloud-sdk-core - npm Package Compare versions

Comparing version 5.0.1 to 5.0.2

es/lib/private-helpers.d.ts

2

auth/authenticators/basic-authenticator.d.ts
/**
* (C) Copyright IBM Corp. 2019, 2023.
* (C) Copyright IBM Corp. 2019, 2024.
*

@@ -4,0 +4,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

"use strict";
/**
* (C) Copyright IBM Corp. 2019, 2023.
* (C) Copyright IBM Corp. 2019, 2024.
*

@@ -40,2 +40,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var authenticator_1 = require("./authenticator");
var logger_1 = __importDefault(require("../../lib/logger"));
/**

@@ -83,2 +84,3 @@ * The BasicAuthenticator is used to add basic authentication information to

requestOptions.headers = (0, extend_1.default)(true, {}, requestOptions.headers, _this.authHeader);
logger_1.default.debug("Authenticated outbound request (type=".concat(_this.authenticationType(), ")"));
resolve();

@@ -85,0 +87,0 @@ });

@@ -40,2 +40,3 @@ "use strict";

var authenticator_1 = require("./authenticator");
var logger_1 = __importDefault(require("../../lib/logger"));
/**

@@ -88,2 +89,3 @@ * The BearerTokenAuthenticator will set a user-provided bearer token

requestOptions.headers = (0, extend_1.default)(true, {}, requestOptions.headers, authHeader);
logger_1.default.debug("Authenticated outbound request (type=".concat(_this.authenticationType(), ")"));
resolve();

@@ -90,0 +92,0 @@ });

@@ -40,2 +40,3 @@ "use strict";

var authenticator_1 = require("./authenticator");
var logger_1 = __importDefault(require("../../lib/logger"));
/**

@@ -109,5 +110,7 @@ * Class for common functionality shared by token-request authenticators.

TokenRequestBasedAuthenticator.prototype.authenticate = function (requestOptions) {
var _this = this;
return this.tokenManager.getToken().then(function (token) {
var authHeader = { Authorization: "Bearer ".concat(token) };
requestOptions.headers = (0, extend_1.default)(true, {}, requestOptions.headers, authHeader);
logger_1.default.debug("Authenticated outbound request (type=".concat(_this.authenticationType(), ")"));
});

@@ -114,0 +117,0 @@ };

@@ -41,2 +41,3 @@ "use strict";

var jwt_token_manager_1 = require("./jwt-token-manager");
var logger_1 = __importDefault(require("../../lib/logger"));
/**

@@ -103,3 +104,7 @@ * Token Manager of CloudPak for data.

};
return this.requestWrapperInstance.sendRequest(parameters);
logger_1.default.debug("Invoking CP4D token service operation: ".concat(parameters.options.url));
return this.requestWrapperInstance.sendRequest(parameters).then(function (response) {
logger_1.default.debug('Returned from CP4D token service operation');
return response;
});
};

@@ -106,0 +111,0 @@ return Cp4dTokenManager;

@@ -171,3 +171,7 @@ "use strict";

};
return this.requestWrapperInstance.sendRequest(parameters);
logger_1.default.debug("Invoking IAM get_token operation: ".concat(parameters.options.url));
return this.requestWrapperInstance.sendRequest(parameters).then(function (response) {
logger_1.default.debug('Returned from IAM get_token operation');
return response;
});
};

@@ -174,0 +178,0 @@ /**

@@ -41,2 +41,3 @@ "use strict";

var jwt_token_manager_1 = require("./jwt-token-manager");
var logger_1 = __importDefault(require("../../lib/logger"));
/**

@@ -94,3 +95,7 @@ * This is the path associated with the operation used to obtain

};
return this.requestWrapperInstance.sendRequest(parameters);
logger_1.default.debug("Invoking MCSP token service operation: ".concat(parameters.options.url));
return this.requestWrapperInstance.sendRequest(parameters).then(function (response) {
logger_1.default.debug('Returned from MCSP token service operation');
return response;
});
};

@@ -97,0 +102,0 @@ return McspTokenManager;

@@ -52,7 +52,9 @@ "use strict";

if (!this.accessToken || this.isTokenExpired()) {
// 1. request a new token
// 1. Need a new token.
logger_1.default.debug('Performing synchronous token refresh');
return this.pacedRequestToken().then(function () { return _this.accessToken; });
}
// If refresh needed, kick one off
if (this.tokenNeedsRefresh()) {
// 2. Need to refresh the current (valid) token.
logger_1.default.debug('Performing background asynchronous token fetch');
this.requestToken().then(function (tokenResponse) {

@@ -71,3 +73,5 @@ _this.saveTokenInfo(tokenResponse);

}
// 2. use valid, managed token
else {
logger_1.default.debug('Using cached access token');
}
return Promise.resolve(this.accessToken);

@@ -74,0 +78,0 @@ };

@@ -165,3 +165,6 @@ "use strict";

logger_1.default.debug("Invoking VPC 'create_iam_token' operation: ".concat(parameters.options.url));
return [2 /*return*/, this.requestWrapperInstance.sendRequest(parameters)];
return [2 /*return*/, this.requestWrapperInstance.sendRequest(parameters).then(function (response) {
logger_1.default.debug("Returned from VPC 'create_iam_token' operation");
return response;
})];
}

@@ -168,0 +171,0 @@ });

@@ -51,2 +51,3 @@ "use strict";

var properties = null;
logger_1.default.debug("Retrieving config properties for service '".concat(serviceName, "'"));
properties = filterPropertiesByServiceName((0, file_reading_helpers_1.readCredentialsFile)(), serviceName);

@@ -59,2 +60,3 @@ if ((0, helper_1.isEmptyObject)(properties)) {

}
logger_1.default.debug("Retrieved ".concat(Object.keys(properties).length, " properties"));
return properties;

@@ -61,0 +63,0 @@ }

@@ -0,1 +1,8 @@

## [5.0.2](https://github.com/IBM/node-sdk-core/compare/v5.0.1...v5.0.2) (2024-09-03)
### Bug Fixes
* **logging:** improve node core's debug logging ([#286](https://github.com/IBM/node-sdk-core/issues/286)) ([7bcb404](https://github.com/IBM/node-sdk-core/commit/7bcb404fa88592079571149c4b4224f97798f47d))
## [5.0.1](https://github.com/IBM/node-sdk-core/compare/v5.0.0...v5.0.1) (2024-08-14)

@@ -2,0 +9,0 @@

/**
* (C) Copyright IBM Corp. 2019, 2023.
* (C) Copyright IBM Corp. 2019, 2024.
*

@@ -4,0 +4,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

/**
* (C) Copyright IBM Corp. 2019, 2023.
* (C) Copyright IBM Corp. 2019, 2024.
*

@@ -19,2 +19,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

import { Authenticator } from './authenticator';
import logger from '../../lib/logger';
/**

@@ -59,2 +60,3 @@ * The BasicAuthenticator is used to add basic authentication information to

requestOptions.headers = extend(true, {}, requestOptions.headers, this.authHeader);
logger.debug(`Authenticated outbound request (type=${this.authenticationType()})`);
resolve();

@@ -61,0 +63,0 @@ });

@@ -19,2 +19,3 @@ /**

import { Authenticator } from './authenticator';
import logger from '../../lib/logger';
/**

@@ -64,2 +65,3 @@ * The BearerTokenAuthenticator will set a user-provided bearer token

requestOptions.headers = extend(true, {}, requestOptions.headers, authHeader);
logger.debug(`Authenticated outbound request (type=${this.authenticationType()})`);
resolve();

@@ -66,0 +68,0 @@ });

@@ -19,2 +19,3 @@ /**

import { Authenticator } from './authenticator';
import logger from '../../lib/logger';
/**

@@ -89,4 +90,5 @@ * Class for common functionality shared by token-request authenticators.

requestOptions.headers = extend(true, {}, requestOptions.headers, authHeader);
logger.debug(`Authenticated outbound request (type=${this.authenticationType()})`);
});
}
}

@@ -20,2 +20,3 @@ /**

import { JwtTokenManager } from './jwt-token-manager';
import logger from '../../lib/logger';
/**

@@ -80,4 +81,8 @@ * Token Manager of CloudPak for data.

};
return this.requestWrapperInstance.sendRequest(parameters);
logger.debug(`Invoking CP4D token service operation: ${parameters.options.url}`);
return this.requestWrapperInstance.sendRequest(parameters).then((response) => {
logger.debug('Returned from CP4D token service operation');
return response;
});
}
}

@@ -147,3 +147,7 @@ /**

};
return this.requestWrapperInstance.sendRequest(parameters);
logger.debug(`Invoking IAM get_token operation: ${parameters.options.url}`);
return this.requestWrapperInstance.sendRequest(parameters).then((response) => {
logger.debug('Returned from IAM get_token operation');
return response;
});
}

@@ -150,0 +154,0 @@ /**

@@ -20,2 +20,3 @@ /**

import { JwtTokenManager } from './jwt-token-manager';
import logger from '../../lib/logger';
/**

@@ -71,4 +72,8 @@ * This is the path associated with the operation used to obtain

};
return this.requestWrapperInstance.sendRequest(parameters);
logger.debug(`Invoking MCSP token service operation: ${parameters.options.url}`);
return this.requestWrapperInstance.sendRequest(parameters).then((response) => {
logger.debug('Returned from MCSP token service operation');
return response;
});
}
}

@@ -45,7 +45,9 @@ /* eslint-disable @typescript-eslint/no-unused-vars, class-methods-use-this */

if (!this.accessToken || this.isTokenExpired()) {
// 1. request a new token
// 1. Need a new token.
logger.debug('Performing synchronous token refresh');
return this.pacedRequestToken().then(() => this.accessToken);
}
// If refresh needed, kick one off
if (this.tokenNeedsRefresh()) {
// 2. Need to refresh the current (valid) token.
logger.debug('Performing background asynchronous token fetch');
this.requestToken().then((tokenResponse) => {

@@ -64,3 +66,5 @@ this.saveTokenInfo(tokenResponse);

}
// 2. use valid, managed token
else {
logger.debug('Using cached access token');
}
return Promise.resolve(this.accessToken);

@@ -67,0 +71,0 @@ }

@@ -111,3 +111,6 @@ /**

logger.debug(`Invoking VPC 'create_iam_token' operation: ${parameters.options.url}`);
return this.requestWrapperInstance.sendRequest(parameters);
return this.requestWrapperInstance.sendRequest(parameters).then((response) => {
logger.debug(`Returned from VPC 'create_iam_token' operation`);
return response;
});
});

@@ -114,0 +117,0 @@ }

@@ -44,2 +44,3 @@ /* eslint-disable no-restricted-syntax */

let properties = null;
logger.debug(`Retrieving config properties for service '${serviceName}'`);
properties = filterPropertiesByServiceName(readCredentialsFile(), serviceName);

@@ -52,2 +53,3 @@ if (isEmptyObject(properties)) {

}
logger.debug(`Retrieved ${Object.keys(properties).length} properties`);
return properties;

@@ -54,0 +56,0 @@ }

@@ -93,2 +93,3 @@ /**

this.baseOptions.serviceUrl = stripTrailingSlash(url);
logger.debug(`Set service URL: ${this.baseOptions.serviceUrl}`);
}

@@ -168,2 +169,3 @@ }

configureService(serviceName) {
logger.debug(`Configuring BaseService instance with service name: ${serviceName}`);
if (!serviceName) {

@@ -170,0 +172,0 @@ const err = 'Error configuring service. Service name is required.';

/**
* (C) Copyright IBM Corp. 2014, 2023.
* (C) Copyright IBM Corp. 2014, 2024.
*

@@ -36,2 +36,38 @@ * Licensed under the Apache License, Version 2.0 (the "License");

constructor(axiosOptions?: any);
/**
* Formats the specified Axios request for debug logging.
* @param request - the request to be logged
* @returns the string representation of the request
*/
private formatAxiosRequest;
/**
* Formats the specified Axios response for debug logging.
* @param response - the response to be logged
* @returns the string representation of the response
*/
private formatAxiosResponse;
/**
* Formats the specified Axios error for debug logging.
* @param error - the error to be logged
* @returns the string representation of the error
*/
private formatAxiosError;
/**
* Formats 'headers' to be included in the debug output
* like this:
* Accept: application/json
* Content-Type: application/json
* My-Header: my-value
* ...
* @param headers - the headers associated with an Axios request or response
* @returns the formatted output to be included in the HTTP message traces
*/
private formatAxiosHeaders;
/**
* Formats 'body' (either a string or object/array) to be included in the debug output
*
* @param body - a string, object or array that contains the request or response body
* @returns the formatted output to be included in the HTTP message traces
*/
private formatAxiosBody;
setCompressRequestData(setting: boolean): void;

@@ -58,3 +94,9 @@ /**

disableRetries(): void;
/**
* Returns true iff the previously-failed request contained in "error" should be retried.
* @param error - an AxiosError instance that contains a previously-failed request
* @returns true iff the request should be retried
*/
private static retryPolicy;
private gzipRequestBody;
}

@@ -12,3 +12,3 @@ /* eslint-disable class-methods-use-this */

/**
* (C) Copyright IBM Corp. 2014, 2023.
* (C) Copyright IBM Corp. 2014, 2024.
*

@@ -36,2 +36,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

import { buildRequestFileObject, isEmptyObject, isFileData, isFileWithMetadata, isJsonMimeType, stripTrailingSlash, } from './helper';
import { redactSecrets } from './private-helpers';
import logger from './logger';

@@ -91,20 +92,16 @@ import { streamToPromise } from './stream-to-promise';

}
// set debug interceptors
if (process.env.NODE_DEBUG === 'axios' || process.env.DEBUG) {
this.axiosInstance.interceptors.request.use((config) => {
logger.debug('Request:');
logger.debug(config);
return config;
// If debug logging is requested, set up interceptors to log http request/response messages.
if (logger.debug.enabled || process.env.NODE_DEBUG === 'axios') {
this.axiosInstance.interceptors.request.use((request) => {
logger.debug(`--> HTTP Request:\n${this.formatAxiosRequest(request)}`);
return request;
}, (error) => {
logger.error('Error: ');
logger.error(error);
logger.debug(`<-- HTTP Error:\n${this.formatAxiosError(error)}`);
return Promise.reject(error);
});
this.axiosInstance.interceptors.response.use((response) => {
logger.debug('Response:');
logger.debug(response);
logger.debug(`<-- HTTP Response:\n${this.formatAxiosResponse(response)}`);
return response;
}, (error) => {
logger.error('Error: ');
logger.error(error);
logger.debug(`<-- HTTP Error:\n${this.formatAxiosError(error)}`);
return Promise.reject(error);

@@ -114,2 +111,74 @@ });

}
/**
* Formats the specified Axios request for debug logging.
* @param request - the request to be logged
* @returns the string representation of the request
*/
formatAxiosRequest(request) {
const { method, url, data, headers } = request;
const headersOutput = this.formatAxiosHeaders(headers);
const body = this.formatAxiosBody(data);
const output = `${(method || '??').toUpperCase()} ${url || '??'}\n${headersOutput}\n${body}`;
return redactSecrets(output);
}
/**
* Formats the specified Axios response for debug logging.
* @param response - the response to be logged
* @returns the string representation of the response
*/
formatAxiosResponse(response) {
const { status, statusText, headers, data } = response;
const headersOutput = this.formatAxiosHeaders(headers);
const body = this.formatAxiosBody(data);
const statusMsg = statusText || `status_code_${status}`;
const output = `${status} ${statusMsg}\n${headersOutput}\n${body}`;
return redactSecrets(output);
}
/**
* Formats the specified Axios error for debug logging.
* @param error - the error to be logged
* @returns the string representation of the error
*/
formatAxiosError(error) {
const { response } = error;
let output = `HTTP error message=${error.message || ''}, code=${error.code || ''}`;
if (response) {
output = this.formatAxiosResponse(response);
}
return output;
}
/**
* Formats 'headers' to be included in the debug output
* like this:
* Accept: application/json
* Content-Type: application/json
* My-Header: my-value
* ...
* @param headers - the headers associated with an Axios request or response
* @returns the formatted output to be included in the HTTP message traces
*/
formatAxiosHeaders(headers) {
let output = '';
if (headers) {
const lines = [];
Object.keys(headers).forEach((key) => {
lines.push(`${key}: ${headers[key]}`);
});
output = lines.join('\n');
}
return output;
}
/**
* Formats 'body' (either a string or object/array) to be included in the debug output
*
* @param body - a string, object or array that contains the request or response body
* @returns the formatted output to be included in the HTTP message traces
*/
formatAxiosBody(body) {
let output = '';
if (body) {
output = typeof body === 'string' ? body : JSON.stringify(body);
}
return output;
}
setCompressRequestData(setting) {

@@ -300,3 +369,4 @@ this.compressRequestData = setting;

checkRetryAfter: true,
maxRetryDelay: 30 * 1000, // default to 30 sec max delay
maxRetryDelay: 30 * 1000,
shouldRetry: this.retryPolicy,
};

@@ -322,2 +392,3 @@ if (retryOptions) {

this.retryInterceptorId = rax.attach(this.axiosInstance);
logger.debug(`Enabled retries; maxRetries=${this.raxConfig.retry}, maxRetryInterval=${this.raxConfig.maxRetryDelay}`);
}

@@ -329,4 +400,32 @@ disableRetries() {

delete this.raxConfig;
logger.debug('Disabled retries');
}
}
/**
* Returns true iff the previously-failed request contained in "error" should be retried.
* @param error - an AxiosError instance that contains a previously-failed request
* @returns true iff the request should be retried
*/
static retryPolicy(error) {
if (logger.debug.enabled) {
const details = [];
if (error.response) {
const statusText = error.response.statusText || ``;
details.push(`status_code=${error.response.status} (${statusText})`);
}
if (error.config) {
if (error.config.method) {
details.push(`method=${error.config.method.toUpperCase()}`);
}
if (error.config.url) {
details.push(`url=${error.config.url}`);
}
}
logger.debug(`Considering retry attempt; ${details.join(', ')}`);
}
// Delegate to the default function defined by retry-axios.
const shouldRetry = rax.shouldRetryRequest(error);
logger.debug(`Retry will ${shouldRetry ? '' : 'not '}be attempted`);
return shouldRetry;
}
gzipRequestBody(data, headers) {

@@ -333,0 +432,0 @@ return __awaiter(this, void 0, void 0, function* () {

@@ -110,2 +110,3 @@ "use strict";

this.baseOptions.serviceUrl = (0, helper_1.stripTrailingSlash)(url);
logger_1.default.debug("Set service URL: ".concat(this.baseOptions.serviceUrl));
}

@@ -185,2 +186,3 @@ };

BaseService.prototype.configureService = function (serviceName) {
logger_1.default.debug("Configuring BaseService instance with service name: ".concat(serviceName));
if (!serviceName) {

@@ -187,0 +189,0 @@ var err = 'Error configuring service. Service name is required.';

/**
* (C) Copyright IBM Corp. 2014, 2023.
* (C) Copyright IBM Corp. 2014, 2024.
*

@@ -36,2 +36,38 @@ * Licensed under the Apache License, Version 2.0 (the "License");

constructor(axiosOptions?: any);
/**
* Formats the specified Axios request for debug logging.
* @param request - the request to be logged
* @returns the string representation of the request
*/
private formatAxiosRequest;
/**
* Formats the specified Axios response for debug logging.
* @param response - the response to be logged
* @returns the string representation of the response
*/
private formatAxiosResponse;
/**
* Formats the specified Axios error for debug logging.
* @param error - the error to be logged
* @returns the string representation of the error
*/
private formatAxiosError;
/**
* Formats 'headers' to be included in the debug output
* like this:
* Accept: application/json
* Content-Type: application/json
* My-Header: my-value
* ...
* @param headers - the headers associated with an Axios request or response
* @returns the formatted output to be included in the HTTP message traces
*/
private formatAxiosHeaders;
/**
* Formats 'body' (either a string or object/array) to be included in the debug output
*
* @param body - a string, object or array that contains the request or response body
* @returns the formatted output to be included in the HTTP message traces
*/
private formatAxiosBody;
setCompressRequestData(setting: boolean): void;

@@ -58,3 +94,9 @@ /**

disableRetries(): void;
/**
* Returns true iff the previously-failed request contained in "error" should be retried.
* @param error - an AxiosError instance that contains a previously-failed request
* @returns true iff the request should be retried
*/
private static retryPolicy;
private gzipRequestBody;
}

@@ -79,3 +79,3 @@ "use strict";

/**
* (C) Copyright IBM Corp. 2014, 2023.
* (C) Copyright IBM Corp. 2014, 2024.
*

@@ -103,2 +103,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var helper_1 = require("./helper");
var private_helpers_1 = require("./private-helpers");
var logger_1 = __importDefault(require("./logger"));

@@ -159,20 +160,16 @@ var stream_to_promise_1 = require("./stream-to-promise");

}
// set debug interceptors
if (process.env.NODE_DEBUG === 'axios' || process.env.DEBUG) {
this.axiosInstance.interceptors.request.use(function (config) {
logger_1.default.debug('Request:');
logger_1.default.debug(config);
return config;
// If debug logging is requested, set up interceptors to log http request/response messages.
if (logger_1.default.debug.enabled || process.env.NODE_DEBUG === 'axios') {
this.axiosInstance.interceptors.request.use(function (request) {
logger_1.default.debug("--> HTTP Request:\n".concat(_this.formatAxiosRequest(request)));
return request;
}, function (error) {
logger_1.default.error('Error: ');
logger_1.default.error(error);
logger_1.default.debug("<-- HTTP Error:\n".concat(_this.formatAxiosError(error)));
return Promise.reject(error);
});
this.axiosInstance.interceptors.response.use(function (response) {
logger_1.default.debug('Response:');
logger_1.default.debug(response);
logger_1.default.debug("<-- HTTP Response:\n".concat(_this.formatAxiosResponse(response)));
return response;
}, function (error) {
logger_1.default.error('Error: ');
logger_1.default.error(error);
logger_1.default.debug("<-- HTTP Error:\n".concat(_this.formatAxiosError(error)));
return Promise.reject(error);

@@ -182,2 +179,74 @@ });

}
/**
* Formats the specified Axios request for debug logging.
* @param request - the request to be logged
* @returns the string representation of the request
*/
RequestWrapper.prototype.formatAxiosRequest = function (request) {
var method = request.method, url = request.url, data = request.data, headers = request.headers;
var headersOutput = this.formatAxiosHeaders(headers);
var body = this.formatAxiosBody(data);
var output = "".concat((method || '??').toUpperCase(), " ").concat(url || '??', "\n").concat(headersOutput, "\n").concat(body);
return (0, private_helpers_1.redactSecrets)(output);
};
/**
* Formats the specified Axios response for debug logging.
* @param response - the response to be logged
* @returns the string representation of the response
*/
RequestWrapper.prototype.formatAxiosResponse = function (response) {
var status = response.status, statusText = response.statusText, headers = response.headers, data = response.data;
var headersOutput = this.formatAxiosHeaders(headers);
var body = this.formatAxiosBody(data);
var statusMsg = statusText || "status_code_".concat(status);
var output = "".concat(status, " ").concat(statusMsg, "\n").concat(headersOutput, "\n").concat(body);
return (0, private_helpers_1.redactSecrets)(output);
};
/**
* Formats the specified Axios error for debug logging.
* @param error - the error to be logged
* @returns the string representation of the error
*/
RequestWrapper.prototype.formatAxiosError = function (error) {
var response = error.response;
var output = "HTTP error message=".concat(error.message || '', ", code=").concat(error.code || '');
if (response) {
output = this.formatAxiosResponse(response);
}
return output;
};
/**
* Formats 'headers' to be included in the debug output
* like this:
* Accept: application/json
* Content-Type: application/json
* My-Header: my-value
* ...
* @param headers - the headers associated with an Axios request or response
* @returns the formatted output to be included in the HTTP message traces
*/
RequestWrapper.prototype.formatAxiosHeaders = function (headers) {
var output = '';
if (headers) {
var lines_1 = [];
Object.keys(headers).forEach(function (key) {
lines_1.push("".concat(key, ": ").concat(headers[key]));
});
output = lines_1.join('\n');
}
return output;
};
/**
* Formats 'body' (either a string or object/array) to be included in the debug output
*
* @param body - a string, object or array that contains the request or response body
* @returns the formatted output to be included in the HTTP message traces
*/
RequestWrapper.prototype.formatAxiosBody = function (body) {
var output = '';
if (body) {
output = typeof body === 'string' ? body : JSON.stringify(body);
}
return output;
};
RequestWrapper.prototype.setCompressRequestData = function (setting) {

@@ -388,3 +457,4 @@ this.compressRequestData = setting;

checkRetryAfter: true,
maxRetryDelay: 30 * 1000, // default to 30 sec max delay
maxRetryDelay: 30 * 1000,
shouldRetry: this.retryPolicy,
};

@@ -410,2 +480,3 @@ if (retryOptions) {

this.retryInterceptorId = rax.attach(this.axiosInstance);
logger_1.default.debug("Enabled retries; maxRetries=".concat(this.raxConfig.retry, ", maxRetryInterval=").concat(this.raxConfig.maxRetryDelay));
};

@@ -417,4 +488,32 @@ RequestWrapper.prototype.disableRetries = function () {

delete this.raxConfig;
logger_1.default.debug('Disabled retries');
}
};
/**
* Returns true iff the previously-failed request contained in "error" should be retried.
* @param error - an AxiosError instance that contains a previously-failed request
* @returns true iff the request should be retried
*/
RequestWrapper.retryPolicy = function (error) {
if (logger_1.default.debug.enabled) {
var details = [];
if (error.response) {
var statusText = error.response.statusText || "";
details.push("status_code=".concat(error.response.status, " (").concat(statusText, ")"));
}
if (error.config) {
if (error.config.method) {
details.push("method=".concat(error.config.method.toUpperCase()));
}
if (error.config.url) {
details.push("url=".concat(error.config.url));
}
}
logger_1.default.debug("Considering retry attempt; ".concat(details.join(', ')));
}
// Delegate to the default function defined by retry-axios.
var shouldRetry = rax.shouldRetryRequest(error);
logger_1.default.debug("Retry will ".concat(shouldRetry ? '' : 'not ', "be attempted"));
return shouldRetry;
};
RequestWrapper.prototype.gzipRequestBody = function (data, headers) {

@@ -421,0 +520,0 @@ return __awaiter(this, void 0, void 0, function () {

{
"name": "ibm-cloud-sdk-core",
"version": "5.0.1",
"version": "5.0.2",
"description": "Core functionality to support SDKs generated with IBM's OpenAPI SDK Generator.",

@@ -54,3 +54,4 @@ "main": "index.js",

"overrides": {
"semver": "^7.5.3"
"semver": "^7.5.3",
"micromatch": "4.0.8"
},

@@ -64,3 +65,3 @@ "browser": {

"scripts": {
"clean": "rm -fr node_modules",
"clean": "rm -fr node_modules sdk-test-utilities/node_modules",
"commitmsg": "commitlint -E GIT_PARAMS",

@@ -67,0 +68,0 @@ "eslint:config": "eslint --print-config .eslintrc.js | eslint-config-prettier-check",

{
"name": "@ibm-cloud/sdk-test-utilities",
"version": "0.0.1",
"version": "1.0.0",
"lockfileVersion": 3,

@@ -9,6 +9,9 @@ "requires": true,

"name": "@ibm-cloud/sdk-test-utilities",
"version": "0.0.1",
"version": "1.0.0",
"license": "Apache-2.0",
"dependencies": {
"expect": "^29.7.0"
},
"engines": {
"node": ">=18"
}

@@ -414,5 +417,5 @@ },

"node_modules/micromatch": {
"version": "4.0.7",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.7.tgz",
"integrity": "sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==",
"version": "4.0.8",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
"integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
"dependencies": {

@@ -419,0 +422,0 @@ "braces": "^3.0.3",

@@ -14,2 +14,5 @@ {

},
"overrides": {
"micromatch": "4.0.8"
},
"engines": {

@@ -16,0 +19,0 @@ "node": ">=18"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc