We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f850ddc commit aaad106Copy full SHA for aaad106
lib/manager.js
@@ -709,7 +709,14 @@ Manager.prototype.generateId = function () {
709
var rand = new Buffer(15); // multiple of 3 for base64
710
this.sequenceNumber = (this.sequenceNumber + 1) | 0;
711
rand.writeInt32BE(this.sequenceNumber, 11);
712
- crypto.randomBytes(12).copy(rand);
+ if (crypto.randomBytes) {
713
+ crypto.randomBytes(12).copy(rand);
714
+ } else {
715
+ // not secure for node 0.4
716
+ [0, 4, 8].forEach(function(i) {
717
+ rand.writeInt32BE(Math.random() * Math.pow(2, 32) | 0, i);
718
+ });
719
+ }
720
return rand.toString('base64').replace(/\//g, '_').replace(/\+/g, '-');
721
};
722
0 commit comments