postman-runtime 7.28.3 → 7.29.1

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.
Files changed (44) hide show
  1. package/CHANGELOG.yaml +30 -0
  2. package/README.md +3 -7
  3. package/dist/index.js +1 -1
  4. package/lib/authorizer/apikey.js +12 -11
  5. package/lib/authorizer/auth-interface.js +6 -6
  6. package/lib/authorizer/aws4.js +20 -20
  7. package/lib/authorizer/basic.js +12 -12
  8. package/lib/authorizer/bearer.js +12 -12
  9. package/lib/authorizer/digest.js +32 -31
  10. package/lib/authorizer/edgegrid.js +7 -7
  11. package/lib/authorizer/hawk.js +20 -20
  12. package/lib/authorizer/index.js +12 -8
  13. package/lib/authorizer/noauth.js +11 -11
  14. package/lib/authorizer/ntlm.js +43 -22
  15. package/lib/authorizer/oauth1.js +21 -21
  16. package/lib/authorizer/oauth2.js +12 -12
  17. package/lib/backpack/index.js +19 -19
  18. package/lib/requester/core-body-builder.js +16 -16
  19. package/lib/requester/core.js +25 -20
  20. package/lib/requester/dry-run.js +21 -21
  21. package/lib/requester/request-wrapper.js +6 -6
  22. package/lib/requester/requester-pool.js +1 -0
  23. package/lib/requester/requester.js +38 -43
  24. package/lib/runner/create-item-context.js +6 -6
  25. package/lib/runner/cursor.js +63 -63
  26. package/lib/runner/extensions/control.command.js +15 -14
  27. package/lib/runner/extensions/delay.command.js +12 -12
  28. package/lib/runner/extensions/event.command.js +33 -27
  29. package/lib/runner/extensions/http-request.command.js +20 -23
  30. package/lib/runner/extensions/item.command.js +6 -5
  31. package/lib/runner/extensions/request.command.js +12 -12
  32. package/lib/runner/extensions/waterfall.command.js +6 -6
  33. package/lib/runner/extract-runnable-items.js +25 -25
  34. package/lib/runner/index.js +20 -21
  35. package/lib/runner/instruction.js +14 -11
  36. package/lib/runner/replay-controller.js +6 -6
  37. package/lib/runner/request-helpers-postsend.js +5 -6
  38. package/lib/runner/request-helpers-presend.js +12 -16
  39. package/lib/runner/run.js +46 -41
  40. package/lib/runner/timings.js +7 -3
  41. package/lib/runner/util.js +10 -9
  42. package/lib/version.js +2 -2
  43. package/lib/visualizer/index.js +1 -1
  44. package/package.json +71 -75
@@ -16,6 +16,7 @@ var _ = require('lodash'),
16
16
  * privateKey: 'string',
17
17
  * privateValue: 'string'
18
18
  * }
19
+ *
19
20
  * @implements {AuthHandlerInterface}
20
21
  */
