File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -100,16 +100,14 @@ function detectPrng() {
100100 }
101101 var browserCrypto = root && ( root . crypto || root . msCrypto ) ;
102102 if ( browserCrypto ) {
103- try {
104- return function ( ) {
105- var buffer = new Uint8Array ( 1 ) ;
106- browserCrypto . getRandomValues ( buffer ) ;
107- return buffer [ 0 ] / 0xff ;
108- } ;
109- } catch ( e ) { }
103+ return function ( ) {
104+ var buffer = new Uint8Array ( 1 ) ;
105+ browserCrypto . getRandomValues ( buffer ) ;
106+ return buffer [ 0 ] / 0xff ;
107+ } ;
110108 } else {
111109 try {
112- var nodeCrypto = require ( "crypto" ) ;
110+ var nodeCrypto = global [ " require" ] ( "crypto" ) ;
113111 return function ( ) {
114112 return nodeCrypto . randomBytes ( 1 ) . readUInt8 ( ) / 0xff ;
115113 } ;
Original file line number Diff line number Diff line change @@ -101,18 +101,15 @@ export function detectPrng(allowInsecure = false, root) {
101101 }
102102 const browserCrypto = root && ( root . crypto || root . msCrypto ) ;
103103 if ( browserCrypto ) {
104- try {
105- return ( ) => {
106- const buffer = new Uint8Array ( 1 ) ;
107- browserCrypto . getRandomValues ( buffer ) ;
108- return buffer [ 0 ] / 0xff ;
109- } ;
110- }
111- catch ( e ) { }
104+ return ( ) => {
105+ const buffer = new Uint8Array ( 1 ) ;
106+ browserCrypto . getRandomValues ( buffer ) ;
107+ return buffer [ 0 ] / 0xff ;
108+ } ;
112109 }
113110 else {
114111 try {
115- const nodeCrypto = require ( "crypto" ) ;
112+ const nodeCrypto = global [ " require" ] ( "crypto" ) ;
116113 return ( ) => nodeCrypto . randomBytes ( 1 ) . readUInt8 ( ) / 0xff ;
117114 }
118115 catch ( e ) { }
Original file line number Diff line number Diff line change @@ -106,16 +106,14 @@ function detectPrng() {
106106 }
107107 var browserCrypto = root && ( root . crypto || root . msCrypto ) ;
108108 if ( browserCrypto ) {
109- try {
110- return function ( ) {
111- var buffer = new Uint8Array ( 1 ) ;
112- browserCrypto . getRandomValues ( buffer ) ;
113- return buffer [ 0 ] / 0xff ;
114- } ;
115- } catch ( e ) { }
109+ return function ( ) {
110+ var buffer = new Uint8Array ( 1 ) ;
111+ browserCrypto . getRandomValues ( buffer ) ;
112+ return buffer [ 0 ] / 0xff ;
113+ } ;
116114 } else {
117115 try {
118- var nodeCrypto = require ( "crypto" ) ;
116+ var nodeCrypto = global [ " require" ] ( "crypto" ) ;
119117 return function ( ) {
120118 return nodeCrypto . randomBytes ( 1 ) . readUInt8 ( ) / 0xff ;
121119 } ;
You can’t perform that action at this time.
0 commit comments