postman-runtime 7.28.4 → 7.29.2
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 +26 -0
- package/README.md +3 -7
- package/dist/index.js +1 -1
- package/lib/authorizer/apikey.js +12 -11
- package/lib/authorizer/auth-interface.js +6 -6
- package/lib/authorizer/aws4.js +20 -20
- package/lib/authorizer/basic.js +12 -12
- package/lib/authorizer/bearer.js +12 -12
- package/lib/authorizer/digest.js +32 -31
- package/lib/authorizer/edgegrid.js +7 -7
- package/lib/authorizer/hawk.js +20 -20
- package/lib/authorizer/index.js +12 -8
- package/lib/authorizer/noauth.js +11 -11
- package/lib/authorizer/ntlm.js +21 -20
- package/lib/authorizer/oauth1.js +21 -21
- package/lib/authorizer/oauth2.js +12 -12
- package/lib/backpack/index.js +19 -19
- package/lib/requester/core-body-builder.js +16 -16
- package/lib/requester/core.js +25 -20
- package/lib/requester/dry-run.js +21 -21
- package/lib/requester/request-wrapper.js +6 -6
- package/lib/requester/requester-pool.js +1 -0
- package/lib/requester/requester.js +38 -43
- package/lib/runner/create-item-context.js +6 -6
- package/lib/runner/cursor.js +63 -63
- package/lib/runner/extensions/control.command.js +15 -14
- package/lib/runner/extensions/delay.command.js +12 -12
- package/lib/runner/extensions/event.command.js +33 -27
- package/lib/runner/extensions/http-request.command.js +20 -23
- package/lib/runner/extensions/item.command.js +6 -5
- package/lib/runner/extensions/request.command.js +12 -12
- package/lib/runner/extensions/waterfall.command.js +6 -6
- package/lib/runner/extract-runnable-items.js +25 -25
- package/lib/runner/index.js +20 -21
- package/lib/runner/instruction.js +11 -11
- package/lib/runner/replay-controller.js +6 -6
- package/lib/runner/request-helpers-postsend.js +5 -6
- package/lib/runner/request-helpers-presend.js +12 -16
- package/lib/runner/run.js +46 -41
- package/lib/runner/timings.js +7 -3
- package/lib/runner/util.js +10 -9
- package/lib/version.js +2 -2
- package/lib/visualizer/index.js +1 -1
- package/package.json +70 -74
|
@@ -77,6 +77,7 @@ getResponseJSON = function (response) {
|
|
|
77
77
|
/**
|
|
78
78
|
* Add options
|
|
79
79
|
* stopOnError:Boolean
|
|
80
|
+
*
|
|
80
81
|
* @type {Object}
|
|
81
82
|
*/
|
|
82
83
|
module.exports = {
|
|
@@ -89,12 +90,12 @@ module.exports = {
|
|
|
89
90
|
|
|
90
91
|
process: {
|
|
91
92
|
/**
|
|
92
|
-
* @param {Function=} callback
|
|
93
|
-
* @param {Object} payload
|
|
94
|
-
* @param {Function} next
|
|
93
|
+
* @param {Function=} callback -
|
|
94
|
+
* @param {Object} payload -
|
|
95
|
+
* @param {Function} next -
|
|
95
96
|
* @todo validate payload
|
|
96
97
|
*/
|
|
97
|
-
item
|
|
98
|
+
item (callback, payload, next) {
|
|
98
99
|
// adjust for polymorphic instructions
|
|
99
100
|
if (!next && _.isFunction(payload) && !_.isFunction(callback)) {
|
|
100
101
|
next = payload;
|
|
@@ -196,7 +197,7 @@ module.exports = {
|
|
|
196
197
|
this.triggers.item(null, coords, item); // @todo - should this trigger receive error?
|
|
197
198
|
|
|
198
199
|
return callback && callback.call(this, requestError, {
|
|
199
|
-
request
|
|
200
|
+
request
|
|
200
201
|
});
|
|
201
202
|
}
|
|
202
203
|
|
|
@@ -6,15 +6,15 @@ var _ = require('lodash'),
|
|
|
6
6
|
/**
|
|
7
7
|
* Resolve variables in item and auth in context.
|
|
8
8
|
*
|
|
9
|
-
* @param {ItemContext} context
|
|
10
|
-
* @param {Item} [context.item]
|
|
11
|
-
* @param {RequestAuth} [context.auth]
|
|
12
|
-
* @param {Object} payload
|
|
13
|
-
* @param {VariableScope} payload._variables
|
|
14
|
-
* @param {Object} payload.data
|
|
15
|
-
* @param {VariableScope} payload.environment
|
|
16
|
-
* @param {VariableScope} payload.collectionVariables
|
|
17
|
-
* @param {VariableScope} payload.globals
|
|
9
|
+
* @param {ItemContext} context -
|
|
10
|
+
* @param {Item} [context.item] -
|
|
11
|
+
* @param {RequestAuth} [context.auth] -
|
|
12
|
+
* @param {Object} payload -
|
|
13
|
+
* @param {VariableScope} payload._variables -
|
|
14
|
+
* @param {Object} payload.data -
|
|
15
|
+
* @param {VariableScope} payload.environment -
|
|
16
|
+
* @param {VariableScope} payload.collectionVariables -
|
|
17
|
+
* @param {VariableScope} payload.globals -
|
|
18
18
|
*/
|
|
19
19
|
resolveVariables = function (context, payload) {
|
|
20
20
|
if (!(context.item && context.item.request)) { return; }
|
|
@@ -36,7 +36,7 @@ var _ = require('lodash'),
|
|
|
36
36
|
// @todo - no need to sync variables when SDK starts supporting resolution from scope directly
|
|
37
37
|
// @todo - avoid resolving the entire item as this unnecessarily resolves URL
|
|
38
38
|
item = context.item = new sdk.Item(context.item.toObjectResolved(null,
|
|
39
|
-
variableDefinitions, {ignoreOwnVariables: true}));
|
|
39
|
+
variableDefinitions, { ignoreOwnVariables: true }));
|
|
40
40
|
|
|
41
41
|
auth = context.auth;
|
|
42
42
|
|
|
@@ -51,7 +51,7 @@ var _ = require('lodash'),
|
|
|
51
51
|
|
|
52
52
|
// resolve variables in auth
|
|
53
53
|
auth && (context.auth = new sdk.RequestAuth(auth.toObjectResolved(null,
|
|
54
|
-
variableDefinitions, {ignoreOwnVariables: true})));
|
|
54
|
+
variableDefinitions, { ignoreOwnVariables: true })));
|
|
55
55
|
};
|
|
56
56
|
|
|
57
57
|
module.exports = {
|
|
@@ -62,7 +62,7 @@ module.exports = {
|
|
|
62
62
|
triggers: ['response'],
|
|
63
63
|
|
|
64
64
|
process: {
|
|
65
|
-
request
|
|
65
|
+
request (payload, next) {
|
|
66
66
|
var abortOnError = _.has(payload, 'abortOnError') ? payload.abortOnError : this.options.abortOnError,
|
|
67
67
|
|
|
68
68
|
// helper function to trigger `response` callback anc complete the command
|
|
@@ -9,7 +9,7 @@ var _ = require('lodash'),
|
|
|
9
9
|
/**
|
|
10
10
|
* Returns a hash of IDs and Names of items in an array
|
|
11
11
|
*
|
|
12
|
-
* @param {Array} items
|
|
12
|
+
* @param {Array} items -
|
|
13
13
|
* @returns {Object}
|
|
14
14
|
*/
|
|
15
15
|
prepareLookupHash = function (items) {
|
|
@@ -111,12 +111,12 @@ module.exports = {
|
|
|
111
111
|
/**
|
|
112
112
|
* This processor simply queues scripts and requests in a linear chain.
|
|
113
113
|
*
|
|
114
|
-
* @param {Object} payload
|
|
115
|
-
* @param {Object} payload.coords
|
|
116
|
-
* @param {Boolean} [payload.static=false]
|
|
117
|
-
* @param {Function} next
|
|
114
|
+
* @param {Object} payload -
|
|
115
|
+
* @param {Object} payload.coords -
|
|
116
|
+
* @param {Boolean} [payload.static=false] -
|
|
117
|
+
* @param {Function} next -
|
|
118
118
|
*/
|
|
119
|
-
waterfall
|
|
119
|
+
waterfall (payload, next) {
|
|
120
120
|
// we procure the coordinates that we have to pick item and data from. the data is
|
|
121
121
|
var coords = payload.static ? payload.coords : this.waterfall.whatnext(payload.coords),
|
|
122
122
|
item = this.state.items[coords.position],
|
|
@@ -9,7 +9,7 @@ var sdk = require('postman-collection'),
|
|
|
9
9
|
* Accumulate all items in order if entry point is a collection/folder.
|
|
10
10
|
* If an item is passed returns an array with that item.
|
|
11
11
|
*
|
|
12
|
-
* @param {ItemGroup|Item} node
|
|
12
|
+
* @param {ItemGroup|Item} node -
|
|
13
13
|
*
|
|
14
14
|
* @returns {Array<Item>}
|
|
15
15
|
*
|
|
@@ -34,8 +34,8 @@ var sdk = require('postman-collection'),
|
|
|
34
34
|
/**
|
|
35
35
|
* Finds an item or item group based on id or name.
|
|
36
36
|
*
|
|
37
|
-
* @param {ItemGroup} itemGroup
|
|
38
|
-
* @param {?String} match
|
|
37
|
+
* @param {ItemGroup} itemGroup -
|
|
38
|
+
* @param {?String} match -
|
|
39
39
|
*
|
|
40
40
|
* @returns {Item|ItemGroup|undefined}
|
|
41
41
|
*/
|
|
@@ -72,7 +72,7 @@ var sdk = require('postman-collection'),
|
|
|
72
72
|
* @returns {Object} Found Items or ItemGroups.
|
|
73
73
|
*/
|
|
74
74
|
findItemsOrGroups = function (itemGroup, entrypointSubset, _continueAccumulation, _accumulatedItems) {
|
|
75
|
-
!_accumulatedItems && (_accumulatedItems = {members: [], reference: {}});
|
|
75
|
+
!_accumulatedItems && (_accumulatedItems = { members: [], reference: {} });
|
|
76
76
|
|
|
77
77
|
if (!itemGroup || !itemGroup.items) { return _accumulatedItems; }
|
|
78
78
|
|
|
@@ -109,11 +109,11 @@ var sdk = require('postman-collection'),
|
|
|
109
109
|
/**
|
|
110
110
|
* Finds an item or group from a path. The path should be an array of ids from the parent chain.
|
|
111
111
|
*
|
|
112
|
-
* @param {Collection} collection
|
|
113
|
-
* @param {Object} options
|
|
114
|
-
* @param {String} options.execute
|
|
115
|
-
* @param {?Array<String>} [options.path]
|
|
116
|
-
* @param {Function} callback
|
|
112
|
+
* @param {Collection} collection -
|
|
113
|
+
* @param {Object} options -
|
|
114
|
+
* @param {String} options.execute -
|
|
115
|
+
* @param {?Array<String>} [options.path] -
|
|
116
|
+
* @param {Function} callback -
|
|
117
117
|
*/
|
|
118
118
|
lookupByPath = function (collection, options, callback) {
|
|
119
119
|
var lookupPath,
|
|
@@ -139,10 +139,10 @@ var sdk = require('postman-collection'),
|
|
|
139
139
|
/**
|
|
140
140
|
* Finds an item or group on a collection with a matching id or name.
|
|
141
141
|
*
|
|
142
|
-
* @param {Collection} collection
|
|
143
|
-
* @param {Object} options
|
|
144
|
-
* @param {String} [options.execute]
|
|
145
|
-
* @param {Function} callback
|
|
142
|
+
* @param {Collection} collection -
|
|
143
|
+
* @param {Object} options -
|
|
144
|
+
* @param {String} [options.execute] -
|
|
145
|
+
* @param {Function} callback -
|
|
146
146
|
*/
|
|
147
147
|
lookupByIdOrName = function (collection, options, callback) {
|
|
148
148
|
var match = options.execute,
|
|
@@ -161,10 +161,10 @@ var sdk = require('postman-collection'),
|
|
|
161
161
|
*
|
|
162
162
|
* @note runnable items follows the order in which the items are defined in the collection
|
|
163
163
|
*
|
|
164
|
-
* @param {Collection} collection
|
|
165
|
-
* @param {Object} options
|
|
166
|
-
* @param {Array<String>} [options.execute]
|
|
167
|
-
* @param {Function} callback
|
|
164
|
+
* @param {Collection} collection -
|
|
165
|
+
* @param {Object} options -
|
|
166
|
+
* @param {Array<String>} [options.execute] -
|
|
167
|
+
* @param {Function} callback -
|
|
168
168
|
*/
|
|
169
169
|
lookupByMultipleIdOrName = function (collection, options, callback) {
|
|
170
170
|
var entrypoints = options.execute,
|
|
@@ -216,10 +216,10 @@ var sdk = require('postman-collection'),
|
|
|
216
216
|
*
|
|
217
217
|
* @note runnable items follows the order of entrypoints
|
|
218
218
|
*
|
|
219
|
-
* @param {Collection} collection
|
|
220
|
-
* @param {Object} options
|
|
221
|
-
* @param {Array<String>} [options.execute]
|
|
222
|
-
* @param {Function} callback
|
|
219
|
+
* @param {Collection} collection -
|
|
220
|
+
* @param {Object} options -
|
|
221
|
+
* @param {Array<String>} [options.execute] -
|
|
222
|
+
* @param {Function} callback -
|
|
223
223
|
*/
|
|
224
224
|
lookupByOrder = function (collection, options, callback) {
|
|
225
225
|
var entrypoints = options.execute,
|
|
@@ -267,13 +267,13 @@ var sdk = require('postman-collection'),
|
|
|
267
267
|
/**
|
|
268
268
|
* Extracts all the items on a collection starting from the entrypoint.
|
|
269
269
|
*
|
|
270
|
-
* @param {Collection} collection
|
|
271
|
-
* @param {?Object} [entrypoint]
|
|
270
|
+
* @param {Collection} collection -
|
|
271
|
+
* @param {?Object} [entrypoint] -
|
|
272
272
|
* @param {String} [entrypoint.execute] id of item or group to execute (can be name when used with `idOrName`)
|
|
273
273
|
* @param {Array<String>} [entrypoint.path] path leading to the item or group selected (only for `path` strategy)
|
|
274
274
|
* @param {String} [entrypoint.lookupStrategy=idOrName] strategy to use for entrypoint lookup [idOrName, path]
|
|
275
275
|
* @param {Boolean} [entrypoint.preserveOrder] option to preserve the order of folder/items when specified.
|
|
276
|
-
* @param {Function} callback
|
|
276
|
+
* @param {Function} callback -
|
|
277
277
|
*/
|
|
278
278
|
extractRunnableItems = function (collection, entrypoint, callback) {
|
|
279
279
|
var lookupFunction,
|
|
@@ -292,5 +292,5 @@ var sdk = require('postman-collection'),
|
|
|
292
292
|
};
|
|
293
293
|
|
|
294
294
|
module.exports = {
|
|
295
|
-
extractRunnableItems
|
|
295
|
+
extractRunnableItems
|
|
296
296
|
};
|
package/lib/runner/index.js
CHANGED
|
@@ -21,7 +21,7 @@ var _ = require('lodash'),
|
|
|
21
21
|
/**
|
|
22
22
|
* @constructor
|
|
23
23
|
*
|
|
24
|
-
* @param {Object} [options]
|
|
24
|
+
* @param {Object} [options] -
|
|
25
25
|
*/
|
|
26
26
|
Runner = function PostmanCollectionRunner (options) { // eslint-disable-line func-name-matching
|
|
27
27
|
this.options = _.assign({}, options);
|
|
@@ -31,13 +31,13 @@ _.assign(Runner.prototype, {
|
|
|
31
31
|
/**
|
|
32
32
|
* Prepares `run` config by combining `runner` config with given run options.
|
|
33
33
|
*
|
|
34
|
-
* @param {Object} [options]
|
|
35
|
-
* @param {Object} [options.timeout]
|
|
36
|
-
* @param {Object} [options.timeout.global]
|
|
37
|
-
* @param {Object} [options.timeout.request]
|
|
38
|
-
* @param {Object} [options.timeout.script]
|
|
34
|
+
* @param {Object} [options] -
|
|
35
|
+
* @param {Object} [options.timeout] -
|
|
36
|
+
* @param {Object} [options.timeout.global] -
|
|
37
|
+
* @param {Object} [options.timeout.request] -
|
|
38
|
+
* @param {Object} [options.timeout.script] -
|
|
39
39
|
*/
|
|
40
|
-
prepareRunConfig
|
|
40
|
+
prepareRunConfig (options) {
|
|
41
41
|
// combine runner config and make a copy
|
|
42
42
|
var runOptions = _.merge(_.omit(options, ['environment', 'globals', 'data']), this.options.run) || {};
|
|
43
43
|
|
|
@@ -58,26 +58,25 @@ _.assign(Runner.prototype, {
|
|
|
58
58
|
/**
|
|
59
59
|
* Runs a collection or a folder.
|
|
60
60
|
*
|
|
61
|
-
* @param {Collection} collection
|
|
62
|
-
* @param {Object} [options]
|
|
63
|
-
* @param {Array.<Item>} options.items
|
|
64
|
-
* @param {Array.<Object>} [options.data]
|
|
65
|
-
* @param {Object} [options.globals]
|
|
66
|
-
* @param {Object} [options.environment]
|
|
67
|
-
* @param {Number} [options.iterationCount]
|
|
68
|
-
* @param {CertificateList} [options.certificates]
|
|
69
|
-
* @param {ProxyConfigList} [options.proxies]
|
|
70
|
-
* @param {
|
|
71
|
-
* @param {Object} [options.entrypoint]
|
|
61
|
+
* @param {Collection} collection -
|
|
62
|
+
* @param {Object} [options] -
|
|
63
|
+
* @param {Array.<Item>} options.items -
|
|
64
|
+
* @param {Array.<Object>} [options.data] -
|
|
65
|
+
* @param {Object} [options.globals] -
|
|
66
|
+
* @param {Object} [options.environment] -
|
|
67
|
+
* @param {Number} [options.iterationCount] -
|
|
68
|
+
* @param {CertificateList} [options.certificates] -
|
|
69
|
+
* @param {ProxyConfigList} [options.proxies] -
|
|
70
|
+
* @param {Object} [options.entrypoint] -
|
|
72
71
|
* @param {String} [options.entrypoint.execute] ID of the item-group to be run.
|
|
73
72
|
* Can be Name if `entrypoint.lookupStrategy` is `idOrName`
|
|
74
73
|
* @param {String} [options.entrypoint.lookupStrategy=idOrName] strategy to lookup the entrypoint [idOrName, path]
|
|
75
74
|
* @param {Array<String>} [options.entrypoint.path] path to lookup
|
|
76
75
|
* @param {Object} [options.run] Run-specific options, such as options related to the host
|
|
77
76
|
*
|
|
78
|
-
* @param {Function} callback
|
|
77
|
+
* @param {Function} callback -
|
|
79
78
|
*/
|
|
80
|
-
run
|
|
79
|
+
run (collection, options, callback) {
|
|
81
80
|
var self = this,
|
|
82
81
|
runOptions = this.prepareRunConfig(options);
|
|
83
82
|
|
|
@@ -130,7 +129,7 @@ _.assign(Runner, {
|
|
|
130
129
|
*
|
|
131
130
|
* @type {Run}
|
|
132
131
|
*/
|
|
133
|
-
Run
|
|
132
|
+
Run
|
|
134
133
|
});
|
|
135
134
|
|
|
136
135
|
module.exports = Runner;
|
|
@@ -92,10 +92,10 @@ pool = function (processors) {
|
|
|
92
92
|
/**
|
|
93
93
|
* Shortcut to `new Instruction(...);`
|
|
94
94
|
*
|
|
95
|
-
* @param {Function} processor
|
|
96
|
-
* @param {String} name
|
|
97
|
-
* @param {Object} [payload]
|
|
98
|
-
* @param {Array} [args]
|
|
95
|
+
* @param {Function} processor -
|
|
96
|
+
* @param {String} name -
|
|
97
|
+
* @param {Object} [payload] -
|
|
98
|
+
* @param {Array} [args] -
|
|
99
99
|
*
|
|
100
100
|
* @returns {Instruction}
|
|
101
101
|
*/
|
|
@@ -113,8 +113,8 @@ pool = function (processors) {
|
|
|
113
113
|
/**
|
|
114
114
|
* Executes an instruction with previously saved payload and arguments
|
|
115
115
|
*
|
|
116
|
-
* @param {Function} callback
|
|
117
|
-
* @param {*} [scope]
|
|
116
|
+
* @param {Function} callback -
|
|
117
|
+
* @param {*} [scope] -
|
|
118
118
|
*
|
|
119
119
|
* @todo: use timeback and control it via options sent during pool creation as an option
|
|
120
120
|
*/
|
|
@@ -148,7 +148,7 @@ pool = function (processors) {
|
|
|
148
148
|
_.isArray(this._done) && _.invokeMap(this._done, _.apply, scope, _.tail(arguments));
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
setTimeout(callback.bind
|
|
151
|
+
setTimeout(callback.bind(...args), 0);
|
|
152
152
|
}.bind(this);
|
|
153
153
|
|
|
154
154
|
// add two additional arguments at the end of the arguments saved - i.e. the payload and a function to call the
|
|
@@ -186,20 +186,20 @@ pool = function (processors) {
|
|
|
186
186
|
};
|
|
187
187
|
|
|
188
188
|
Instruction.shift = function () {
|
|
189
|
-
return Instruction._queue.shift
|
|
189
|
+
return Instruction._queue.shift(...arguments);
|
|
190
190
|
};
|
|
191
191
|
|
|
192
192
|
Instruction.unshift = function () {
|
|
193
|
-
return Instruction._queue.unshift
|
|
193
|
+
return Instruction._queue.unshift(...arguments);
|
|
194
194
|
};
|
|
195
195
|
|
|
196
196
|
Instruction.push = function () {
|
|
197
|
-
return Instruction._queue.push
|
|
197
|
+
return Instruction._queue.push(...arguments);
|
|
198
198
|
};
|
|
199
199
|
|
|
200
200
|
return Instruction;
|
|
201
201
|
};
|
|
202
202
|
|
|
203
203
|
module.exports = {
|
|
204
|
-
pool
|
|
204
|
+
pool
|
|
205
205
|
};
|
|
@@ -10,8 +10,8 @@ var _ = require('lodash'),
|
|
|
10
10
|
* Handles replay logic with replayState from context.
|
|
11
11
|
* Makes sure request replays do not go into an infinite loop.
|
|
12
12
|
*
|
|
13
|
-
* @param {ReplayState} replayState
|
|
14
|
-
* @param {Run} run
|
|
13
|
+
* @param {ReplayState} replayState -
|
|
14
|
+
* @param {Run} run -
|
|
15
15
|
*
|
|
16
16
|
* @constructor
|
|
17
17
|
*/
|
|
@@ -25,13 +25,13 @@ _.assign(ReplayController.prototype, /** @lends ReplayController.prototype */{
|
|
|
25
25
|
/**
|
|
26
26
|
* Sends a request in the item. This takes care of limiting the total number of replays for a request.
|
|
27
27
|
*
|
|
28
|
-
* @param {Object} context
|
|
29
|
-
* @param {Request} item
|
|
28
|
+
* @param {Object} context -
|
|
29
|
+
* @param {Request} item -
|
|
30
30
|
* @param {Object} desiredPayload a partial payload to use for the replay request
|
|
31
31
|
* @param {Function} success this callback is invoked when replay controller sent the request
|
|
32
32
|
* @param {Function} failure this callback is invoked when replay controller decided not to send the request
|
|
33
33
|
*/
|
|
34
|
-
requestReplay
|
|
34
|
+
requestReplay (context, item, desiredPayload, success, failure) {
|
|
35
35
|
// max retries exceeded
|
|
36
36
|
if (this.count >= MAX_REPLAY_COUNT) {
|
|
37
37
|
return failure(new Error('runtime: maximum intermediate request limit exceeded'));
|
|
@@ -66,7 +66,7 @@ _.assign(ReplayController.prototype, /** @lends ReplayController.prototype */{
|
|
|
66
66
|
*
|
|
67
67
|
* @returns {ReplayState}
|
|
68
68
|
*/
|
|
69
|
-
getReplayState
|
|
69
|
+
getReplayState () {
|
|
70
70
|
/**
|
|
71
71
|
* Defines the current replay state of a request.
|
|
72
72
|
*
|
|
@@ -32,7 +32,8 @@ module.exports = [
|
|
|
32
32
|
authHandler.post(authInterface, context.response, function (err, success) {
|
|
33
33
|
// sync all auth system parameters to the original auth
|
|
34
34
|
originalAuthParams && auth.parameters().each(function (param) {
|
|
35
|
-
param && param.system &&
|
|
35
|
+
param && param.system &&
|
|
36
|
+
originalAuthParams.upsert({ key: param.key, value: param.value, system: true });
|
|
36
37
|
});
|
|
37
38
|
|
|
38
39
|
// sync auth state back to item request
|
|
@@ -41,12 +42,10 @@ module.exports = [
|
|
|
41
42
|
// there was an error in auth post hook
|
|
42
43
|
// warn the user but don't bubble it up
|
|
43
44
|
if (err) {
|
|
44
|
-
run.triggers.console(
|
|
45
|
-
context.coords,
|
|
45
|
+
run.triggers.console(context.coords,
|
|
46
46
|
'warn',
|
|
47
47
|
'runtime~' + auth.type + '.auth: there was an error validating auth: ' + (err.message || err),
|
|
48
|
-
err
|
|
49
|
-
);
|
|
48
|
+
err);
|
|
50
49
|
|
|
51
50
|
return done();
|
|
52
51
|
}
|
|
@@ -55,7 +54,7 @@ module.exports = [
|
|
|
55
54
|
if (success) { return done(); }
|
|
56
55
|
|
|
57
56
|
// request a replay of request
|
|
58
|
-
done(null, {replay: true, helper: auth.type + DOT_AUTH});
|
|
57
|
+
done(null, { replay: true, helper: auth.type + DOT_AUTH });
|
|
59
58
|
});
|
|
60
59
|
}
|
|
61
60
|
];
|
|
@@ -43,9 +43,9 @@ module.exports = [
|
|
|
43
43
|
async.waterfall([async.constant(data), {
|
|
44
44
|
// form data parsing simply "enriches" all form parameters having file data type by replacing / setting the
|
|
45
45
|
// value as a read stream
|
|
46
|
-
formdata
|
|
46
|
+
formdata (formdata, next) {
|
|
47
47
|
// ensure that we only process the file type
|
|
48
|
-
async.eachSeries(_.filter(formdata.all(), {type: 'file'}), function (formparam, callback) {
|
|
48
|
+
async.eachSeries(_.filter(formdata.all(), { type: 'file' }), function (formparam, callback) {
|
|
49
49
|
if (!formparam || formparam.disabled) {
|
|
50
50
|
return callback(); // disabled params will be filtered in body-builder.
|
|
51
51
|
}
|
|
@@ -100,7 +100,7 @@ module.exports = [
|
|
|
100
100
|
return next(); // swallow the error
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
next(null, {src: src, value: stream});
|
|
103
|
+
next(null, { src: src, value: stream });
|
|
104
104
|
});
|
|
105
105
|
}, function (err, results) {
|
|
106
106
|
if (err) {
|
|
@@ -123,7 +123,7 @@ module.exports = [
|
|
|
123
123
|
}, next);
|
|
124
124
|
},
|
|
125
125
|
// file data
|
|
126
|
-
file
|
|
126
|
+
file (filedata, next) {
|
|
127
127
|
// eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
128
128
|
util.createReadStream(resolver, filedata.src, function (err, stream) {
|
|
129
129
|
if (err) {
|
|
@@ -175,8 +175,7 @@ module.exports = [
|
|
|
175
175
|
run.triggers.console(context.coords,
|
|
176
176
|
'warn',
|
|
177
177
|
'runtime~' + authType + '.auth: could not sign the request: ' + (err.message || err),
|
|
178
|
-
err
|
|
179
|
-
);
|
|
178
|
+
err);
|
|
180
179
|
|
|
181
180
|
// swallow the error, we've warned the user
|
|
182
181
|
done();
|
|
@@ -211,8 +210,7 @@ module.exports = [
|
|
|
211
210
|
run.triggers.console(context.coords,
|
|
212
211
|
'warn',
|
|
213
212
|
'runtime~' + authType + '.auth: could not validate the request: ' + (err.message || err),
|
|
214
|
-
err
|
|
215
|
-
);
|
|
213
|
+
err);
|
|
216
214
|
|
|
217
215
|
// swallow the error, we've warned the user
|
|
218
216
|
return done();
|
|
@@ -221,7 +219,7 @@ module.exports = [
|
|
|
221
219
|
// sync all auth system parameters to the original auth
|
|
222
220
|
originalAuthParams && auth.parameters().each(function (param) {
|
|
223
221
|
param && param.system &&
|
|
224
|
-
originalAuthParams.upsert({key: param.key, value: param.value, system: true});
|
|
222
|
+
originalAuthParams.upsert({ key: param.key, value: param.value, system: true });
|
|
225
223
|
});
|
|
226
224
|
|
|
227
225
|
// authHandler gave a go, sign the request
|
|
@@ -232,14 +230,14 @@ module.exports = [
|
|
|
232
230
|
|
|
233
231
|
// prepare for sending intermediate request
|
|
234
232
|
var replayController = new ReplayController(context.replayState, run),
|
|
235
|
-
item = new sdk.Item({request
|
|
233
|
+
item = new sdk.Item({ request });
|
|
236
234
|
|
|
237
235
|
// auth handler gave a no go, and an intermediate request.
|
|
238
236
|
// make the intermediate request the response is passed to `init` hook
|
|
239
237
|
replayController.requestReplay(context,
|
|
240
238
|
item,
|
|
241
239
|
// marks the auth as source for intermediate request
|
|
242
|
-
{source: auth.type + DOT_AUTH},
|
|
240
|
+
{ source: auth.type + DOT_AUTH },
|
|
243
241
|
function (err, response) {
|
|
244
242
|
// errors for intermediate requests are passed to request callback
|
|
245
243
|
// passing it here will add it to original request as well, so don't do it
|
|
@@ -263,14 +261,12 @@ module.exports = [
|
|
|
263
261
|
function (err) {
|
|
264
262
|
// warn users that maximum retries have exceeded
|
|
265
263
|
if (err) {
|
|
266
|
-
run.triggers.console(
|
|
267
|
-
|
|
268
|
-
);
|
|
264
|
+
run.triggers.console(context.coords,
|
|
265
|
+
'warn', 'runtime~' + authType + '.auth: ' + (err.message || err));
|
|
269
266
|
}
|
|
270
267
|
// but don't bubble up the error with the request
|
|
271
268
|
done();
|
|
272
|
-
}
|
|
273
|
-
);
|
|
269
|
+
});
|
|
274
270
|
});
|
|
275
271
|
};
|
|
276
272
|
|