Skip to content

Commit 064fbee

Browse files
committed
Move to Node's own UUID generation
1 parent 3c78a97 commit 064fbee

File tree

10 files changed

+49
-35
lines changed

10 files changed

+49
-35
lines changed

lib/authorizer/asap.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
var jose = require('jose'),
2-
uuid = require('uuid'),
2+
crypto = require('crypto'),
33
nodeForge = require('node-forge'),
44
AUTHORIZATION = 'Authorization',
55
AUTHORIZATION_PREFIX = 'Bearer ',
@@ -181,7 +181,7 @@ module.exports = {
181181
audience = claims.aud || params.aud;
182182

183183
// Default to a uuid, this is mandatory in ASAP
184-
jwtTokenId = claims.jti || uuid.v4();
184+
jwtTokenId = claims.jti || crypto.randomUUID();
185185
currentTimeStamp = Math.floor(Date.now() / 1000);
186186
issuedAt = claims.iat || currentTimeStamp;
187187

lib/authorizer/edgegrid.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88

99
var _ = require('lodash'),
10-
uuid = require('uuid'),
1110
crypto = require('crypto'),
1211
sdk = require('postman-collection'),
1312
RequestBody = sdk.RequestBody,
@@ -302,7 +301,7 @@ module.exports = {
302301

303302
// Extract host from provided baseURL.
304303
params.baseURL = params.baseURL && urlEncoder.toNodeUrl(params.baseURL).host;
305-
params.nonce = params.nonce || uuid.v4();
304+
params.nonce = params.nonce || crypto.randomUUID();
306305
params.timestamp = params.timestamp || getTimestamp();
307306
params.url = url;
308307
params.method = request.method;

lib/requester/core.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var dns = require('dns'),
33
constants = require('constants'),
44

55
_ = require('lodash'),
6-
uuid = require('uuid'),
6+
crypto = require('crypto'),
77
sdk = require('postman-collection'),
88
urlEncoder = require('postman-url-encoder'),
99

@@ -160,7 +160,7 @@ var dns = require('dns'),
160160
{ key: 'User-Agent', value: `PostmanRuntime/${version}` },
161161
{ key: 'Accept', value: '*/*' },
162162
{ key: 'Cache-Control', value: 'no-cache' },
163-
{ key: 'Postman-Token', value: uuid.v4() },
163+
{ key: 'Postman-Token', value: crypto.randomUUID() },
164164
{ key: 'Host', value: options.url && options.url.host },
165165
{ key: 'Accept-Encoding', value: 'gzip, deflate, br' },
166166
{ key: 'Connection', value: 'keep-alive' }

lib/runner/cursor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
var _ = require('lodash'),
2-
uuid = require('uuid'),
2+
crypto = require('crypto'),
33
Cursor;
44

55
/**
@@ -23,7 +23,7 @@ Cursor = function RunCursor (length, cycles, position, iteration, // eslint-disa
2323
this.partitionIndex = Cursor.validate(partitionIndex, 0, this.cycles);
2424
this.partitionCycles = Cursor.validate(partitionCycles, 0, this.cycles);
2525

26-
this.ref = ref || uuid.v4();
26+
this.ref = ref || crypto.randomUUID();
2727
};
2828

2929
_.assign(Cursor.prototype, {

lib/runner/extensions/event.command.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
var _ = require('lodash'),
2-
uuid = require('uuid'),
2+
crypto = require('crypto'),
33
async = require('async'),
44

55
util = require('../util'),
@@ -287,7 +287,7 @@ module.exports = {
287287

288288
// get access to the script from the event.
289289
var script = event.script,
290-
executionId = uuid.v4(),
290+
executionId = crypto.randomUUID(),
291291
assertionFailed = [],
292292
asyncScriptError,
293293

lib/runner/extensions/http-request.command.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var _ = require('lodash'),
22
async = require('async'),
3-
uuid = require('uuid'),
3+
crypto = require('crypto'),
44

55
// These are functions which a request passes through _before_ being sent. They take care of stuff such as
66
// variable resolution, loading of files, etc.
@@ -52,7 +52,7 @@ module.exports = {
5252

5353
// generates a unique id for each http request
5454
// a collection request can have multiple http requests
55-
_.set(context, 'coords.httpRequestId', payload.httpRequestId || uuid.v4());
55+
_.set(context, 'coords.httpRequestId', payload.httpRequestId || crypto.randomUUID());
5656

5757
// Run the helper functions
5858
async.applyEachSeries(prehelpers, context, self)(function (err) {
@@ -109,7 +109,7 @@ module.exports = {
109109
}, function (err, requester) {
110110
if (err) { return next(err); } // this should never happen
111111

112-
var requestId = uuid.v4(),
112+
var requestId = crypto.randomUUID(),
113113
replayOptions;
114114

115115
// eslint-disable-next-line @stylistic/js/max-len

lib/runner/extensions/item.command.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
var _ = require('lodash'),
2-
uuid = require('uuid'),
2+
crypto = require('crypto'),
33
Response = require('postman-collection').Response,
44
visualizer = require('../../visualizer'),
55

@@ -129,7 +129,7 @@ module.exports = {
129129
}
130130

131131
// store a common uuid in the coords
132-
coords.ref = uuid.v4();
132+
coords.ref = crypto.randomUUID();
133133

134134
// here we code to queue prerequest script, then make a request and then execute test script
135135
this.triggers.beforeItem(null, coords, item);

package-lock.json

Lines changed: 31 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@
5959
"postman-sandbox": "6.3.0",
6060
"postman-url-encoder": "3.0.8",
6161
"serialised-error": "1.1.3",
62-
"strip-json-comments": "3.1.1",
63-
"uuid": "8.3.2"
62+
"strip-json-comments": "3.1.1"
6463
},
6564
"devDependencies": {
6665
"@postman/shipit": "^0.4.0",

test/integration/auth-methods/ntlm.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
var expect = require('chai').expect,
2-
uuid = require('uuid'),
2+
crypto = require('crypto'),
33
_ = require('lodash');
44

55
(typeof window === 'undefined' ? describe : describe.skip)('NTLM', function () {
@@ -470,7 +470,7 @@ var expect = require('chai').expect,
470470

471471
describe('with NTLM auth set at collection level and 5 iterations', function () {
472472
before(function (done) {
473-
let executionId = uuid.v4();
473+
let executionId = crypto.randomUUID();
474474

475475
var localRunOptions = {
476476
collection: {
@@ -542,7 +542,7 @@ var expect = require('chai').expect,
542542

543543
describe('with NTLM auth set at collection level with 4 requests', function () {
544544
before(function (done) {
545-
let executionId = uuid.v4();
545+
let executionId = crypto.randomUUID();
546546

547547
var localRunOptions = {
548548
collection: {

0 commit comments

Comments
 (0)