postman-runtime 7.31.3 → 7.32.0
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/CHANGELOG.yaml +17 -8
- package/dist/index.js +1 -1
- package/lib/authorizer/jwt.js +11 -4
- package/lib/requester/dry-run.js +43 -4
- package/lib/runner/request-helpers-presend.js +37 -1
- package/package.json +6 -5
package/lib/authorizer/jwt.js
CHANGED
|
@@ -55,15 +55,19 @@ const _ = require('lodash'),
|
|
|
55
55
|
*/
|
|
56
56
|
function addTokenToRequest (auth, request, jwtToken) {
|
|
57
57
|
const addTokenTo = auth.get(AUTH_KEYS.ADD_TOKEN_TO) || ADD_TOKEN_TO_TARGETS.HEADER,
|
|
58
|
-
queryParamKey = auth.get(AUTH_KEYS.QUERY_PARAM_KEY) || QUERY_KEY
|
|
59
|
-
headerPrefix = auth.get(AUTH_KEYS.HEADER_PREFIX) || BEARER_AUTH_PREFIX;
|
|
58
|
+
queryParamKey = auth.get(AUTH_KEYS.QUERY_PARAM_KEY) || QUERY_KEY;
|
|
60
59
|
|
|
61
60
|
if (addTokenTo === ADD_TOKEN_TO_TARGETS.HEADER) {
|
|
62
61
|
request.removeHeader(AUTHORIZATION, { ignoreCase: true });
|
|
63
62
|
|
|
63
|
+
let headerPrefix = auth.get(AUTH_KEYS.HEADER_PREFIX);
|
|
64
|
+
|
|
65
|
+
headerPrefix = _.isNil(headerPrefix) ? BEARER_AUTH_PREFIX : headerPrefix;
|
|
66
|
+
headerPrefix && (headerPrefix += SPACE);
|
|
67
|
+
|
|
64
68
|
request.addHeader({
|
|
65
69
|
key: AUTHORIZATION,
|
|
66
|
-
value: headerPrefix +
|
|
70
|
+
value: headerPrefix + jwtToken,
|
|
67
71
|
system: true
|
|
68
72
|
});
|
|
69
73
|
}
|
|
@@ -94,7 +98,10 @@ function addTokenToRequest (auth, request, jwtToken) {
|
|
|
94
98
|
* is encoded in base64 format
|
|
95
99
|
* privateKey: <string> - PEM format private key for RS, PS, ES algorithms
|
|
96
100
|
* addTokenTo: <string> - possible values - header | queryParam,
|
|
97
|
-
* headerPrefix: <string> - prefix added before jwt token in header
|
|
101
|
+
* headerPrefix: <string> - prefix added before jwt token in header
|
|
102
|
+
* If headerPrefix is null | undefined - `Authorization:Bearer + SPACE + JWT_TOKEN`
|
|
103
|
+
* If headerPrefix is valid string - `Authorization:HEADER_PREFIX + SPACE + JWT_TOKEN`
|
|
104
|
+
* If headerPrefix is empty string - `Authorization:JWT_TOKEN`
|
|
98
105
|
* queryParamKey: <string> - optional property added when <addTokenTo> set to [queryParam],
|
|
99
106
|
* }
|
|
100
107
|
* }
|
package/lib/requester/dry-run.js
CHANGED
|
@@ -11,6 +11,7 @@ const _ = require('lodash'),
|
|
|
11
11
|
authorizeRequest = require('../authorizer').authorizeRequest,
|
|
12
12
|
authHandlers = require('../authorizer').AuthLoader.handlers,
|
|
13
13
|
version = require('../../package.json').version,
|
|
14
|
+
stripJSONComments = require('strip-json-comments'),
|
|
14
15
|
|
|
15
16
|
CALCULATED_AT_RUNTIME = '<calculated when request is sent>',
|
|
16
17
|
COOKIE = 'Cookie',
|
|
@@ -19,6 +20,8 @@ const _ = require('lodash'),
|
|
|
19
20
|
DEFAULT_MIME_TYPE = 'application/octet-stream',
|
|
20
21
|
CONTENT_TYPE_URLENCODED = 'application/x-www-form-urlencoded',
|
|
21
22
|
CONTENT_TYPE_FORMDATA = 'multipart/form-data; boundary=' + CALCULATED_AT_RUNTIME,
|
|
23
|
+
STRING = 'string',
|
|
24
|
+
CONTENT_LANGUAGE_JSON = 'json',
|
|
22
25
|
|
|
23
26
|
CONTENT_TYPE_LANGUAGE = {
|
|
24
27
|
html: 'text/html',
|
|
@@ -197,6 +200,39 @@ function setContentType (request, callback) {
|
|
|
197
200
|
callback(null, request);
|
|
198
201
|
}
|
|
199
202
|
|
|
203
|
+
/**
|
|
204
|
+
* Remove comments if the data mode is raw and content type is application/json
|
|
205
|
+
*
|
|
206
|
+
* @private
|
|
207
|
+
* @param {Request} request -
|
|
208
|
+
* @param {Function} callback -
|
|
209
|
+
*/
|
|
210
|
+
function sanitizeRawBody (request, callback) {
|
|
211
|
+
let language = _.get(request, 'body.options.raw.language'),
|
|
212
|
+
content = _.get(request, 'body.raw');
|
|
213
|
+
|
|
214
|
+
// bail out if raw language is not json or content is not present
|
|
215
|
+
if (!(content && language === CONTENT_LANGUAGE_JSON)) {
|
|
216
|
+
return callback(null, request);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (typeof content !== STRING) {
|
|
220
|
+
content = JSON.stringify(content);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// bail out if no comments present in content
|
|
224
|
+
if (!(content.includes('//') || content.includes('/*'))) {
|
|
225
|
+
return callback(null, request);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// stripJSONComments throws error if the content is not string
|
|
229
|
+
// here were have already converted the content to string in previous step
|
|
230
|
+
// hence we are do not have a safety check here.
|
|
231
|
+
request.body.raw = stripJSONComments(content, { whitespace: false });
|
|
232
|
+
|
|
233
|
+
callback(null, request);
|
|
234
|
+
}
|
|
235
|
+
|
|
200
236
|
/**
|
|
201
237
|
* Adds Cookie header for the given request url.
|
|
202
238
|
*
|
|
@@ -254,12 +290,15 @@ function dryRun (request, options, done) {
|
|
|
254
290
|
disableCookies = _.get(options.protocolProfileBehavior, 'disableCookies');
|
|
255
291
|
|
|
256
292
|
async.waterfall([
|
|
257
|
-
function
|
|
258
|
-
setAuthorization(request, next);
|
|
259
|
-
},
|
|
260
|
-
function setContentTypeHeader (request, next) {
|
|
293
|
+
function setContentTypeHeader (next) {
|
|
261
294
|
setContentType(request, next);
|
|
262
295
|
},
|
|
296
|
+
function sanitizeRawBodyContent (request, next) {
|
|
297
|
+
sanitizeRawBody(request, next);
|
|
298
|
+
},
|
|
299
|
+
function setAuthorizationHeaders (request, next) {
|
|
300
|
+
setAuthorization(request, next);
|
|
301
|
+
},
|
|
263
302
|
function setContentLength (request, next) {
|
|
264
303
|
var headers = request.headers,
|
|
265
304
|
header = headers.one('content-length');
|
|
@@ -1,15 +1,51 @@
|
|
|
1
|
-
|
|
1
|
+
const _ = require('lodash'),
|
|
2
2
|
async = require('async'),
|
|
3
3
|
util = require('./util'),
|
|
4
4
|
sdk = require('postman-collection'),
|
|
5
|
+
stripJSONComments = require('strip-json-comments'),
|
|
5
6
|
|
|
6
7
|
createAuthInterface = require('../authorizer/auth-interface'),
|
|
7
8
|
AuthLoader = require('../authorizer/index').AuthLoader,
|
|
8
9
|
ReplayController = require('./replay-controller'),
|
|
10
|
+
{ getRequestBody } = require('../requester/core'),
|
|
9
11
|
|
|
12
|
+
CONTENT_LANGUAGE_JSON = 'json',
|
|
13
|
+
STRING = 'string',
|
|
10
14
|
DOT_AUTH = '.auth';
|
|
11
15
|
|
|
12
16
|
module.exports = [
|
|
17
|
+
// Raw request body update
|
|
18
|
+
function (context, run, done) {
|
|
19
|
+
if (!context.item) { return done(new Error('Nothing to update body.')); }
|
|
20
|
+
|
|
21
|
+
let request = _.get(context.item, 'request'),
|
|
22
|
+
requestBody = _.get(request, 'body'),
|
|
23
|
+
rawContent;
|
|
24
|
+
|
|
25
|
+
// bail out if raw language is not json
|
|
26
|
+
if (_.get(requestBody, 'options.raw.language') !== CONTENT_LANGUAGE_JSON) {
|
|
27
|
+
return done();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// here we are using the core `getRequestBody` to cover the cases
|
|
31
|
+
// where request body is not sent (disableBodyPruning)
|
|
32
|
+
rawContent = getRequestBody(request, context.protocolProfileBehavior);
|
|
33
|
+
|
|
34
|
+
// bail out if there is no request body to sanitize
|
|
35
|
+
if (!(rawContent && rawContent.body && typeof rawContent.body === STRING)) {
|
|
36
|
+
return done();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// bail out if no comments present in raw body
|
|
40
|
+
if (!(rawContent.body.includes('//') || rawContent.body.includes('/*'))) {
|
|
41
|
+
return done();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// NOTE: mutates context.item request body
|
|
45
|
+
requestBody.raw = stripJSONComments(rawContent.body, { whitespace: false });
|
|
46
|
+
|
|
47
|
+
done();
|
|
48
|
+
},
|
|
13
49
|
// File loading
|
|
14
50
|
function (context, run, done) {
|
|
15
51
|
if (!context.item) { return done(new Error('Nothing to resolve files for.')); }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postman-runtime",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.32.0",
|
|
4
4
|
"description": "Underlying library of executing Postman Collections",
|
|
5
5
|
"author": "Postman Inc.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"async": "3.2.4",
|
|
47
47
|
"aws4": "1.12.0",
|
|
48
48
|
"handlebars": "4.7.7",
|
|
49
|
-
"httpntlm": "1.8.
|
|
50
|
-
"jose": "4.
|
|
49
|
+
"httpntlm": "1.8.10",
|
|
50
|
+
"jose": "4.13.1",
|
|
51
51
|
"js-sha512": "0.8.0",
|
|
52
52
|
"lodash": "4.17.21",
|
|
53
53
|
"mime-types": "2.1.35",
|
|
@@ -58,6 +58,7 @@
|
|
|
58
58
|
"postman-sandbox": "4.2.4",
|
|
59
59
|
"postman-url-encoder": "3.0.5",
|
|
60
60
|
"serialised-error": "1.1.3",
|
|
61
|
+
"strip-json-comments": "3.1.1",
|
|
61
62
|
"uuid": "8.3.2"
|
|
62
63
|
},
|
|
63
64
|
"devDependencies": {
|
|
@@ -91,9 +92,9 @@
|
|
|
91
92
|
"shelljs": "^0.8.5",
|
|
92
93
|
"sinon": "^12.0.1",
|
|
93
94
|
"teleport-javascript": "^1.0.0",
|
|
94
|
-
"terser": "^5.16.
|
|
95
|
+
"terser": "^5.16.8",
|
|
95
96
|
"tmp": "^0.2.1",
|
|
96
|
-
"webpack": "^5.
|
|
97
|
+
"webpack": "^5.77.0",
|
|
97
98
|
"yankee": "^1.0.8"
|
|
98
99
|
},
|
|
99
100
|
"engines": {
|