21
22
  module.exports = {
@@ -43,9 +44,9 @@ module.exports = {
43
44
  * Initializes an item (extracts parameters from intermediate requests if any, etc)
44
45
  * before the actual authorization step
45
46
  *
46
- * @param {AuthInterface} auth
47
- * @param {Response} response
48
- * @param {AuthHandlerInterface~authInitHookCallback} done
47
+ * @param {AuthInterface} auth -
48
+ * @param {Response} response -
49
+ * @param {AuthHandlerInterface~authInitHookCallback} done -
49
50
  */
50
51
  init: function (auth, response, done) {
51
52
  done();
@@ -54,8 +55,8 @@ module.exports = {
54
55
  /**
55
56
  * Verifies whether the request has required parameters
56
57
  *
57
- * @param {AuthInterface} auth
58
- * @param {AuthHandlerInterface~authPreHookCallback} done
58
+ * @param {AuthInterface} auth -
59
+ * @param {AuthHandlerInterface~authPreHookCallback} done -
59
60
  */
60
61
  pre: function (auth, done) {
61
62
  return done(null, Boolean(auth.get('key') || auth.get('value')));
@@ -64,9 +65,9 @@ module.exports = {
64
65
  /**
65
66
  * Verifies whether the auth succeeded
66
67
  *
67
- * @param {AuthInterface} auth
68
- * @param {Response} response
69
- * @param {AuthHandlerInterface~authPostHookCallback} done
68
+ * @param {AuthInterface} auth -
69
+ * @param {Response} response -
70
+ * @param {AuthHandlerInterface~authPostHookCallback} done -
70
71
  */
71
72
  post: function (auth, response, done) {
72
73
  done(null, true);
@@ -75,9 +76,9 @@ module.exports = {
75
76
  /**
76
77
  * Signs the request
77
78
  *
78
- * @param {AuthInterface} auth
79
- * @param {Request} request
80
- * @param {AuthHandlerInterface~authSignHookCallback} done
79
+ * @param {AuthInterface} auth -
80
+ * @param {Request} request -
81
+ * @param {AuthHandlerInterface~authSignHookCallback} done -
81
82
  */
82
83
  sign: function (auth, request, done) {
83
84
  var target = TARGETS[auth.get('in')] || TARGETS.header,
@@ -6,7 +6,7 @@ var _ = require('lodash'),
6
6
  * Creates a wrapper around RequestAuth and provides getters and setters helper functions
7
7
  *
8
8
  * @constructs AuthInterface
9
- * @param {RequestAuth} auth
9
+ * @param {RequestAuth} auth -
10
10
  * @param {Object} protocolProfileBehavior - Protocol profile behaviors
11
11
  * @return {AuthInterface}
12
12
  * @throws {Error}
@@ -24,7 +24,7 @@ createAuthInterface = function (auth, protocolProfileBehavior) {
24
24
  _protocolProfileBehavior: protocolProfileBehavior || {},
25
25
 
26
26
  /**
27
- * @param {String|Array<String>} keys
27
+ * @param {String|Array<String>} keys -
28
28
  * @return {*} Returns a value for a key or an object having all keys & values depending on the input
29
29
  * @example
30
30
  * get('foo') // bar
@@ -51,8 +51,8 @@ createAuthInterface = function (auth, protocolProfileBehavior) {
51
51
  },
52
52
 
53
53
  /**
54
- * @param {String|Object} key
55
- * @param {*} [value]
54
+ * @param {String|Object} key -
55
+ * @param {*} [value] -
56
56
  * @return {AuthInterface}
57
57
  * @example
58
58
  * set('foo', 'bar')
@@ -78,12 +78,12 @@ createAuthInterface = function (auth, protocolProfileBehavior) {
78
78
  var param = parameters.one(key);
79
79
 
80
80
  if (!param) {
81
- return parameters.add({key: key, value: value, system: true});
81
+ return parameters.add({ key: key, value: value, system: true });
82
82
  }
83
83
 
84
84
  // Update if the param is a system property or an empty user property (null, undefined or empty string)
85
85
  if (param.system || param.value === EMPTY || _.isNil(param.value) || _.isNaN(param.value)) {
86
- return param.update({key: key, value: value, system: true});
86
+ return param.update({ key: key, value: value, system: true });
87
87
  }
88
88
  });
89
89
 
@@ -15,10 +15,10 @@ var _ = require('lodash'),
15
15
  *
16
16
  * @todo This function can also be used in Digest auth so that it works correctly for urlencoded and file body types
17
17
  *
18
- * @param {RequestBody} body
19
- * @param {String} algorithm
20
- * @param {String} digestEncoding
21
- * @param {Function} callback
18
+ * @param {RequestBody} body -
19
+ * @param {String} algorithm -
20
+ * @param {String} digestEncoding -
21
+ * @param {Function} callback -
22
22
  */
23
23
  computeBodyHash = function (body, algorithm, digestEncoding, callback) {
24
24
  if (!(body && algorithm && digestEncoding) || body.isEmpty()) { return callback(); }
@@ -146,9 +146,9 @@ module.exports = {
146
146
  /**
147
147
  * Initializes a item (fetches all required parameters, etc) before the actual authorization step.
148
148
  *
149
- * @param {AuthInterface} auth
150
- * @param {Response} response
151
- * @param {AuthHandlerInterface~authInitHookCallback} done
149
+ * @param {AuthInterface} auth -
150
+ * @param {Response} response -
151
+ * @param {AuthHandlerInterface~authInitHookCallback} done -
152
152
  */
153
153
  init: function (auth, response, done) {
154
154
  done(null);
@@ -157,8 +157,8 @@ module.exports = {
157
157
  /**
158
158
  * Checks the item, and fetches any parameters that are not already provided.
159
159
  *
160
- * @param {AuthInterface} auth
161
- * @param {AuthHandlerInterface~authPreHookCallback} done
160
+ * @param {AuthInterface} auth -
161
+ * @param {AuthHandlerInterface~authPreHookCallback} done -
162
162
  */
163
163
  pre: function (auth, done) {
164
164
  done(null, true);
@@ -167,9 +167,9 @@ module.exports = {
167
167
  /**
168
168
  * Verifies whether the request was successful after being sent.
169
169
  *
170
- * @param {AuthInterface} auth
171
- * @param {Requester} response
172
- * @param {AuthHandlerInterface~authPostHookCallback} done
170
+ * @param {AuthInterface} auth -
171
+ * @param {Requester} response -
172
+ * @param {AuthHandlerInterface~authPostHookCallback} done -
173
173
  */
174
174
  post: function (auth, response, done) {
175
175
  done(null, true);
@@ -216,9 +216,9 @@ module.exports = {
216
216
  /**
217
217
  * Signs a request.
218
218
  *
219
- * @param {AuthInterface} auth
220
- * @param {Request} request
221
- * @param {AuthHandlerInterface~authSignHookCallback} done
219
+ * @param {AuthInterface} auth -
220
+ * @param {Request} request -
221
+ * @param {AuthHandlerInterface~authSignHookCallback} done -
222
222
  */
223
223
  sign: function (auth, request, done) {
224
224
  var self = this,
@@ -234,10 +234,10 @@ module.exports = {
234
234
  dataToSign;
235
235
 
236
236
  // Clean up the request (if needed)
237
- request.removeHeader('Authorization', {ignoreCase: true});
238
- request.removeHeader('X-Amz-Date', {ignoreCase: true});
239
- request.removeHeader('X-Amz-Security-Token', {ignoreCase: true});
240
- request.removeHeader('X-Amz-Content-Sha256', {ignoreCase: true});
237
+ request.removeHeader('Authorization', { ignoreCase: true });
238
+ request.removeHeader('X-Amz-Date', { ignoreCase: true });
239
+ request.removeHeader('X-Amz-Security-Token', { ignoreCase: true });
240
+ request.removeHeader('X-Amz-Content-Sha256', { ignoreCase: true });
241
241
 
242
242
  // Not removing `X-Amz-Expires` from params here allowing user to override
243
243
  // default value
@@ -262,7 +262,7 @@ module.exports = {
262
262
  region: params.region || 'us-east-1',
263
263
  method: request.method,
264
264
  body: undefined, // no need to give body since we are setting 'X-Amz-Content-Sha256' header
265
- headers: _.transform(request.getHeaders({enabled: true}), function (accumulator, value, key) {
265
+ headers: _.transform(request.getHeaders({ enabled: true }), function (accumulator, value, key) {
266
266
  accumulator[key] = value;
267
267
  }, {}),
268
268
  signQuery: params.addAuthDataToQuery
@@ -22,9 +22,9 @@ module.exports = {
22
22
  * Initializes an item (extracts parameters from intermediate requests if any, etc)
23
23
  * before the actual authorization step.
24
24
  *
25
- * @param {AuthInterface} auth
26
- * @param {Response} response
27
- * @param {AuthHandlerInterface~authInitHookCallback} done
25
+ * @param {AuthInterface} auth -
26
+ * @param {Response} response -
27
+ * @param {AuthHandlerInterface~authInitHookCallback} done -
28
28
  */
29
29
  init: function (auth, response, done) {
30
30
  done(null);
@@ -36,8 +36,8 @@ module.exports = {
36
36
  *
37
37
  * @todo - add support for prompting a user for basic auth credentials if not already provided
38
38
  *
39
- * @param {AuthInterface} auth
40
- * @param {AuthHandlerInterface~authPreHookCallback} done
39
+ * @param {AuthInterface} auth -
40
+ * @param {AuthHandlerInterface~authPreHookCallback} done -
41
41
  */
42
42
  pre: function (auth, done) {
43
43
  done(null, true);
@@ -46,9 +46,9 @@ module.exports = {
46
46
  /**
47
47
  * Verifies whether the basic auth succeeded.
48
48
  *
49
- * @param {AuthInterface} auth
50
- * @param {Response} response
51
- * @param {AuthHandlerInterface~authPostHookCallback} done
49
+ * @param {AuthInterface} auth -
50
+ * @param {Response} response -
51
+ * @param {AuthHandlerInterface~authPostHookCallback} done -
52
52
  */
53
53
  post: function (auth, response, done) {
54
54
  done(null, true);
@@ -57,15 +57,15 @@ module.exports = {
57
57
  /**
58
58
  * Signs a request.
59
59
  *
60
- * @param {AuthInterface} auth
61
- * @param {Request} request
62
- * @param {AuthHandlerInterface~authSignHookCallback} done
60
+ * @param {AuthInterface} auth -
61
+ * @param {Request} request -
62
+ * @param {AuthHandlerInterface~authSignHookCallback} done -
63
63
  */
64
64
  sign: function (auth, request, done) {
65
65
  var username = auth.get('username') || '',
66
66
  password = auth.get('password') || '';
67
67
 
68
- request.removeHeader('Authorization', {ignoreCase: true});
68
+ request.removeHeader('Authorization', { ignoreCase: true });
69
69
  request.addHeader({
70
70
  key: 'Authorization',
71
71
  value: 'Basic ' + Buffer.from(`${username}:${password}`, 'utf8').toString('base64'),
@@ -25,9 +25,9 @@ module.exports = {
25
25
  * Initializes an item (extracts parameters from intermediate requests if any, etc)
26
26
  * before the actual authorization step
27
27
  *
28
- * @param {AuthInterface} auth
29
- * @param {Response} response
30
- * @param {AuthHandlerInterface~authInitHookCallback} done
28
+ * @param {AuthInterface} auth -
29
+ * @param {Response} response -
30
+ * @param {AuthHandlerInterface~authInitHookCallback} done -
31
31
  */
32
32
  init: function (auth, response, done) {
33
33
  done();
@@ -36,8 +36,8 @@ module.exports = {
36
36
  /**
37
37
  * Verifies whether the request has required parameters
38
38
  *
39
- * @param {AuthInterface} auth
40
- * @param {AuthHandlerInterface~authPreHookCallback} done
39
+ * @param {AuthInterface} auth -
40
+ * @param {AuthHandlerInterface~authPreHookCallback} done -
41
41
  */
42
42
  pre: function (auth, done) {
43
43
  return done(null, Boolean(auth.get('token')));
@@ -46,9 +46,9 @@ module.exports = {
46
46
  /**
47
47
  * Verifies whether the auth succeeded
48
48
  *
49
- * @param {AuthInterface} auth
50
- * @param {Response} response
51
- * @param {AuthHandlerInterface~authPostHookCallback} done
49
+ * @param {AuthInterface} auth -
50
+ * @param {Response} response -
51
+ * @param {AuthHandlerInterface~authPostHookCallback} done -
52
52
  */
53
53
  post: function (auth, response, done) {
54
54
  done(null, true);
@@ -57,9 +57,9 @@ module.exports = {
57
57
  /**
58
58
  * Signs the request
59
59
  *
60
- * @param {AuthInterface} auth
61
- * @param {Request} request
62
- * @param {AuthHandlerInterface~authSignHookCallback} done
60
+ * @param {AuthInterface} auth -
61
+ * @param {Request} request -
62
+ * @param {AuthHandlerInterface~authSignHookCallback} done -
63
63
  */
64
64
  sign: function (auth, request, done) {
65
65
  var token = auth.get('token');
@@ -71,7 +71,7 @@ module.exports = {
71
71
  // @TODO Should we support adding to query params and/or body also?
72
72
  // According to the RFC#6750 they are supported but not recommended!
73
73
 
74
- request.removeHeader('Authorization', {ignoreCase: true});
74
+ request.removeHeader('Authorization', { ignoreCase: true });
75
75
  request.addHeader({
76
76
  key: 'Authorization',
77
77
  value: BEARER_AUTH_PREFIX + token,
@@ -73,20 +73,20 @@ if (!_.includes(crypto.getHashes(), 'sha512-256')) {
73
73
  };
74
74
 
75
75
  _.assign(crypto.prototype, {
76
- update: function (data) {
76
+ update (data) {
77
77
  this._hash.update(data);
78
78
 
79
79
  return this;
80
80
  },
81
81
 
82
- digest: function () {
82
+ digest () {
83
83
  // we only need 'hex' digest for this auth
84
84
  return this._hash.hex();
85
85
  }
86
86
  });
87
87
 
88
88
  _.assign(crypto, {
89
- createHash: function (hashAlgo) {
89
+ createHash (hashAlgo) {
90
90
  // return hash from js-sha for SHA512-256
91
91
  if (hashAlgo === 'sha512-256') {
92
92
  return new crypto();
@@ -102,7 +102,7 @@ if (!_.includes(crypto.getHashes(), 'sha512-256')) {
102
102
  * Generates a random string of given length
103
103
  *
104
104
  * @todo Move this to util.js. After moving use that for hawk auth too
105
- * @param {Number} length
105
+ * @param {Number} length -
106
106
  */
107
107
  function randomString (length) {
108
108
  length = length || 6;
@@ -121,8 +121,8 @@ function randomString (length) {
121
121
  /**
122
122
  * Extracts a Digest Auth field from a WWW-Authenticate header value using a given regexp.
123
123
  *
124
- * @param {String} string
125
- * @param {RegExp} regexp
124
+ * @param {String} string -
125
+ * @param {RegExp} regexp -
126
126
  * @private
127
127
  */
128
128
  _extractField = function (string, regexp) {
@@ -135,7 +135,7 @@ _extractField = function (string, regexp) {
135
135
  * Returns the 'www-authenticate' header for Digest auth. Since a server can suport more than more auth-scheme,
136
136
  * there can be more than one header with the same key. So need to loop over and check each one.
137
137
  *
138
- * @param {VariableList} headers
138
+ * @param {VariableList} headers -
139
139
  * @private
140
140
  */
141
141
  function _getDigestAuthHeader (headers) {
@@ -227,6 +227,7 @@ function computeBodyHash (body, algorithm, digestEncoding, callback) {
227
227
 
228
228
  /**
229
229
  * All the auth definition parameters excluding username and password should be stored and resued.
230
+ *
230
231
  * @todo The current implementation would fail for the case when two requests to two different hosts inherits the same
231
232
  * auth. In that case a retry would not be attempted for the second request (since all the parameters would be present
232
233
  * in the auth definition though invalid).
@@ -262,9 +263,9 @@ module.exports = {
262
263
  * Initializes an item (extracts parameters from intermediate requests if any, etc)
263
264
  * before the actual authorization step.
264
265
  *
265
- * @param {AuthInterface} auth
266
- * @param {Response} response
267
- * @param {AuthHandlerInterface~authInitHookCallback} done
266
+ * @param {AuthInterface} auth -
267
+ * @param {Response} response -
268
+ * @param {AuthHandlerInterface~authInitHookCallback} done -
268
269
  */
269
270
  init: function (auth, response, done) {
270
271
  done(null);
@@ -274,8 +275,8 @@ module.exports = {
274
275
  * Checks whether the given item has all the required parameters in its request.
275
276
  * Sanitizes the auth parameters if needed.
276
277
  *
277
- * @param {AuthInterface} auth
278
- * @param {AuthHandlerInterface~authPreHookCallback} done
278
+ * @param {AuthInterface} auth -
279
+ * @param {AuthHandlerInterface~authPreHookCallback} done -
279
280
  */
280
281
  pre: function (auth, done) {
281
282
  // ensure that all dynamic parameter values are present in the parameters
@@ -286,9 +287,9 @@ module.exports = {
286
287
  /**
287
288
  * Verifies whether the request was successfully authorized after being sent.
288
289
  *
289
- * @param {AuthInterface} auth
290
- * @param {Response} response
291
- * @param {AuthHandlerInterface~authPostHookCallback} done
290
+ * @param {AuthInterface} auth -
291
+ * @param {Response} response -
292
+ * @param {AuthHandlerInterface~authPostHookCallback} done -
292
293
  */
293
294
  post: function (auth, response, done) {
294
295
  if (auth.get(DISABLE_RETRY_REQUEST) || !response) {
@@ -341,18 +342,18 @@ module.exports = {
341
342
  /**
342
343
  * Computes the Digest Authentication header from the given parameters.
343
344
  *
344
- * @param {Object} params
345
- * @param {String} params.algorithm
346
- * @param {String} params.username
347
- * @param {String} params.realm
348
- * @param {String} params.password
349
- * @param {String} params.method
350
- * @param {String} params.nonce
351
- * @param {String} params.nonceCount
352
- * @param {String} params.clientNonce
353
- * @param {String} params.opaque
354
- * @param {String} params.qop
355
- * @param {String} params.uri
345
+ * @param {Object} params -
346
+ * @param {String} params.algorithm -
347
+ * @param {String} params.username -
348
+ * @param {String} params.realm -
349
+ * @param {String} params.password -
350
+ * @param {String} params.method -
351
+ * @param {String} params.nonce -
352
+ * @param {String} params.nonceCount -
353
+ * @param {String} params.clientNonce -
354
+ * @param {String} params.opaque -
355
+ * @param {String} params.qop -
356
+ * @param {String} params.uri -
356
357
  * @returns {String}
357
358
  */
358
359
  computeHeader: function (params) {
@@ -429,9 +430,9 @@ module.exports = {
429
430
  /**
430
431
  * Signs a request.
431
432
  *
432
- * @param {AuthInterface} auth
433
- * @param {Request} request
434
- * @param {AuthHandlerInterface~authSignHookCallback} done
433
+ * @param {AuthInterface} auth -
434
+ * @param {Request} request -
435
+ * @param {AuthHandlerInterface~authSignHookCallback} done -
435
436
  */
436
437
  sign: function (auth, request, done) {
437
438
  var self = this,
@@ -443,7 +444,7 @@ module.exports = {
443
444
  return done(); // Nothing to do if required parameters are not present.
444
445
  }
445
446
 
446
- request.removeHeader(AUTHORIZATION, {ignoreCase: true});
447
+ request.removeHeader(AUTHORIZATION, { ignoreCase: true });
447
448
 
448
449
  params.method = request.method;
449
450
  params.uri = url.path;
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  var _ = require('lodash'),
10
- uuid = require('uuid/v4'),
10
+ uuid = require('uuid'),
11
11
  crypto = require('crypto'),
12
12
  sdk = require('postman-collection'),
13
13
  RequestBody = sdk.RequestBody,
@@ -74,7 +74,7 @@ var _ = require('lodash'),
74
74
  },
75
75
 
76
76
  /**
77
- * Returns base64 encoding of the SHA256 HMAC of given data signed with given key
77
+ * Returns base64 encoding of the SHA-256 HMAC of given data signed with given key
78
78
  *
79
79
  * @param {String} data Data to sign
80
80
  * @param {String} key Key to use while signing the data
@@ -147,7 +147,7 @@ var _ = require('lodash'),
147
147
  return callback(hash.digest(digestEncoding));
148
148
  }
149
149
 
150
- // @todo: Figure out a way to calculate hash for formdata body type.
150
+ // @todo: Figure out a way to calculate hash for form-data body type.
151
151
 
152
152
  // ensure that callback is called if body.mode doesn't match with any of the above modes
153
153
  return callback();
@@ -215,7 +215,7 @@ module.exports = {
215
215
  * @param {String} params.clientSecret Client secret provided by service provider
216
216
  * @param {String} params.nonce Nonce to include in authorization header
217
217
  * @param {String} params.timestamp Timestamp as defined in protocol specification
218
- * @param {String} [params.bodyHash] Base64-encoded SHA256 hash of request body for POST request
218
+ * @param {String} [params.bodyHash] Base64-encoded SHA-256 hash of request body for POST request
219
219
  * @param {Object[]} params.headers Request headers
220
220
  * @param {String[]} params.headersToSign Ordered list of headers to include in signature
221
221
  * @param {String} params.method Request method
@@ -271,17 +271,17 @@ module.exports = {
271
271
  return done(); // Nothing to do if required parameters are not present.
272
272
  }
273
273
 
274
- request.removeHeader(AUTHORIZATION, {ignoreCase: true});
274
+ request.removeHeader(AUTHORIZATION, { ignoreCase: true });
275
275
 
276
276
  // Extract host from provided baseURL.
277
277
  params.baseURL = params.baseURL && urlEncoder.toNodeUrl(params.baseURL).host;
278
- params.nonce = params.nonce || uuid();
278
+ params.nonce = params.nonce || uuid.v4();
279
279
  params.timestamp = params.timestamp || getTimestamp();
280
280
  params.url = url;
281
281
  params.method = request.method;
282
282
 
283
283
  // ensure that headers are case-insensitive as specified in the documentation
284
- params.headers = request.getHeaders({enabled: true, ignoreCase: true});
284
+ params.headers = request.getHeaders({ enabled: true, ignoreCase: true });
285
285
 
286
286
  if (typeof params.headersToSign === STRING) {
287
287
  params.headersToSign = params.headersToSign.split(',');
@@ -14,7 +14,7 @@ var url = require('url'),
14
14
  /**
15
15
  * Generates a random string of given length (useful for nonce generation, etc).
16
16
  *
17
- * @param {Number} length
17
+ * @param {Number} length -
18
18
  */
19
19
  function randomString (length) {
20
20
  length = length || 6;
@@ -33,11 +33,11 @@ function randomString (length) {
33
33
  * Calculates body hash with given algorithm and digestEncoding.
34
34
  * REFER: https://github.com/postmanlabs/postman-request/blob/master/lib/hawk.js#L12
35
35
  *
36
- * @param {RequestBody} body
37
- * @param {String} algorithm
38
- * @param {String} digestEncoding
39
- * @param {String} contentType
40
- * @param {Function} callback
36
+ * @param {RequestBody} body -
37
+ * @param {String} algorithm -
38
+ * @param {String} digestEncoding -
39
+ * @param {String} contentType -
40
+ * @param {Function} callback -
41
41
  */
42
42
  function computeBodyHash (body, algorithm, digestEncoding, contentType, callback) {
43
43
  if (!(body && algorithm && digestEncoding) || body.isEmpty()) { return callback(); }
@@ -135,9 +135,9 @@ module.exports = {
135
135
  * Initializes an item (extracts parameters from intermediate requests if any, etc)
136
136
  * before the actual authorization step.
137
137
  *
138
- * @param {AuthInterface} auth
139
- * @param {Response} response
140
- * @param {AuthHandlerInterface~authInitHookCallback} done
138
+ * @param {AuthInterface} auth -
139
+ * @param {Response} response -
140
+ * @param {AuthHandlerInterface~authInitHookCallback} done -
141
141
  */
142
142
  init: function (auth, response, done) {
143
143
  done(null);
@@ -147,8 +147,8 @@ module.exports = {
147
147
  * Checks the item, and fetches any parameters that are not already provided.
148
148
  * Sanitizes the auth parameters if needed.
149
149
  *
150
- * @param {AuthInterface} auth
151
- * @param {AuthHandlerInterface~authPreHookCallback} done
150
+ * @param {AuthInterface} auth -
151
+ * @param {AuthHandlerInterface~authPreHookCallback} done -
152
152
  */
153
153
  pre: function (auth, done) {
154
154
  !auth.get('nonce') && auth.set('nonce', randomString(6));
@@ -159,9 +159,9 @@ module.exports = {
159
159
  /**
160
160
  * Verifies whether the request was successfully authorized after being sent.
161
161
  *
162
- * @param {AuthInterface} auth
163
- * @param {Response} response
164
- * @param {AuthHandlerInterface~authPostHookCallback} done
162
+ * @param {AuthInterface} auth -
163
+ * @param {Response} response -
164
+ * @param {AuthHandlerInterface~authPostHookCallback} done -
165
165
  */
166
166
  post: function (auth, response, done) {
167
167
  done(null, true);
@@ -170,9 +170,9 @@ module.exports = {
170
170
  /**
171
171
  * Computes signature and Auth header for a request.
172
172
  *
173
- * @param {Object} params
173
+ * @param {Object} params -
174
174
  * @param {Object} params.credentials Contains hawk auth credentials, "id", "key" and "algorithm"
175
- * @param {String} params.nonce
175
+ * @param {String} params.nonce -
176
176
  * @param {String} params.ext Extra data that may be associated with the request.
177
177
  * @param {String} params.app Application ID used in Oz authorization protocol
178
178
  * @param {String} params.dlg Delegation information (used in the Oz protocol)
@@ -189,9 +189,9 @@ module.exports = {
189
189
  /**
190
190
  * Signs a request.
191
191
  *
192
- * @param {AuthInterface} auth
193
- * @param {Request} request
194
- * @param {AuthHandlerInterface~authSignHookCallback} done
192
+ * @param {AuthInterface} auth -
193
+ * @param {Request} request -
194
+ * @param {AuthHandlerInterface~authSignHookCallback} done -
195
195
  */
196
196
  sign: function (auth, request, done) {
197
197
  var params = auth.get([
@@ -245,7 +245,7 @@ module.exports = {
245
245
  return done(); // Nothing to do if required parameters are not present.
246
246
  }
247
247
 
248
- request.removeHeader(AUTHORIZATION, {ignoreCase: true});
248
+ request.removeHeader(AUTHORIZATION, { ignoreCase: true });
249
249
 
250
250
  // @note: Payload verification is optional in hawk auth according to specifications (see below link). If user
251
251
  // opt-in for payload verification, `Content-Type` header must be specified explicitely otherwise