ibm-cloud-sdk-core 5.4.13 → 5.4.15
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/auth/authenticators/basic-authenticator.js +12 -2
- package/auth/authenticators/bearer-token-authenticator.js +12 -2
- package/auth/authenticators/token-request-based-authenticator-immutable.js +12 -2
- package/auth/token-managers/cp4d-token-manager.js +12 -2
- package/auth/token-managers/iam-request-based-token-manager.js +12 -2
- package/auth/token-managers/mcsp-token-manager.js +12 -2
- package/auth/token-managers/mcspv2-token-manager.js +12 -2
- package/docs/ibm-cloud-sdk-core.api.json +61 -0
- package/es/auth/authenticators/basic-authenticator.js +1 -2
- package/es/auth/authenticators/bearer-token-authenticator.js +1 -2
- package/es/auth/authenticators/token-request-based-authenticator-immutable.js +1 -2
- package/es/auth/token-managers/cp4d-token-manager.js +1 -2
- package/es/auth/token-managers/iam-request-based-token-manager.js +1 -2
- package/es/auth/token-managers/mcsp-token-manager.js +1 -2
- package/es/auth/token-managers/mcspv2-token-manager.js +1 -2
- package/es/lib/base-service.js +1 -2
- package/es/lib/cookie-support.js +1 -3
- package/es/lib/helper.d.ts +1 -0
- package/es/lib/helper.js +13 -0
- package/es/lib/request-wrapper.js +7 -13
- package/ibm-cloud-sdk-core.d.ts +2 -0
- package/lib/base-service.js +1 -2
- package/lib/cookie-support.js +2 -4
- package/lib/helper.d.ts +1 -0
- package/lib/helper.js +26 -1
- package/lib/request-wrapper.js +6 -12
- package/package.json +1 -2
|
@@ -29,12 +29,22 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
29
29
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
30
30
|
};
|
|
31
31
|
})();
|
|
32
|
+
var __assign = (this && this.__assign) || function () {
|
|
33
|
+
__assign = Object.assign || function(t) {
|
|
34
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
35
|
+
s = arguments[i];
|
|
36
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
37
|
+
t[p] = s[p];
|
|
38
|
+
}
|
|
39
|
+
return t;
|
|
40
|
+
};
|
|
41
|
+
return __assign.apply(this, arguments);
|
|
42
|
+
};
|
|
32
43
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
44
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
45
|
};
|
|
35
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
47
|
exports.BasicAuthenticator = void 0;
|
|
37
|
-
var extend_1 = __importDefault(require("extend"));
|
|
38
48
|
var helpers_1 = require("../utils/helpers");
|
|
39
49
|
var authenticator_1 = require("./authenticator");
|
|
40
50
|
var logger_1 = __importDefault(require("../../lib/logger"));
|
|
@@ -79,7 +89,7 @@ var BasicAuthenticator = /** @class */ (function (_super) {
|
|
|
79
89
|
BasicAuthenticator.prototype.authenticate = function (requestOptions) {
|
|
80
90
|
var _this = this;
|
|
81
91
|
return new Promise(function (resolve) {
|
|
82
|
-
requestOptions.headers = (
|
|
92
|
+
requestOptions.headers = __assign(__assign({}, requestOptions.headers), _this.authHeader);
|
|
83
93
|
logger_1.default.debug("Authenticated outbound request (type=".concat(_this.authenticationType(), ")"));
|
|
84
94
|
resolve();
|
|
85
95
|
});
|
|
@@ -29,12 +29,22 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
29
29
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
30
30
|
};
|
|
31
31
|
})();
|
|
32
|
+
var __assign = (this && this.__assign) || function () {
|
|
33
|
+
__assign = Object.assign || function(t) {
|
|
34
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
35
|
+
s = arguments[i];
|
|
36
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
37
|
+
t[p] = s[p];
|
|
38
|
+
}
|
|
39
|
+
return t;
|
|
40
|
+
};
|
|
41
|
+
return __assign.apply(this, arguments);
|
|
42
|
+
};
|
|
32
43
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
44
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
45
|
};
|
|
35
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
47
|
exports.BearerTokenAuthenticator = void 0;
|
|
37
|
-
var extend_1 = __importDefault(require("extend"));
|
|
38
48
|
var helpers_1 = require("../utils/helpers");
|
|
39
49
|
var authenticator_1 = require("./authenticator");
|
|
40
50
|
var logger_1 = __importDefault(require("../../lib/logger"));
|
|
@@ -84,7 +94,7 @@ var BearerTokenAuthenticator = /** @class */ (function (_super) {
|
|
|
84
94
|
var _this = this;
|
|
85
95
|
return new Promise(function (resolve) {
|
|
86
96
|
var authHeader = { Authorization: "Bearer ".concat(_this.bearerToken) };
|
|
87
|
-
requestOptions.headers = (
|
|
97
|
+
requestOptions.headers = __assign(__assign({}, requestOptions.headers), authHeader);
|
|
88
98
|
logger_1.default.debug("Authenticated outbound request (type=".concat(_this.authenticationType(), ")"));
|
|
89
99
|
resolve();
|
|
90
100
|
});
|
|
@@ -29,12 +29,22 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
29
29
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
30
30
|
};
|
|
31
31
|
})();
|
|
32
|
+
var __assign = (this && this.__assign) || function () {
|
|
33
|
+
__assign = Object.assign || function(t) {
|
|
34
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
35
|
+
s = arguments[i];
|
|
36
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
37
|
+
t[p] = s[p];
|
|
38
|
+
}
|
|
39
|
+
return t;
|
|
40
|
+
};
|
|
41
|
+
return __assign.apply(this, arguments);
|
|
42
|
+
};
|
|
32
43
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
44
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
45
|
};
|
|
35
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
47
|
exports.TokenRequestBasedAuthenticatorImmutable = void 0;
|
|
37
|
-
var extend_1 = __importDefault(require("extend"));
|
|
38
48
|
var jwt_token_manager_1 = require("../token-managers/jwt-token-manager");
|
|
39
49
|
var authenticator_1 = require("./authenticator");
|
|
40
50
|
var logger_1 = __importDefault(require("../../lib/logger"));
|
|
@@ -82,7 +92,7 @@ var TokenRequestBasedAuthenticatorImmutable = /** @class */ (function (_super) {
|
|
|
82
92
|
var _this = this;
|
|
83
93
|
return this.tokenManager.getToken().then(function (token) {
|
|
84
94
|
var authHeader = { Authorization: "Bearer ".concat(token) };
|
|
85
|
-
requestOptions.headers = (
|
|
95
|
+
requestOptions.headers = __assign(__assign({}, requestOptions.headers), authHeader);
|
|
86
96
|
logger_1.default.debug("Authenticated outbound request (type=".concat(_this.authenticationType(), ")"));
|
|
87
97
|
});
|
|
88
98
|
};
|
|
@@ -29,12 +29,22 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
29
29
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
30
30
|
};
|
|
31
31
|
})();
|
|
32
|
+
var __assign = (this && this.__assign) || function () {
|
|
33
|
+
__assign = Object.assign || function(t) {
|
|
34
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
35
|
+
s = arguments[i];
|
|
36
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
37
|
+
t[p] = s[p];
|
|
38
|
+
}
|
|
39
|
+
return t;
|
|
40
|
+
};
|
|
41
|
+
return __assign.apply(this, arguments);
|
|
42
|
+
};
|
|
32
43
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
44
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
45
|
};
|
|
35
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
47
|
exports.Cp4dTokenManager = void 0;
|
|
37
|
-
var extend_1 = __importDefault(require("extend"));
|
|
38
48
|
var helpers_1 = require("../utils/helpers");
|
|
39
49
|
var build_user_agent_1 = require("../../lib/build-user-agent");
|
|
40
50
|
var jwt_token_manager_1 = require("./jwt-token-manager");
|
|
@@ -96,7 +106,7 @@ var Cp4dTokenManager = /** @class */ (function (_super) {
|
|
|
96
106
|
api_key: this.apikey,
|
|
97
107
|
},
|
|
98
108
|
method: 'POST',
|
|
99
|
-
headers: (
|
|
109
|
+
headers: __assign(__assign({}, this.headers), requiredHeaders),
|
|
100
110
|
rejectUnauthorized: !this.disableSslVerification,
|
|
101
111
|
},
|
|
102
112
|
};
|
|
@@ -29,12 +29,22 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
29
29
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
30
30
|
};
|
|
31
31
|
})();
|
|
32
|
+
var __assign = (this && this.__assign) || function () {
|
|
33
|
+
__assign = Object.assign || function(t) {
|
|
34
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
35
|
+
s = arguments[i];
|
|
36
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
37
|
+
t[p] = s[p];
|
|
38
|
+
}
|
|
39
|
+
return t;
|
|
40
|
+
};
|
|
41
|
+
return __assign.apply(this, arguments);
|
|
42
|
+
};
|
|
32
43
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
44
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
45
|
};
|
|
35
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
47
|
exports.IamRequestBasedTokenManager = void 0;
|
|
37
|
-
var extend_1 = __importDefault(require("extend"));
|
|
38
48
|
var logger_1 = __importDefault(require("../../lib/logger"));
|
|
39
49
|
var helpers_1 = require("../utils/helpers");
|
|
40
50
|
var jwt_token_manager_1 = require("./jwt-token-manager");
|
|
@@ -155,7 +165,7 @@ var IamRequestBasedTokenManager = /** @class */ (function (_super) {
|
|
|
155
165
|
options: {
|
|
156
166
|
url: this.url + OPERATION_PATH,
|
|
157
167
|
method: 'POST',
|
|
158
|
-
headers: (
|
|
168
|
+
headers: __assign(__assign({}, this.headers), requiredHeaders),
|
|
159
169
|
form: this.formData,
|
|
160
170
|
rejectUnauthorized: !this.disableSslVerification,
|
|
161
171
|
},
|
|
@@ -29,12 +29,22 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
29
29
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
30
30
|
};
|
|
31
31
|
})();
|
|
32
|
+
var __assign = (this && this.__assign) || function () {
|
|
33
|
+
__assign = Object.assign || function(t) {
|
|
34
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
35
|
+
s = arguments[i];
|
|
36
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
37
|
+
t[p] = s[p];
|
|
38
|
+
}
|
|
39
|
+
return t;
|
|
40
|
+
};
|
|
41
|
+
return __assign.apply(this, arguments);
|
|
42
|
+
};
|
|
32
43
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
44
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
45
|
};
|
|
35
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
47
|
exports.McspTokenManager = void 0;
|
|
37
|
-
var extend_1 = __importDefault(require("extend"));
|
|
38
48
|
var helpers_1 = require("../utils/helpers");
|
|
39
49
|
var build_user_agent_1 = require("../../lib/build-user-agent");
|
|
40
50
|
var jwt_token_manager_1 = require("./jwt-token-manager");
|
|
@@ -87,7 +97,7 @@ var McspTokenManager = /** @class */ (function (_super) {
|
|
|
87
97
|
apikey: this.apikey,
|
|
88
98
|
},
|
|
89
99
|
method: 'POST',
|
|
90
|
-
headers: (
|
|
100
|
+
headers: __assign(__assign({}, this.headers), requiredHeaders),
|
|
91
101
|
rejectUnauthorized: !this.disableSslVerification,
|
|
92
102
|
},
|
|
93
103
|
};
|
|
@@ -29,12 +29,22 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
29
29
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
30
30
|
};
|
|
31
31
|
})();
|
|
32
|
+
var __assign = (this && this.__assign) || function () {
|
|
33
|
+
__assign = Object.assign || function(t) {
|
|
34
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
35
|
+
s = arguments[i];
|
|
36
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
37
|
+
t[p] = s[p];
|
|
38
|
+
}
|
|
39
|
+
return t;
|
|
40
|
+
};
|
|
41
|
+
return __assign.apply(this, arguments);
|
|
42
|
+
};
|
|
32
43
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
44
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
45
|
};
|
|
35
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
47
|
exports.McspV2TokenManager = void 0;
|
|
37
|
-
var extend_1 = __importDefault(require("extend"));
|
|
38
48
|
var helpers_1 = require("../utils/helpers");
|
|
39
49
|
var build_user_agent_1 = require("../../lib/build-user-agent");
|
|
40
50
|
var jwt_token_manager_1 = require("./jwt-token-manager");
|
|
@@ -115,7 +125,7 @@ var McspV2TokenManager = /** @class */ (function (_super) {
|
|
|
115
125
|
'Content-Type': 'application/json',
|
|
116
126
|
'User-Agent': this.userAgent,
|
|
117
127
|
};
|
|
118
|
-
var requestHeaders = (
|
|
128
|
+
var requestHeaders = __assign(__assign({}, this.headers), requiredHeaders);
|
|
119
129
|
// The keys used here must match the path parameter references in PATH_TEMPLATE above.
|
|
120
130
|
var pathParams = {
|
|
121
131
|
scopeCollectionType: this.scopeCollectionType,
|
|
@@ -3270,6 +3270,67 @@
|
|
|
3270
3270
|
},
|
|
3271
3271
|
"implementsTokenRanges": []
|
|
3272
3272
|
},
|
|
3273
|
+
{
|
|
3274
|
+
"kind": "Function",
|
|
3275
|
+
"canonicalReference": "ibm-cloud-sdk-core!deepMerge:function(1)",
|
|
3276
|
+
"docComment": "",
|
|
3277
|
+
"excerptTokens": [
|
|
3278
|
+
{
|
|
3279
|
+
"kind": "Content",
|
|
3280
|
+
"text": "export declare function deepMerge(target: "
|
|
3281
|
+
},
|
|
3282
|
+
{
|
|
3283
|
+
"kind": "Content",
|
|
3284
|
+
"text": "any"
|
|
3285
|
+
},
|
|
3286
|
+
{
|
|
3287
|
+
"kind": "Content",
|
|
3288
|
+
"text": ", source: "
|
|
3289
|
+
},
|
|
3290
|
+
{
|
|
3291
|
+
"kind": "Content",
|
|
3292
|
+
"text": "any"
|
|
3293
|
+
},
|
|
3294
|
+
{
|
|
3295
|
+
"kind": "Content",
|
|
3296
|
+
"text": "): "
|
|
3297
|
+
},
|
|
3298
|
+
{
|
|
3299
|
+
"kind": "Content",
|
|
3300
|
+
"text": "any"
|
|
3301
|
+
},
|
|
3302
|
+
{
|
|
3303
|
+
"kind": "Content",
|
|
3304
|
+
"text": ";"
|
|
3305
|
+
}
|
|
3306
|
+
],
|
|
3307
|
+
"fileUrlPath": "dist/es/lib/helper.d.ts",
|
|
3308
|
+
"returnTypeTokenRange": {
|
|
3309
|
+
"startIndex": 5,
|
|
3310
|
+
"endIndex": 6
|
|
3311
|
+
},
|
|
3312
|
+
"releaseTag": "Public",
|
|
3313
|
+
"overloadIndex": 1,
|
|
3314
|
+
"parameters": [
|
|
3315
|
+
{
|
|
3316
|
+
"parameterName": "target",
|
|
3317
|
+
"parameterTypeTokenRange": {
|
|
3318
|
+
"startIndex": 1,
|
|
3319
|
+
"endIndex": 2
|
|
3320
|
+
},
|
|
3321
|
+
"isOptional": false
|
|
3322
|
+
},
|
|
3323
|
+
{
|
|
3324
|
+
"parameterName": "source",
|
|
3325
|
+
"parameterTypeTokenRange": {
|
|
3326
|
+
"startIndex": 3,
|
|
3327
|
+
"endIndex": 4
|
|
3328
|
+
},
|
|
3329
|
+
"isOptional": false
|
|
3330
|
+
}
|
|
3331
|
+
],
|
|
3332
|
+
"name": "deepMerge"
|
|
3333
|
+
},
|
|
3273
3334
|
{
|
|
3274
3335
|
"kind": "Function",
|
|
3275
3336
|
"canonicalReference": "ibm-cloud-sdk-core!fileExistsAtPath:function(1)",
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import extend from 'extend';
|
|
17
16
|
import { computeBasicAuthHeader, validateInput } from '../utils/helpers';
|
|
18
17
|
import { Authenticator } from './authenticator';
|
|
19
18
|
import logger from '../../lib/logger';
|
|
@@ -55,7 +54,7 @@ export class BasicAuthenticator extends Authenticator {
|
|
|
55
54
|
*/
|
|
56
55
|
authenticate(requestOptions) {
|
|
57
56
|
return new Promise((resolve) => {
|
|
58
|
-
requestOptions.headers =
|
|
57
|
+
requestOptions.headers = Object.assign(Object.assign({}, requestOptions.headers), this.authHeader);
|
|
59
58
|
logger.debug(`Authenticated outbound request (type=${this.authenticationType()})`);
|
|
60
59
|
resolve();
|
|
61
60
|
});
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import extend from 'extend';
|
|
17
16
|
import { validateInput } from '../utils/helpers';
|
|
18
17
|
import { Authenticator } from './authenticator';
|
|
19
18
|
import logger from '../../lib/logger';
|
|
@@ -60,7 +59,7 @@ export class BearerTokenAuthenticator extends Authenticator {
|
|
|
60
59
|
authenticate(requestOptions) {
|
|
61
60
|
return new Promise((resolve) => {
|
|
62
61
|
const authHeader = { Authorization: `Bearer ${this.bearerToken}` };
|
|
63
|
-
requestOptions.headers =
|
|
62
|
+
requestOptions.headers = Object.assign(Object.assign({}, requestOptions.headers), authHeader);
|
|
64
63
|
logger.debug(`Authenticated outbound request (type=${this.authenticationType()})`);
|
|
65
64
|
resolve();
|
|
66
65
|
});
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import extend from 'extend';
|
|
17
16
|
import { JwtTokenManager } from '../token-managers/jwt-token-manager';
|
|
18
17
|
import { Authenticator } from './authenticator';
|
|
19
18
|
import logger from '../../lib/logger';
|
|
@@ -58,7 +57,7 @@ export class TokenRequestBasedAuthenticatorImmutable extends Authenticator {
|
|
|
58
57
|
authenticate(requestOptions) {
|
|
59
58
|
return this.tokenManager.getToken().then((token) => {
|
|
60
59
|
const authHeader = { Authorization: `Bearer ${token}` };
|
|
61
|
-
requestOptions.headers =
|
|
60
|
+
requestOptions.headers = Object.assign(Object.assign({}, requestOptions.headers), authHeader);
|
|
62
61
|
logger.debug(`Authenticated outbound request (type=${this.authenticationType()})`);
|
|
63
62
|
});
|
|
64
63
|
}
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import extend from 'extend';
|
|
17
16
|
import { validateInput } from '../utils/helpers';
|
|
18
17
|
import { buildUserAgent } from '../../lib/build-user-agent';
|
|
19
18
|
import { JwtTokenManager } from './jwt-token-manager';
|
|
@@ -73,7 +72,7 @@ export class Cp4dTokenManager extends JwtTokenManager {
|
|
|
73
72
|
api_key: this.apikey,
|
|
74
73
|
},
|
|
75
74
|
method: 'POST',
|
|
76
|
-
headers:
|
|
75
|
+
headers: Object.assign(Object.assign({}, this.headers), requiredHeaders),
|
|
77
76
|
rejectUnauthorized: !this.disableSslVerification,
|
|
78
77
|
},
|
|
79
78
|
};
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import extend from 'extend';
|
|
17
16
|
import logger from '../../lib/logger';
|
|
18
17
|
import { computeBasicAuthHeader, getCurrentTime, onlyOne, removeSuffix } from '../utils/helpers';
|
|
19
18
|
import { JwtTokenManager } from './jwt-token-manager';
|
|
@@ -131,7 +130,7 @@ export class IamRequestBasedTokenManager extends JwtTokenManager {
|
|
|
131
130
|
options: {
|
|
132
131
|
url: this.url + OPERATION_PATH,
|
|
133
132
|
method: 'POST',
|
|
134
|
-
headers:
|
|
133
|
+
headers: Object.assign(Object.assign({}, this.headers), requiredHeaders),
|
|
135
134
|
form: this.formData,
|
|
136
135
|
rejectUnauthorized: !this.disableSslVerification,
|
|
137
136
|
},
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import extend from 'extend';
|
|
17
16
|
import { validateInput } from '../utils/helpers';
|
|
18
17
|
import { buildUserAgent } from '../../lib/build-user-agent';
|
|
19
18
|
import { JwtTokenManager } from './jwt-token-manager';
|
|
@@ -64,7 +63,7 @@ export class McspTokenManager extends JwtTokenManager {
|
|
|
64
63
|
apikey: this.apikey,
|
|
65
64
|
},
|
|
66
65
|
method: 'POST',
|
|
67
|
-
headers:
|
|
66
|
+
headers: Object.assign(Object.assign({}, this.headers), requiredHeaders),
|
|
68
67
|
rejectUnauthorized: !this.disableSslVerification,
|
|
69
68
|
},
|
|
70
69
|
};
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import extend from 'extend';
|
|
17
16
|
import { validateInput } from '../utils/helpers';
|
|
18
17
|
import { buildUserAgent } from '../../lib/build-user-agent';
|
|
19
18
|
import { JwtTokenManager } from './jwt-token-manager';
|
|
@@ -92,7 +91,7 @@ export class McspV2TokenManager extends JwtTokenManager {
|
|
|
92
91
|
'Content-Type': 'application/json',
|
|
93
92
|
'User-Agent': this.userAgent,
|
|
94
93
|
};
|
|
95
|
-
const requestHeaders =
|
|
94
|
+
const requestHeaders = Object.assign(Object.assign({}, this.headers), requiredHeaders);
|
|
96
95
|
// The keys used here must match the path parameter references in PATH_TEMPLATE above.
|
|
97
96
|
const pathParams = {
|
|
98
97
|
scopeCollectionType: this.scopeCollectionType,
|
package/es/lib/base-service.js
CHANGED
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import extend from 'extend';
|
|
17
16
|
import { checkCredentials, readExternalSources } from '../auth';
|
|
18
17
|
import { stripTrailingSlash } from './helper';
|
|
19
18
|
import logger from './logger';
|
|
@@ -206,7 +205,7 @@ export class BaseService {
|
|
|
206
205
|
const userAgent = {
|
|
207
206
|
'User-Agent': this.defaultUserAgent,
|
|
208
207
|
};
|
|
209
|
-
parameters.defaultOptions.headers =
|
|
208
|
+
parameters.defaultOptions.headers = Object.assign(Object.assign({}, userAgent), parameters.defaultOptions.headers);
|
|
210
209
|
return this.authenticator.authenticate(parameters.defaultOptions).then(() =>
|
|
211
210
|
// resolve() handles rejection as well, so resolving the result of sendRequest should allow for proper handling later
|
|
212
211
|
this.requestWrapperInstance.sendRequest(parameters));
|
package/es/lib/cookie-support.js
CHANGED
|
@@ -23,7 +23,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
25
|
import { isAxiosError } from 'axios';
|
|
26
|
-
import extend from 'extend';
|
|
27
26
|
import { CookieJar } from 'tough-cookie';
|
|
28
27
|
import logger from './logger';
|
|
29
28
|
const internalCreateCookieInterceptor = (cookieJar) => {
|
|
@@ -42,8 +41,7 @@ const internalCreateCookieInterceptor = (cookieJar) => {
|
|
|
42
41
|
const cookieHeaderValue = yield cookieJar.getCookieString(config.url);
|
|
43
42
|
if (cookieHeaderValue) {
|
|
44
43
|
logger.debug('CookieInterceptor: setting cookie header');
|
|
45
|
-
|
|
46
|
-
config.headers = extend(true, {}, config.headers, cookieHeader);
|
|
44
|
+
config.headers.cookie = cookieHeaderValue;
|
|
47
45
|
}
|
|
48
46
|
else {
|
|
49
47
|
logger.debug(`CookieInterceptor: no cookies for: ${config.url}`);
|
package/es/lib/helper.d.ts
CHANGED
|
@@ -126,3 +126,4 @@ export declare function constructServiceUrl(parameterizedUrl: string, defaultUrl
|
|
|
126
126
|
* @returns true if "mimeType" represents a JSON media type and false otherwise
|
|
127
127
|
*/
|
|
128
128
|
export declare function isJsonMimeType(mimeType: string): boolean;
|
|
129
|
+
export declare function deepMerge(target: any, source: any): any;
|
package/es/lib/helper.js
CHANGED
|
@@ -310,3 +310,16 @@ export function isJsonMimeType(mimeType) {
|
|
|
310
310
|
logger.debug(`Determining if the mime type '${mimeType}' specifies JSON content.`);
|
|
311
311
|
return !!mimeType && /^application\/json(\s*;.*)?$/i.test(mimeType);
|
|
312
312
|
}
|
|
313
|
+
const isObj = (val) => val && typeof val === 'object' && !Array.isArray(val);
|
|
314
|
+
export function deepMerge(target, source) {
|
|
315
|
+
const result = Object.assign({}, target);
|
|
316
|
+
Object.keys(source).forEach((key) => {
|
|
317
|
+
if (isObj(target[key]) && isObj(source[key])) {
|
|
318
|
+
result[key] = deepMerge(target[key], source[key]);
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
result[key] = source[key];
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
return result;
|
|
325
|
+
}
|
|
@@ -25,13 +25,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
25
25
|
*/
|
|
26
26
|
import axios from 'axios';
|
|
27
27
|
import * as rax from 'retry-axios';
|
|
28
|
-
import extend from 'extend';
|
|
29
28
|
import FormData from 'form-data';
|
|
30
29
|
import { Agent } from 'https';
|
|
31
30
|
import isStream from 'isstream';
|
|
32
31
|
import { stringify } from 'querystring';
|
|
33
32
|
import { gzipSync } from 'zlib';
|
|
34
|
-
import { buildRequestFileObject, isEmptyObject, isFileData, isFileWithMetadata, isJsonMimeType, stripTrailingSlash, } from './helper';
|
|
33
|
+
import { buildRequestFileObject, deepMerge, isEmptyObject, isFileData, isFileWithMetadata, isJsonMimeType, stripTrailingSlash, } from './helper';
|
|
35
34
|
import { redactSecrets } from './private-helpers';
|
|
36
35
|
import logger from './logger';
|
|
37
36
|
import { streamToPromise } from './stream-to-promise';
|
|
@@ -39,15 +38,10 @@ import { createCookieInterceptor } from './cookie-support';
|
|
|
39
38
|
import { chainError } from './chain-error';
|
|
40
39
|
export class RequestWrapper {
|
|
41
40
|
constructor(axiosOptions) {
|
|
42
|
-
axiosOptions
|
|
41
|
+
axiosOptions !== null && axiosOptions !== void 0 ? axiosOptions : (axiosOptions = {});
|
|
43
42
|
this.compressRequestData = Boolean(axiosOptions.enableGzipCompression);
|
|
44
|
-
// override a couple axios defaults
|
|
45
|
-
const axiosConfig = {
|
|
46
|
-
maxContentLength: -1,
|
|
47
|
-
maxBodyLength: Infinity,
|
|
48
|
-
};
|
|
49
|
-
// merge axios config into default
|
|
50
|
-
extend(true, axiosConfig, axiosOptions);
|
|
43
|
+
// override a couple axios defaults then merge axios config into default
|
|
44
|
+
const axiosConfig = Object.assign({ maxContentLength: -1, maxBodyLength: Infinity }, axiosOptions);
|
|
51
45
|
// if the user explicitly sets `disableSslVerification` to true,
|
|
52
46
|
// `rejectUnauthorized` must be set to false in the https agent
|
|
53
47
|
if (axiosOptions.disableSslVerification === true) {
|
|
@@ -196,7 +190,7 @@ export class RequestWrapper {
|
|
|
196
190
|
*/
|
|
197
191
|
sendRequest(parameters) {
|
|
198
192
|
return __awaiter(this, void 0, void 0, function* () {
|
|
199
|
-
const options =
|
|
193
|
+
const options = deepMerge(parameters.defaultOptions || {}, parameters.options || {});
|
|
200
194
|
const { path, body, form, formData, qs, method, serviceUrl, axiosOptions } = options;
|
|
201
195
|
let { headers, url } = options;
|
|
202
196
|
const multipartForm = new FormData();
|
|
@@ -249,10 +243,10 @@ export class RequestWrapper {
|
|
|
249
243
|
if (formData) {
|
|
250
244
|
data = multipartForm;
|
|
251
245
|
// form-data generates headers that MUST be included or the request will fail
|
|
252
|
-
headers =
|
|
246
|
+
headers = Object.assign(Object.assign({}, headers), multipartForm.getHeaders());
|
|
253
247
|
}
|
|
254
248
|
// accept gzip encoded responses if Accept-Encoding is not already set
|
|
255
|
-
headers['Accept-Encoding']
|
|
249
|
+
headers['Accept-Encoding'] || (headers['Accept-Encoding'] = 'gzip');
|
|
256
250
|
// compress request body data if enabled
|
|
257
251
|
if (this.compressRequestData) {
|
|
258
252
|
data = yield this.gzipRequestBody(data, headers);
|
package/ibm-cloud-sdk-core.d.ts
CHANGED
|
@@ -591,6 +591,8 @@ export declare class Cp4dTokenManager extends JwtTokenManager {
|
|
|
591
591
|
protected requestToken(): Promise<any>;
|
|
592
592
|
}
|
|
593
593
|
|
|
594
|
+
export declare function deepMerge(target: any, source: any): any;
|
|
595
|
+
|
|
594
596
|
export declare function fileExistsAtPath(filepath: string): boolean;
|
|
595
597
|
|
|
596
598
|
/**
|
package/lib/base-service.js
CHANGED
|
@@ -30,7 +30,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
30
30
|
};
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
32
|
exports.BaseService = void 0;
|
|
33
|
-
var extend_1 = __importDefault(require("extend"));
|
|
34
33
|
var auth_1 = require("../auth");
|
|
35
34
|
var helper_1 = require("./helper");
|
|
36
35
|
var logger_1 = __importDefault(require("./logger"));
|
|
@@ -224,7 +223,7 @@ var BaseService = /** @class */ (function () {
|
|
|
224
223
|
var userAgent = {
|
|
225
224
|
'User-Agent': this.defaultUserAgent,
|
|
226
225
|
};
|
|
227
|
-
parameters.defaultOptions.headers = (
|
|
226
|
+
parameters.defaultOptions.headers = __assign(__assign({}, userAgent), parameters.defaultOptions.headers);
|
|
228
227
|
return this.authenticator.authenticate(parameters.defaultOptions).then(function () {
|
|
229
228
|
// resolve() handles rejection as well, so resolving the result of sendRequest should allow for proper handling later
|
|
230
229
|
return _this.requestWrapperInstance.sendRequest(parameters);
|
package/lib/cookie-support.js
CHANGED
|
@@ -56,7 +56,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
56
56
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
57
|
exports.createCookieInterceptor = void 0;
|
|
58
58
|
var axios_1 = require("axios");
|
|
59
|
-
var extend_1 = __importDefault(require("extend"));
|
|
60
59
|
var tough_cookie_1 = require("tough-cookie");
|
|
61
60
|
var logger_1 = __importDefault(require("./logger"));
|
|
62
61
|
var internalCreateCookieInterceptor = function (cookieJar) {
|
|
@@ -69,7 +68,7 @@ var internalCreateCookieInterceptor = function (cookieJar) {
|
|
|
69
68
|
*/
|
|
70
69
|
function requestInterceptor(config) {
|
|
71
70
|
return __awaiter(this, void 0, void 0, function () {
|
|
72
|
-
var cookieHeaderValue
|
|
71
|
+
var cookieHeaderValue;
|
|
73
72
|
return __generator(this, function (_a) {
|
|
74
73
|
switch (_a.label) {
|
|
75
74
|
case 0:
|
|
@@ -81,8 +80,7 @@ var internalCreateCookieInterceptor = function (cookieJar) {
|
|
|
81
80
|
cookieHeaderValue = _a.sent();
|
|
82
81
|
if (cookieHeaderValue) {
|
|
83
82
|
logger_1.default.debug('CookieInterceptor: setting cookie header');
|
|
84
|
-
|
|
85
|
-
config.headers = (0, extend_1.default)(true, {}, config.headers, cookieHeader);
|
|
83
|
+
config.headers.cookie = cookieHeaderValue;
|
|
86
84
|
}
|
|
87
85
|
else {
|
|
88
86
|
logger_1.default.debug("CookieInterceptor: no cookies for: ".concat(config.url));
|
package/lib/helper.d.ts
CHANGED
|
@@ -126,3 +126,4 @@ export declare function constructServiceUrl(parameterizedUrl: string, defaultUrl
|
|
|
126
126
|
* @returns true if "mimeType" represents a JSON media type and false otherwise
|
|
127
127
|
*/
|
|
128
128
|
export declare function isJsonMimeType(mimeType: string): boolean;
|
|
129
|
+
export declare function deepMerge(target: any, source: any): any;
|
package/lib/helper.js
CHANGED
|
@@ -14,6 +14,17 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
17
28
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
29
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
30
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -63,7 +74,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
63
74
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
64
75
|
};
|
|
65
76
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
66
|
-
exports.isJsonMimeType = exports.constructServiceUrl = exports.toLowerKeys = exports.buildRequestFileObject = exports.getFormat = exports.isHTML = exports.validateParams = exports.getMissingParams = exports.getQueryParam = exports.stripTrailingSlash = exports.getContentType = exports.isEmptyObject = exports.isFileData = exports.isFileWithMetadata = void 0;
|
|
77
|
+
exports.deepMerge = exports.isJsonMimeType = exports.constructServiceUrl = exports.toLowerKeys = exports.buildRequestFileObject = exports.getFormat = exports.isHTML = exports.validateParams = exports.getMissingParams = exports.getQueryParam = exports.stripTrailingSlash = exports.getContentType = exports.isEmptyObject = exports.isFileData = exports.isFileWithMetadata = void 0;
|
|
67
78
|
var isstream_1 = require("isstream");
|
|
68
79
|
var mime_types_1 = require("mime-types");
|
|
69
80
|
var path_1 = require("path");
|
|
@@ -383,3 +394,17 @@ function isJsonMimeType(mimeType) {
|
|
|
383
394
|
return !!mimeType && /^application\/json(\s*;.*)?$/i.test(mimeType);
|
|
384
395
|
}
|
|
385
396
|
exports.isJsonMimeType = isJsonMimeType;
|
|
397
|
+
var isObj = function (val) { return val && typeof val === 'object' && !Array.isArray(val); };
|
|
398
|
+
function deepMerge(target, source) {
|
|
399
|
+
var result = __assign({}, target);
|
|
400
|
+
Object.keys(source).forEach(function (key) {
|
|
401
|
+
if (isObj(target[key]) && isObj(source[key])) {
|
|
402
|
+
result[key] = deepMerge(target[key], source[key]);
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
result[key] = source[key];
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
return result;
|
|
409
|
+
}
|
|
410
|
+
exports.deepMerge = deepMerge;
|
package/lib/request-wrapper.js
CHANGED
|
@@ -92,7 +92,6 @@ exports.RequestWrapper = void 0;
|
|
|
92
92
|
*/
|
|
93
93
|
var axios_1 = __importDefault(require("axios"));
|
|
94
94
|
var rax = __importStar(require("retry-axios"));
|
|
95
|
-
var extend_1 = __importDefault(require("extend"));
|
|
96
95
|
var form_data_1 = __importDefault(require("form-data"));
|
|
97
96
|
var https_1 = require("https");
|
|
98
97
|
var isstream_1 = __importDefault(require("isstream"));
|
|
@@ -107,15 +106,10 @@ var chain_error_1 = require("./chain-error");
|
|
|
107
106
|
var RequestWrapper = /** @class */ (function () {
|
|
108
107
|
function RequestWrapper(axiosOptions) {
|
|
109
108
|
var _this = this;
|
|
110
|
-
axiosOptions
|
|
109
|
+
axiosOptions !== null && axiosOptions !== void 0 ? axiosOptions : (axiosOptions = {});
|
|
111
110
|
this.compressRequestData = Boolean(axiosOptions.enableGzipCompression);
|
|
112
|
-
// override a couple axios defaults
|
|
113
|
-
var axiosConfig = {
|
|
114
|
-
maxContentLength: -1,
|
|
115
|
-
maxBodyLength: Infinity,
|
|
116
|
-
};
|
|
117
|
-
// merge axios config into default
|
|
118
|
-
(0, extend_1.default)(true, axiosConfig, axiosOptions);
|
|
111
|
+
// override a couple axios defaults then merge axios config into default
|
|
112
|
+
var axiosConfig = __assign({ maxContentLength: -1, maxBodyLength: Infinity }, axiosOptions);
|
|
119
113
|
// if the user explicitly sets `disableSslVerification` to true,
|
|
120
114
|
// `rejectUnauthorized` must be set to false in the https agent
|
|
121
115
|
if (axiosOptions.disableSslVerification === true) {
|
|
@@ -269,7 +263,7 @@ var RequestWrapper = /** @class */ (function () {
|
|
|
269
263
|
return __generator(this, function (_c) {
|
|
270
264
|
switch (_c.label) {
|
|
271
265
|
case 0:
|
|
272
|
-
options = (0,
|
|
266
|
+
options = (0, helper_1.deepMerge)(parameters.defaultOptions || {}, parameters.options || {});
|
|
273
267
|
path = options.path, body = options.body, form = options.form, formData = options.formData, qs = options.qs, method = options.method, serviceUrl = options.serviceUrl, axiosOptions = options.axiosOptions;
|
|
274
268
|
headers = options.headers, url = options.url;
|
|
275
269
|
multipartForm = new form_data_1.default();
|
|
@@ -333,10 +327,10 @@ var RequestWrapper = /** @class */ (function () {
|
|
|
333
327
|
if (formData) {
|
|
334
328
|
data = multipartForm;
|
|
335
329
|
// form-data generates headers that MUST be included or the request will fail
|
|
336
|
-
headers = (
|
|
330
|
+
headers = __assign(__assign({}, headers), multipartForm.getHeaders());
|
|
337
331
|
}
|
|
338
332
|
// accept gzip encoded responses if Accept-Encoding is not already set
|
|
339
|
-
headers['Accept-Encoding']
|
|
333
|
+
headers['Accept-Encoding'] || (headers['Accept-Encoding'] = 'gzip');
|
|
340
334
|
if (!this.compressRequestData) return [3 /*break*/, 9];
|
|
341
335
|
return [4 /*yield*/, this.gzipRequestBody(data, headers)];
|
|
342
336
|
case 8:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ibm-cloud-sdk-core",
|
|
3
|
-
"version": "5.4.
|
|
3
|
+
"version": "5.4.15",
|
|
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",
|
|
@@ -45,7 +45,6 @@
|
|
|
45
45
|
"camelcase": "6.3.0",
|
|
46
46
|
"debug": "4.3.4",
|
|
47
47
|
"dotenv": "16.4.5",
|
|
48
|
-
"extend": "3.0.2",
|
|
49
48
|
"file-type": "21.3.2",
|
|
50
49
|
"form-data": "4.0.4",
|
|
51
50
|
"isstream": "0.1.2",
|