Compare commits

...
2 Commits
Author SHA1 Message Date
Emil Bay b883b2a8df 0.5.2 2017-11-03 08:19:11 +01:00
Emil Bay f336097b6a Fix bug with undefined window in web workers
Fixes #8
2017-11-03 08:19:06 +01:00
2 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "sodium-javascript",
"version": "0.5.1",
"version": "0.5.2",
"description": "WIP - a pure javascript version of sodium-native",
"main": "index.js",
"dependencies": {
+3 -3
View File
@@ -1,9 +1,9 @@
var assert = require('nanoassert')
var randombytes = (function () {
var QUOTA = 65536 // limit for QuotaExceededException
var crypto = typeof window !== 'undefined' ? (window.crypto || window.msCrypto) : null
var crypto = typeof global !== 'undefined' ? crypto = (global.crypto || global.msCrypto) : null
function windowBytes (out, n) {
function browserBytes (out, n) {
for (var i = 0; i < n; i += QUOTA) {
crypto.getRandomValues(out.subarray(i, i + Math.min(n - i, QUOTA)))
}
@@ -18,7 +18,7 @@ var randombytes = (function () {
}
if (crypto && crypto.getRandomValues) {
return windowBytes
return browserBytes
} else if (typeof require !== 'undefined') {
// Node.js.
crypto = require('cry' + 'pto');