From 2f805fedef233e5330c381965651f2cb12ff1847 Mon Sep 17 00:00:00 2001 From: Sebastian Pape Date: Wed, 10 May 2023 10:19:30 +0200 Subject: [PATCH] v1.21.4: fix crypto.randomBytes polyfil --- dist/esm/index.js | 2 +- dist/umd/index.js | 2 +- package.json | 2 +- rollup.config.js | 5 ++--- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/dist/esm/index.js b/dist/esm/index.js index b58b5b3..8290885 100644 --- a/dist/esm/index.js +++ b/dist/esm/index.js @@ -6,7 +6,7 @@ if(_global$1.XMLHttpRequest == undefined) { _global$1.XMLHttpRequest = class XML if(_global$1.location == undefined) { _global$1.location = {} } if(_global$1.crypto == undefined) { _global$1.crypto = {} } if(_global$1.crypto.getRandomValues == undefined) { _global$1.crypto.getRandomValues = function(abv) { var l = abv.length; while (l--) { abv[l] = parseInt(Math.random().toString().replace('0.', ''), 10) }; return abv } } -if(_global$1.crypto.randomBytes == undefined) { let array = new Uint8Array(size); _global$1.crypto.getRandomValues(array); return array } +if(_global$1.crypto.randomBytes == undefined) { _global$1.crypto.randomBytes = function(size) { let array = new Uint8Array(size); _global$1.crypto.getRandomValues(array); return array } } if(_global$1.fetch == undefined) { throw('Please polyfill .fetch | See: https://github.com/DePayFi/solana-web3.js#polyfill-fetch') } var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; diff --git a/dist/umd/index.js b/dist/umd/index.js index 509bdce..ba3c71a 100644 --- a/dist/umd/index.js +++ b/dist/umd/index.js @@ -6,7 +6,7 @@ if(_global$1.XMLHttpRequest == undefined) { _global$1.XMLHttpRequest = class XML if(_global$1.location == undefined) { _global$1.location = {} } if(_global$1.crypto == undefined) { _global$1.crypto = {} } if(_global$1.crypto.getRandomValues == undefined) { _global$1.crypto.getRandomValues = function(abv) { var l = abv.length; while (l--) { abv[l] = parseInt(Math.random().toString().replace('0.', ''), 10) }; return abv } } -if(_global$1.crypto.randomBytes == undefined) { let array = new Uint8Array(size); _global$1.crypto.getRandomValues(array); return array } +if(_global$1.crypto.randomBytes == undefined) { _global$1.crypto.randomBytes = function(size) { let array = new Uint8Array(size); _global$1.crypto.getRandomValues(array); return array } } if(_global$1.fetch == undefined) { throw('Please polyfill .fetch | See: https://github.com/DePayFi/solana-web3.js#polyfill-fetch') } (function (global, factory) { diff --git a/package.json b/package.json index 13e80cd..63faae9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@depay/solana-web3.js", "moduleName": "SolanaWeb3js", - "version": "1.21.3", + "version": "1.21.4", "description": "Solana Web3.js browser pre-built usable in rollup bundles.", "main": "dist/umd/index.js", "module": "dist/esm/index.js", diff --git a/rollup.config.js b/rollup.config.js index d73e27a..e9a7e88 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -23,7 +23,7 @@ if(_global$1.XMLHttpRequest == undefined) { _global$1.XMLHttpRequest = class XML if(_global$1.location == undefined) { _global$1.location = {} } if(_global$1.crypto == undefined) { _global$1.crypto = {} } if(_global$1.crypto.getRandomValues == undefined) { _global$1.crypto.getRandomValues = function(abv) { var l = abv.length; while (l--) { abv[l] = parseInt(Math.random().toString().replace('0.', ''), 10) }; return abv } } -if(_global$1.crypto.randomBytes == undefined) { let array = new Uint8Array(size); _global$1.crypto.getRandomValues(array); return array } +if(_global$1.crypto.randomBytes == undefined) { _global$1.crypto.randomBytes = function(size) { let array = new Uint8Array(size); _global$1.crypto.getRandomValues(array); return array } } if(_global$1.fetch == undefined) { throw('Please polyfill .fetch | See: https://github.com/DePayFi/solana-web3.js#polyfill-fetch') } ` }, @@ -40,7 +40,7 @@ if(_global$1.XMLHttpRequest == undefined) { _global$1.XMLHttpRequest = class XML if(_global$1.location == undefined) { _global$1.location = {} } if(_global$1.crypto == undefined) { _global$1.crypto = {} } if(_global$1.crypto.getRandomValues == undefined) { _global$1.crypto.getRandomValues = function(abv) { var l = abv.length; while (l--) { abv[l] = parseInt(Math.random().toString().replace('0.', ''), 10) }; return abv } } -if(_global$1.crypto.randomBytes == undefined) { let array = new Uint8Array(size); _global$1.crypto.getRandomValues(array); return array } +if(_global$1.crypto.randomBytes == undefined) { _global$1.crypto.randomBytes = function(size) { let array = new Uint8Array(size); _global$1.crypto.getRandomValues(array); return array } } if(_global$1.fetch == undefined) { throw('Please polyfill .fetch | See: https://github.com/DePayFi/solana-web3.js#polyfill-fetch') } ` }, @@ -81,7 +81,6 @@ if(_global$1.fetch == undefined) { throw('Please polyfill .fetch | See: https:// for (const fileName in bundle) { let file = bundle[fileName]; if(file.code){ - console.log(file.code) file.code = file.code.replace( /var nodeCrypto[\s\S]*?;/m, "var nodeCrypto = _global$1.crypto;"