ibm-cloud-sdk-core 3.2.2-beta-3 → 3.2.2-beta-5

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.
@@ -16,7 +16,7 @@
16
16
  import { Authenticator } from './authenticator';
17
17
  import { AuthenticateOptions } from './authenticator-interface';
18
18
  /** Configuration options for basic authentication. */
19
- export declare type Options = {
19
+ export type Options = {
20
20
  /** The username to be used in basic authorization. */
21
21
  username: string;
22
22
  /** The password to be used in basic authorization. */
@@ -16,7 +16,7 @@
16
16
  import { Authenticator } from './authenticator';
17
17
  import { AuthenticateOptions } from './authenticator-interface';
18
18
  /** Configuration options for bearer authentication. */
19
- export declare type Options = {
19
+ export type Options = {
20
20
  /** The bearer token to be added to requests. */
21
21
  bearerToken: string;
22
22
  };
@@ -19,7 +19,7 @@ import { JwtTokenManager } from '../token-managers';
19
19
  import { Authenticator } from './authenticator';
20
20
  import { AuthenticateOptions } from './authenticator-interface';
21
21
  /** Configuration options for token-based authentication. */
22
- export declare type BaseOptions = {
22
+ export type BaseOptions = {
23
23
  /** Headers to be sent with every outbound HTTP requests to token services. */
24
24
  headers?: OutgoingHttpHeaders;
25
25
  /**
@@ -44,7 +44,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
44
44
  function verb(n) { return function (v) { return step([n, v]); }; }
45
45
  function step(op) {
46
46
  if (f) throw new TypeError("Generator is already executing.");
47
- while (_) try {
47
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
48
48
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
49
49
  if (y = 0, t) op = [op[0] & 2, t.value];
50
50
  switch (op[0]) {
@@ -1,6 +1,6 @@
1
1
  import { TokenManager, TokenManagerOptions } from './token-manager';
2
2
  /** Configuration options for JWT token retrieval. */
3
- export declare type JwtTokenManagerOptions = TokenManagerOptions;
3
+ export type JwtTokenManagerOptions = TokenManagerOptions;
4
4
  /**
5
5
  * A class for shared functionality for parsing, storing, and requesting
6
6
  * JWT tokens. Intended to be used as a parent to be extended for token
@@ -17,7 +17,7 @@
17
17
  import { OutgoingHttpHeaders } from 'http';
18
18
  import { RequestWrapper } from '../../lib/request-wrapper';
19
19
  /** Configuration options for token retrieval. */
20
- export declare type TokenManagerOptions = {
20
+ export type TokenManagerOptions = {
21
21
  /** The endpoint for token requests. */
22
22
  url?: string;
23
23
  /** Headers to be sent with every service token request. */
@@ -44,7 +44,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
44
44
  function verb(n) { return function (v) { return step([n, v]); }; }
45
45
  function step(op) {
46
46
  if (f) throw new TypeError("Generator is already executing.");
47
- while (_) try {
47
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
48
48
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
49
49
  if (y = 0, t) op = [op[0] & 2, t.value];
50
50
  switch (op[0]) {
@@ -4894,7 +4894,7 @@
4894
4894
  "excerptTokens": [
4895
4895
  {
4896
4896
  "kind": "Content",
4897
- "text": "export declare type JwtTokenManagerOptions = "
4897
+ "text": "export type JwtTokenManagerOptions = "
4898
4898
  },
4899
4899
  {
4900
4900
  "kind": "Reference",
@@ -6020,7 +6020,7 @@
6020
6020
  "excerptTokens": [
6021
6021
  {
6022
6022
  "kind": "Content",
6023
- "text": "export declare type TokenManagerOptions = "
6023
+ "text": "export type TokenManagerOptions = "
6024
6024
  },
6025
6025
  {
6026
6026
  "kind": "Content",
@@ -16,7 +16,7 @@
16
16
  import { Authenticator } from './authenticator';
17
17
  import { AuthenticateOptions } from './authenticator-interface';
18
18
  /** Configuration options for basic authentication. */
19
- export declare type Options = {
19
+ export type Options = {
20
20
  /** The username to be used in basic authorization. */
21
21
  username: string;
22
22
  /** The password to be used in basic authorization. */
@@ -16,7 +16,7 @@
16
16
  import { Authenticator } from './authenticator';
17
17
  import { AuthenticateOptions } from './authenticator-interface';
18
18
  /** Configuration options for bearer authentication. */
19
- export declare type Options = {
19
+ export type Options = {
20
20
  /** The bearer token to be added to requests. */
21
21
  bearerToken: string;
22
22
  };
@@ -19,7 +19,7 @@ import { JwtTokenManager } from '../token-managers';
19
19
  import { Authenticator } from './authenticator';
20
20
  import { AuthenticateOptions } from './authenticator-interface';
21
21
  /** Configuration options for token-based authentication. */
22
- export declare type BaseOptions = {
22
+ export type BaseOptions = {
23
23
  /** Headers to be sent with every outbound HTTP requests to token services. */
24
24
  headers?: OutgoingHttpHeaders;
25
25
  /**
@@ -1,6 +1,6 @@
1
1
  import { TokenManager, TokenManagerOptions } from './token-manager';
2
2
  /** Configuration options for JWT token retrieval. */
3
- export declare type JwtTokenManagerOptions = TokenManagerOptions;
3
+ export type JwtTokenManagerOptions = TokenManagerOptions;
4
4
  /**
5
5
  * A class for shared functionality for parsing, storing, and requesting
6
6
  * JWT tokens. Intended to be used as a parent to be extended for token
@@ -17,7 +17,7 @@
17
17
  import { OutgoingHttpHeaders } from 'http';
18
18
  import { RequestWrapper } from '../../lib/request-wrapper';
19
19
  /** Configuration options for token retrieval. */
20
- export declare type TokenManagerOptions = {
20
+ export type TokenManagerOptions = {
21
21
  /** The endpoint for token requests. */
22
22
  url?: string;
23
23
  /** Headers to be sent with every service token request. */
@@ -69,10 +69,9 @@ export class CookieInterceptor {
69
69
  logger.debug('CookieInterceptor: checking for set-cookie headers.');
70
70
  const cookies = response.headers['set-cookie'];
71
71
  if (cookies) {
72
- logger.debug('CookieInterceptor: setting cookies in jar.');
73
- cookies.forEach((cookie) => __awaiter(this, void 0, void 0, function* () {
74
- yield this.cookieJar.setCookie(cookie, response.request.url);
75
- }));
72
+ logger.debug(`CookieInterceptor: setting cookies in jar for URL ${response.config.url}.`);
73
+ // Write cookies sequentially by chaining the promises in a reduce
74
+ yield cookies.reduce((cookiePromise, cookie) => cookiePromise.then(() => this.cookieJar.setCookie(cookie, response.config.url)), Promise.resolve(null));
76
75
  }
77
76
  else {
78
77
  logger.debug('CookieInterceptor: no set-cookie headers.');
@@ -73,8 +73,10 @@ export class RequestWrapper {
73
73
  // if a cookie jar is provided, wrap the axios instance and update defaults
74
74
  if (axiosOptions.jar) {
75
75
  const cookieInterceptor = new CookieInterceptor(axiosOptions.jar);
76
- this.axiosInstance.interceptors.request.use((config) => cookieInterceptor.requestInterceptor(config));
77
- this.axiosInstance.interceptors.response.use((response) => cookieInterceptor.responseInterceptor(response));
76
+ const requestCookieInterceptor = (config) => cookieInterceptor.requestInterceptor(config);
77
+ const responseCookieInterceptor = (response) => cookieInterceptor.responseInterceptor(response);
78
+ this.axiosInstance.interceptors.request.use(requestCookieInterceptor);
79
+ this.axiosInstance.interceptors.response.use(responseCookieInterceptor);
78
80
  }
79
81
  // get retry config properties and conditionally enable retries
80
82
  if (axiosOptions.enableRetries) {
@@ -29,7 +29,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
29
29
  function verb(n) { return function (v) { return step([n, v]); }; }
30
30
  function step(op) {
31
31
  if (f) throw new TypeError("Generator is already executing.");
32
- while (_) try {
32
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
33
33
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
34
  if (y = 0, t) op = [op[0] & 2, t.value];
35
35
  switch (op[0]) {
@@ -108,31 +108,31 @@ var CookieInterceptor = /** @class */ (function () {
108
108
  var cookies;
109
109
  var _this = this;
110
110
  return __generator(this, function (_a) {
111
- logger_1.default.debug('CookieInterceptor: intercepting response.');
112
- if (response && response.headers) {
113
- logger_1.default.debug('CookieInterceptor: checking for set-cookie headers.');
114
- cookies = response.headers['set-cookie'];
115
- if (cookies) {
116
- logger_1.default.debug('CookieInterceptor: setting cookies in jar.');
117
- cookies.forEach(function (cookie) { return __awaiter(_this, void 0, void 0, function () {
118
- return __generator(this, function (_a) {
119
- switch (_a.label) {
120
- case 0: return [4 /*yield*/, this.cookieJar.setCookie(cookie, response.request.url)];
121
- case 1:
122
- _a.sent();
123
- return [2 /*return*/];
124
- }
125
- });
126
- }); });
127
- }
128
- else {
111
+ switch (_a.label) {
112
+ case 0:
113
+ logger_1.default.debug('CookieInterceptor: intercepting response.');
114
+ if (!(response && response.headers)) return [3 /*break*/, 4];
115
+ logger_1.default.debug('CookieInterceptor: checking for set-cookie headers.');
116
+ cookies = response.headers['set-cookie'];
117
+ if (!cookies) return [3 /*break*/, 2];
118
+ logger_1.default.debug("CookieInterceptor: setting cookies in jar for URL ".concat(response.config.url, "."));
119
+ // Write cookies sequentially by chaining the promises in a reduce
120
+ return [4 /*yield*/, cookies.reduce(function (cookiePromise, cookie) {
121
+ return cookiePromise.then(function () { return _this.cookieJar.setCookie(cookie, response.config.url); });
122
+ }, Promise.resolve(null))];
123
+ case 1:
124
+ // Write cookies sequentially by chaining the promises in a reduce
125
+ _a.sent();
126
+ return [3 /*break*/, 3];
127
+ case 2:
129
128
  logger_1.default.debug('CookieInterceptor: no set-cookie headers.');
130
- }
131
- }
132
- else {
133
- logger_1.default.debug('CookieInterceptor: no response headers.');
129
+ _a.label = 3;
130
+ case 3: return [3 /*break*/, 5];
131
+ case 4:
132
+ logger_1.default.debug('CookieInterceptor: no response headers.');
133
+ _a.label = 5;
134
+ case 5: return [2 /*return*/, response];
134
135
  }
135
- return [2 /*return*/, response];
136
136
  });
137
137
  });
138
138
  };
package/lib/helper.js CHANGED
@@ -29,7 +29,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
29
29
  function verb(n) { return function (v) { return step([n, v]); }; }
30
30
  function step(op) {
31
31
  if (f) throw new TypeError("Generator is already executing.");
32
- while (_) try {
32
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
33
33
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
34
  if (y = 0, t) op = [op[0] & 2, t.value];
35
35
  switch (op[0]) {
@@ -49,7 +49,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
49
49
  function verb(n) { return function (v) { return step([n, v]); }; }
50
50
  function step(op) {
51
51
  if (f) throw new TypeError("Generator is already executing.");
52
- while (_) try {
52
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
53
53
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
54
54
  if (y = 0, t) op = [op[0] & 2, t.value];
55
55
  switch (op[0]) {
@@ -141,12 +141,12 @@ var RequestWrapper = /** @class */ (function () {
141
141
  // if a cookie jar is provided, wrap the axios instance and update defaults
142
142
  if (axiosOptions.jar) {
143
143
  var cookieInterceptor_1 = new cookie_support_1.CookieInterceptor(axiosOptions.jar);
144
- this.axiosInstance.interceptors.request.use(function (config) {
145
- return cookieInterceptor_1.requestInterceptor(config);
146
- });
147
- this.axiosInstance.interceptors.response.use(function (response) {
144
+ var requestCookieInterceptor = function (config) { return cookieInterceptor_1.requestInterceptor(config); };
145
+ var responseCookieInterceptor = function (response) {
148
146
  return cookieInterceptor_1.responseInterceptor(response);
149
- });
147
+ };
148
+ this.axiosInstance.interceptors.request.use(requestCookieInterceptor);
149
+ this.axiosInstance.interceptors.response.use(responseCookieInterceptor);
150
150
  }
151
151
  // get retry config properties and conditionally enable retries
152
152
  if (axiosOptions.enableRetries) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ibm-cloud-sdk-core",
3
- "version": "3.2.2-beta-3",
3
+ "version": "3.2.2-beta-5",
4
4
  "description": "Core functionality to support SDKs generated with IBM's OpenAPI SDK Generator.",
5
5
  "main": "./index.js",
6
6
  "typings": "./es/index.d.ts",
@@ -62,21 +62,21 @@
62
62
  "eslint-plugin-node": "^9.0.0",
63
63
  "eslint-plugin-prettier": "^3.0.1",
64
64
  "jest": "^29.3.1",
65
- "nock": "^13.1.2",
65
+ "nock": "^13.2.9",
66
66
  "npm-run-all": "^4.1.5",
67
67
  "object.assign": "~4.1.0",
68
68
  "package-json-reducer": "^1.0.18",
69
69
  "prettier": "~2.3.0",
70
70
  "rimraf": "^3.0.2",
71
71
  "semantic-release": "19.0.3",
72
- "typescript": "4.8.4"
72
+ "typescript": "~4.9.4"
73
73
  },
74
74
  "dependencies": {
75
75
  "@types/file-type": "~5.2.1",
76
76
  "@types/isstream": "^0.1.0",
77
77
  "@types/node": "~10.14.19",
78
78
  "@types/tough-cookie": "^4.0.0",
79
- "axios": "1.2.0",
79
+ "axios": "1.2.1",
80
80
  "camelcase": "^5.3.1",
81
81
  "debug": "^4.1.1",
82
82
  "dotenv": "^6.2.0",