Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rusha

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rusha - npm Package Compare versions

Comparing version 0.8.10 to 0.8.11

39

dist/rusha.js

@@ -358,16 +358,6 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Rusha = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){

var isRunningInWorker = 'WorkerGlobalScope' in self && self instanceof self.WorkerGlobalScope;
var isRunningInSharedWorker = 'SharedWorkerGlobalScope' in self && self instanceof self.SharedWorkerGlobalScope;
var isRunningInServiceWorker = 'ServiceWorkerGlobalScope' in self && self instanceof self.ServiceWorkerGlobalScope;
var _require = _dereq_('./utils'),
isDedicatedWorkerScope = _require.isDedicatedWorkerScope;
// Detects whether we run inside a dedicated worker or not.
//
// We can't just check for `DedicatedWorkerGlobalScope`, since IE11
// has a bug where it only supports `WorkerGlobalScope`.
//
// Therefore, we consider us as running inside a dedicated worker
// when we are running inside a worker, but not in a shared or service worker.
//
// When new types of workers are introduced, we will need to adjust this code.
var isRunningInDedicatedWorker = isRunningInWorker && !isRunningInSharedWorker && !isRunningInServiceWorker;
var isRunningInDedicatedWorker = typeof self !== 'undefined' && isDedicatedWorkerScope(self);

@@ -390,3 +380,3 @@ Rusha.disableWorkerBehaviour = isRunningInDedicatedWorker ? runWorker() : function () {};

},{"./hash":4,"./rusha":6,"./worker":8,"webworkify":1}],6:[function(_dereq_,module,exports){
},{"./hash":4,"./rusha":6,"./utils":7,"./worker":8,"webworkify":1}],6:[function(_dereq_,module,exports){
"use strict";

@@ -647,2 +637,23 @@ /* eslint-env commonjs, browser */

//
// isDedicatedWorkerScope
//
module.exports.isDedicatedWorkerScope = function (self) {
var isRunningInWorker = 'WorkerGlobalScope' in self && self instanceof self.WorkerGlobalScope;
var isRunningInSharedWorker = 'SharedWorkerGlobalScope' in self && self instanceof self.SharedWorkerGlobalScope;
var isRunningInServiceWorker = 'ServiceWorkerGlobalScope' in self && self instanceof self.ServiceWorkerGlobalScope;
// Detects whether we run inside a dedicated worker or not.
//
// We can't just check for `DedicatedWorkerGlobalScope`, since IE11
// has a bug where it only supports `WorkerGlobalScope`.
//
// Therefore, we consider us as running inside a dedicated worker
// when we are running inside a worker, but not in a shared or service worker.
//
// When new types of workers are introduced, we will need to adjust this code.
return isRunningInWorker && !isRunningInSharedWorker && !isRunningInServiceWorker;
};
},{}],8:[function(_dereq_,module,exports){

@@ -649,0 +660,0 @@ "use strict";

/*! rusha 2018-01-04 */
(function(e){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=e()}else if(typeof define==="function"&&define.amd){define([],e)}else{var r;if(typeof window!=="undefined"){r=window}else if(typeof global!=="undefined"){r=global}else if(typeof self!=="undefined"){r=self}else{r=this}r.Rusha=e()}})(function(){var e,r,t;return function e(r,t,n){function a(o,s){if(!t[o]){if(!r[o]){var f=typeof require=="function"&&require;if(!s&&f)return f(o,!0);if(i)return i(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var h=t[o]={exports:{}};r[o][0].call(h.exports,function(e){var t=r[o][1][e];return a(t?t:e)},h,h.exports,e,r,t,n)}return t[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<n.length;o++)a(n[o]);return a}({1:[function(e,r,t){var n=arguments[3];var a=arguments[4];var i=arguments[5];var o=JSON.stringify;r.exports=function(e,r){var t;var s=Object.keys(i);for(var f=0,u=s.length;f<u;f++){var h=s[f];var c=i[h].exports;if(c===e||c&&c.default===e){t=h;break}}if(!t){t=Math.floor(Math.pow(16,8)*Math.random()).toString(16);var p={};for(var f=0,u=s.length;f<u;f++){var h=s[f];p[h]=h}a[t]=["function(require,module,exports){"+e+"(self); }",p]}var l=Math.floor(Math.pow(16,8)*Math.random()).toString(16);var d={};d[t]=t;a[l]=["function(require,module,exports){"+"var f = require("+o(t)+");"+"(f.default ? f.default : f)(self);"+"}",d];var v={};w(l);function w(e){v[e]=true;for(var r in a[e][1]){var t=a[e][1][r];if(!v[t]){w(t)}}}var y="("+n+")({"+Object.keys(v).map(function(e){return o(e)+":["+a[e][0]+","+o(a[e][1])+"]"}).join(",")+"},{},["+o(l)+"])";var _=window.URL||window.webkitURL||window.mozURL||window.msURL;var b=new Blob([y],{type:"text/javascript"});if(r&&r.bare){return b}var k=_.createObjectURL(b);var x=new Worker(k);x.objectURL=k;return x}},{}],2:[function(e,r,t){(function(e){"use strict";var t=void 0;if(typeof self!=="undefined"&&typeof self.FileReaderSync!=="undefined"){t=new self.FileReaderSync}var n=function(e,r,t,n,a,i){var o=void 0,s=i%4,f=(a+s)%4,u=a-f;switch(s){case 0:r[i]=e.charCodeAt(n+3);case 1:r[i+1-(s<<1)|0]=e.charCodeAt(n+2);case 2:r[i+2-(s<<1)|0]=e.charCodeAt(n+1);case 3:r[i+3-(s<<1)|0]=e.charCodeAt(n)}if(a<f+(4-s)){return}for(o=4-s;o<u;o=o+4|0){t[i+o>>2]=e.charCodeAt(n+o)<<24|e.charCodeAt(n+o+1)<<16|e.charCodeAt(n+o+2)<<8|e.charCodeAt(n+o+3)}switch(f){case 3:r[i+u+1|0]=e.charCodeAt(n+u+2);case 2:r[i+u+2|0]=e.charCodeAt(n+u+1);case 1:r[i+u+3|0]=e.charCodeAt(n+u)}};var a=function(e,r,t,n,a,i){var o=void 0,s=i%4,f=(a+s)%4,u=a-f;switch(s){case 0:r[i]=e[n+3];case 1:r[i+1-(s<<1)|0]=e[n+2];case 2:r[i+2-(s<<1)|0]=e[n+1];case 3:r[i+3-(s<<1)|0]=e[n]}if(a<f+(4-s)){return}for(o=4-s;o<u;o=o+4|0){t[i+o>>2|0]=e[n+o]<<24|e[n+o+1]<<16|e[n+o+2]<<8|e[n+o+3]}switch(f){case 3:r[i+u+1|0]=e[n+u+2];case 2:r[i+u+2|0]=e[n+u+1];case 1:r[i+u+3|0]=e[n+u]}};var i=function(e,r,n,a,i,o){var s=void 0,f=o%4,u=(i+f)%4,h=i-u;var c=new Uint8Array(t.readAsArrayBuffer(e.slice(a,a+i)));switch(f){case 0:r[o]=c[3];case 1:r[o+1-(f<<1)|0]=c[2];case 2:r[o+2-(f<<1)|0]=c[1];case 3:r[o+3-(f<<1)|0]=c[0]}if(i<u+(4-f)){return}for(s=4-f;s<h;s=s+4|0){n[o+s>>2|0]=c[s]<<24|c[s+1]<<16|c[s+2]<<8|c[s+3]}switch(u){case 3:r[o+h+1|0]=c[h+2];case 2:r[o+h+2|0]=c[h+1];case 1:r[o+h+3|0]=c[h]}};r.exports=function(r,t,o,s,f,u){if(typeof r==="string"){return n(r,t,o,s,f,u)}if(r instanceof Array){return a(r,t,o,s,f,u)}if(e.Buffer&&e.Buffer.isBuffer(r)){return a(r,t,o,s,f,u)}if(r instanceof ArrayBuffer){return a(new Uint8Array(r),t,o,s,f,u)}if(r.buffer instanceof ArrayBuffer){return a(new Uint8Array(r.buffer,r.byteOffset,r.byteLength),t,o,s,f,u)}if(r instanceof Blob){return i(r,t,o,s,f,u)}throw new Error("Unsupported data type.")}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],3:[function(e,r,t){"use strict";r.exports=function e(r,t,n){"use asm";var a=new r.Int32Array(n);function i(e,r){e=e|0;r=r|0;var t=0,n=0,i=0,o=0,s=0,f=0,u=0,h=0,c=0,p=0,l=0,d=0,v=0,w=0;i=a[r+320>>2]|0;s=a[r+324>>2]|0;u=a[r+328>>2]|0;c=a[r+332>>2]|0;l=a[r+336>>2]|0;for(t=0;(t|0)<(e|0);t=t+64|0){o=i;f=s;h=u;p=c;d=l;for(n=0;(n|0)<64;n=n+4|0){w=a[t+n>>2]|0;v=((i<<5|i>>>27)+(s&u|~s&c)|0)+((w+l|0)+1518500249|0)|0;l=c;c=u;u=s<<30|s>>>2;s=i;i=v;a[e+n>>2]=w}for(n=e+64|0;(n|0)<(e+80|0);n=n+4|0){w=(a[n-12>>2]^a[n-32>>2]^a[n-56>>2]^a[n-64>>2])<<1|(a[n-12>>2]^a[n-32>>2]^a[n-56>>2]^a[n-64>>2])>>>31;v=((i<<5|i>>>27)+(s&u|~s&c)|0)+((w+l|0)+1518500249|0)|0;l=c;c=u;u=s<<30|s>>>2;s=i;i=v;a[n>>2]=w}for(n=e+80|0;(n|0)<(e+160|0);n=n+4|0){w=(a[n-12>>2]^a[n-32>>2]^a[n-56>>2]^a[n-64>>2])<<1|(a[n-12>>2]^a[n-32>>2]^a[n-56>>2]^a[n-64>>2])>>>31;v=((i<<5|i>>>27)+(s^u^c)|0)+((w+l|0)+1859775393|0)|0;l=c;c=u;u=s<<30|s>>>2;s=i;i=v;a[n>>2]=w}for(n=e+160|0;(n|0)<(e+240|0);n=n+4|0){w=(a[n-12>>2]^a[n-32>>2]^a[n-56>>2]^a[n-64>>2])<<1|(a[n-12>>2]^a[n-32>>2]^a[n-56>>2]^a[n-64>>2])>>>31;v=((i<<5|i>>>27)+(s&u|s&c|u&c)|0)+((w+l|0)-1894007588|0)|0;l=c;c=u;u=s<<30|s>>>2;s=i;i=v;a[n>>2]=w}for(n=e+240|0;(n|0)<(e+320|0);n=n+4|0){w=(a[n-12>>2]^a[n-32>>2]^a[n-56>>2]^a[n-64>>2])<<1|(a[n-12>>2]^a[n-32>>2]^a[n-56>>2]^a[n-64>>2])>>>31;v=((i<<5|i>>>27)+(s^u^c)|0)+((w+l|0)-899497514|0)|0;l=c;c=u;u=s<<30|s>>>2;s=i;i=v;a[n>>2]=w}i=i+o|0;s=s+f|0;u=u+h|0;c=c+p|0;l=l+d|0}a[r+320>>2]=i;a[r+324>>2]=s;a[r+328>>2]=u;a[r+332>>2]=c;a[r+336>>2]=l}return{hash:i}}},{}],4:[function(e,r,t){"use strict";function n(e,r){if(!(e instanceof r)){throw new TypeError("Cannot call a class as a function")}}var a=e("./rusha");var i=e("./utils"),o=i.toHex;var s=function(){function e(){n(this,e);this._rusha=new a;this._rusha.resetState()}e.prototype.update=function e(r){this._rusha.append(r);return this};e.prototype.digest=function e(r){var e=this._rusha.rawEnd().buffer;if(!r){return e}if(r==="hex"){return o(e)}throw new Error("unsupported digest encoding")};return e}();r.exports=function(){return new s}},{"./rusha":6,"./utils":7}],5:[function(e,r,t){"use strict";var n=e("webworkify");var a=e("./rusha");var i=e("./hash");var o=e("./worker");var s="WorkerGlobalScope"in self&&self instanceof self.WorkerGlobalScope;var f="SharedWorkerGlobalScope"in self&&self instanceof self.SharedWorkerGlobalScope;var u="ServiceWorkerGlobalScope"in self&&self instanceof self.ServiceWorkerGlobalScope;var h=s&&!f&&!u;a.disableWorkerBehaviour=h?o():function(){};a.createWorker=function(){var r=n(e("./worker"));var t=r.terminate;r.terminate=function(){URL.revokeObjectURL(r.objectURL);t.call(r)};return r};a.createHash=i;r.exports=a},{"./hash":4,"./rusha":6,"./worker":8,webworkify:1}],6:[function(e,r,t){"use strict";function n(e,r){if(!(e instanceof r)){throw new TypeError("Cannot call a class as a function")}}var a=e("./core.sjs");var i=e("./utils"),o=i.toHex,s=i.ceilHeapSize;var f=e("./conv");var u=function(e){for(e+=9;e%64>0;e+=1){}return e};var h=function(e,r){var t=new Uint8Array(e.buffer);var n=r%4,a=r-n;switch(n){case 0:t[a+3]=0;case 1:t[a+2]=0;case 2:t[a+1]=0;case 3:t[a+0]=0}for(var i=(r>>2)+1;i<e.length;i++){e[i]=0}};var c=function(e,r,t){e[r>>2]|=128<<24-(r%4<<3);e[((r>>2)+2&~15)+14]=t/(1<<29)|0;e[((r>>2)+2&~15)+15]=t<<3};var p=function(e,r){var t=new Int32Array(e,r+320,5);var n=new Int32Array(5);var a=new DataView(n.buffer);a.setInt32(0,t[0],false);a.setInt32(4,t[1],false);a.setInt32(8,t[2],false);a.setInt32(12,t[3],false);a.setInt32(16,t[4],false);return n};var l=function(){function e(r){n(this,e);r=r||64*1024;if(r%64>0){throw new Error("Chunk size must be a multiple of 128 bit")}this._offset=0;this._maxChunkLen=r;this._padMaxChunkLen=u(r);this._heap=new ArrayBuffer(s(this._padMaxChunkLen+320+20));this._h32=new Int32Array(this._heap);this._h8=new Int8Array(this._heap);this._core=new a({Int32Array:Int32Array},{},this._heap)}e.prototype._initState=function e(r,t){this._offset=0;var n=new Int32Array(r,t+320,5);n[0]=1732584193;n[1]=-271733879;n[2]=-1732584194;n[3]=271733878;n[4]=-1009589776};e.prototype._padChunk=function e(r,t){var n=u(r);var a=new Int32Array(this._heap,0,n>>2);h(a,r);c(a,r,t);return n};e.prototype._write=function e(r,t,n,a){f(r,this._h8,this._h32,t,n,a||0)};e.prototype._coreCall=function e(r,t,n,a,i){var o=n;this._write(r,t,n);if(i){o=this._padChunk(n,a)}this._core.hash(o,this._padMaxChunkLen)};e.prototype.rawDigest=function e(r){var t=r.byteLength||r.length||r.size||0;this._initState(this._heap,this._padMaxChunkLen);var n=0,a=this._maxChunkLen;for(n=0;t>n+a;n+=a){this._coreCall(r,n,a,t,false)}this._coreCall(r,n,t-n,t,true);return p(this._heap,this._padMaxChunkLen)};e.prototype.digest=function e(r){return o(this.rawDigest(r).buffer)};e.prototype.digestFromString=function e(r){return this.digest(r)};e.prototype.digestFromBuffer=function e(r){return this.digest(r)};e.prototype.digestFromArrayBuffer=function e(r){return this.digest(r)};e.prototype.resetState=function e(){this._initState(this._heap,this._padMaxChunkLen);return this};e.prototype.append=function e(r){var t=0;var n=r.byteLength||r.length||r.size||0;var a=this._offset%this._maxChunkLen;var i=void 0;this._offset+=n;while(t<n){i=Math.min(n-t,this._maxChunkLen-a);this._write(r,t,i,a);a+=i;t+=i;if(a===this._maxChunkLen){this._core.hash(this._maxChunkLen,this._padMaxChunkLen);a=0}}return this};e.prototype.getState=function e(){var r=this._offset%this._maxChunkLen;var t=void 0;if(!r){var n=new Int32Array(this._heap,this._padMaxChunkLen+320,5);t=n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength)}else{t=this._heap.slice(0)}return{offset:this._offset,heap:t}};e.prototype.setState=function e(r){this._offset=r.offset;if(r.heap.byteLength===20){var t=new Int32Array(this._heap,this._padMaxChunkLen+320,5);t.set(new Int32Array(r.heap))}else{this._h32.set(new Int32Array(r.heap))}return this};e.prototype.rawEnd=function e(){var r=this._offset;var t=r%this._maxChunkLen;var n=this._padChunk(t,r);this._core.hash(n,this._padMaxChunkLen);var a=p(this._heap,this._padMaxChunkLen);this._initState(this._heap,this._padMaxChunkLen);return a};e.prototype.end=function e(){return o(this.rawEnd().buffer)};return e}();r.exports=l;r.exports._core=a},{"./conv":2,"./core.sjs":3,"./utils":7}],7:[function(e,r,t){"use strict";var n=new Array(256);for(var a=0;a<256;a++){n[a]=(a<16?"0":"")+a.toString(16)}r.exports.toHex=function(e){var r=new Uint8Array(e);var t=new Array(e.byteLength);for(var a=0;a<t.length;a++){t[a]=n[r[a]]}return t.join("")};r.exports.ceilHeapSize=function(e){var r=0;if(e<=65536)return 65536;if(e<16777216){for(r=1;r<e;r=r<<1){}}else{for(r=16777216;r<e;r+=16777216){}}return r}},{}],8:[function(e,r,t){"use strict";r.exports=function(){var r=e("./rusha");var t=function(e,r,t){try{return t(null,e.digest(r))}catch(e){return t(e)}};var n=function(e,r,t,a,i){var o=new self.FileReader;o.onloadend=function s(){if(o.error){return i(o.error)}var f=o.result;r+=o.result.byteLength;try{e.append(f)}catch(e){i(e);return}if(r<a.size){n(e,r,t,a,i)}else{i(null,e.end())}};o.readAsArrayBuffer(a.slice(r,r+t))};var a=true;self.onmessage=function(e){if(!a){return}var i=e.data.data,o=e.data.file,s=e.data.id;if(typeof s==="undefined")return;if(!o&&!i)return;var f=e.data.blockSize||4*1024*1024;var u=new r(f);u.resetState();var h=function(e,r){if(!e){self.postMessage({id:s,hash:r})}else{self.postMessage({id:s,error:e.name})}};if(i)t(u,i,h);if(o)n(u,0,f,o,h)};return function(){a=false}}},{"./rusha":6}]},{},[5])(5)});
(function(e){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=e()}else if(typeof define==="function"&&define.amd){define([],e)}else{var r;if(typeof window!=="undefined"){r=window}else if(typeof global!=="undefined"){r=global}else if(typeof self!=="undefined"){r=self}else{r=this}r.Rusha=e()}})(function(){var e,r,t;return function e(r,t,n){function a(o,s){if(!t[o]){if(!r[o]){var f=typeof require=="function"&&require;if(!s&&f)return f(o,!0);if(i)return i(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var h=t[o]={exports:{}};r[o][0].call(h.exports,function(e){var t=r[o][1][e];return a(t?t:e)},h,h.exports,e,r,t,n)}return t[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<n.length;o++)a(n[o]);return a}({1:[function(e,r,t){var n=arguments[3];var a=arguments[4];var i=arguments[5];var o=JSON.stringify;r.exports=function(e,r){var t;var s=Object.keys(i);for(var f=0,u=s.length;f<u;f++){var h=s[f];var c=i[h].exports;if(c===e||c&&c.default===e){t=h;break}}if(!t){t=Math.floor(Math.pow(16,8)*Math.random()).toString(16);var p={};for(var f=0,u=s.length;f<u;f++){var h=s[f];p[h]=h}a[t]=["function(require,module,exports){"+e+"(self); }",p]}var d=Math.floor(Math.pow(16,8)*Math.random()).toString(16);var l={};l[t]=t;a[d]=["function(require,module,exports){"+"var f = require("+o(t)+");"+"(f.default ? f.default : f)(self);"+"}",l];var v={};w(d);function w(e){v[e]=true;for(var r in a[e][1]){var t=a[e][1][r];if(!v[t]){w(t)}}}var y="("+n+")({"+Object.keys(v).map(function(e){return o(e)+":["+a[e][0]+","+o(a[e][1])+"]"}).join(",")+"},{},["+o(d)+"])";var _=window.URL||window.webkitURL||window.mozURL||window.msURL;var b=new Blob([y],{type:"text/javascript"});if(r&&r.bare){return b}var k=_.createObjectURL(b);var x=new Worker(k);x.objectURL=k;return x}},{}],2:[function(e,r,t){(function(e){"use strict";var t=void 0;if(typeof self!=="undefined"&&typeof self.FileReaderSync!=="undefined"){t=new self.FileReaderSync}var n=function(e,r,t,n,a,i){var o=void 0,s=i%4,f=(a+s)%4,u=a-f;switch(s){case 0:r[i]=e.charCodeAt(n+3);case 1:r[i+1-(s<<1)|0]=e.charCodeAt(n+2);case 2:r[i+2-(s<<1)|0]=e.charCodeAt(n+1);case 3:r[i+3-(s<<1)|0]=e.charCodeAt(n)}if(a<f+(4-s)){return}for(o=4-s;o<u;o=o+4|0){t[i+o>>2]=e.charCodeAt(n+o)<<24|e.charCodeAt(n+o+1)<<16|e.charCodeAt(n+o+2)<<8|e.charCodeAt(n+o+3)}switch(f){case 3:r[i+u+1|0]=e.charCodeAt(n+u+2);case 2:r[i+u+2|0]=e.charCodeAt(n+u+1);case 1:r[i+u+3|0]=e.charCodeAt(n+u)}};var a=function(e,r,t,n,a,i){var o=void 0,s=i%4,f=(a+s)%4,u=a-f;switch(s){case 0:r[i]=e[n+3];case 1:r[i+1-(s<<1)|0]=e[n+2];case 2:r[i+2-(s<<1)|0]=e[n+1];case 3:r[i+3-(s<<1)|0]=e[n]}if(a<f+(4-s)){return}for(o=4-s;o<u;o=o+4|0){t[i+o>>2|0]=e[n+o]<<24|e[n+o+1]<<16|e[n+o+2]<<8|e[n+o+3]}switch(f){case 3:r[i+u+1|0]=e[n+u+2];case 2:r[i+u+2|0]=e[n+u+1];case 1:r[i+u+3|0]=e[n+u]}};var i=function(e,r,n,a,i,o){var s=void 0,f=o%4,u=(i+f)%4,h=i-u;var c=new Uint8Array(t.readAsArrayBuffer(e.slice(a,a+i)));switch(f){case 0:r[o]=c[3];case 1:r[o+1-(f<<1)|0]=c[2];case 2:r[o+2-(f<<1)|0]=c[1];case 3:r[o+3-(f<<1)|0]=c[0]}if(i<u+(4-f)){return}for(s=4-f;s<h;s=s+4|0){n[o+s>>2|0]=c[s]<<24|c[s+1]<<16|c[s+2]<<8|c[s+3]}switch(u){case 3:r[o+h+1|0]=c[h+2];case 2:r[o+h+2|0]=c[h+1];case 1:r[o+h+3|0]=c[h]}};r.exports=function(r,t,o,s,f,u){if(typeof r==="string"){return n(r,t,o,s,f,u)}if(r instanceof Array){return a(r,t,o,s,f,u)}if(e.Buffer&&e.Buffer.isBuffer(r)){return a(r,t,o,s,f,u)}if(r instanceof ArrayBuffer){return a(new Uint8Array(r),t,o,s,f,u)}if(r.buffer instanceof ArrayBuffer){return a(new Uint8Array(r.buffer,r.byteOffset,r.byteLength),t,o,s,f,u)}if(r instanceof Blob){return i(r,t,o,s,f,u)}throw new Error("Unsupported data type.")}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],3:[function(e,r,t){"use strict";r.exports=function e(r,t,n){"use asm";var a=new r.Int32Array(n);function i(e,r){e=e|0;r=r|0;var t=0,n=0,i=0,o=0,s=0,f=0,u=0,h=0,c=0,p=0,d=0,l=0,v=0,w=0;i=a[r+320>>2]|0;s=a[r+324>>2]|0;u=a[r+328>>2]|0;c=a[r+332>>2]|0;d=a[r+336>>2]|0;for(t=0;(t|0)<(e|0);t=t+64|0){o=i;f=s;h=u;p=c;l=d;for(n=0;(n|0)<64;n=n+4|0){w=a[t+n>>2]|0;v=((i<<5|i>>>27)+(s&u|~s&c)|0)+((w+d|0)+1518500249|0)|0;d=c;c=u;u=s<<30|s>>>2;s=i;i=v;a[e+n>>2]=w}for(n=e+64|0;(n|0)<(e+80|0);n=n+4|0){w=(a[n-12>>2]^a[n-32>>2]^a[n-56>>2]^a[n-64>>2])<<1|(a[n-12>>2]^a[n-32>>2]^a[n-56>>2]^a[n-64>>2])>>>31;v=((i<<5|i>>>27)+(s&u|~s&c)|0)+((w+d|0)+1518500249|0)|0;d=c;c=u;u=s<<30|s>>>2;s=i;i=v;a[n>>2]=w}for(n=e+80|0;(n|0)<(e+160|0);n=n+4|0){w=(a[n-12>>2]^a[n-32>>2]^a[n-56>>2]^a[n-64>>2])<<1|(a[n-12>>2]^a[n-32>>2]^a[n-56>>2]^a[n-64>>2])>>>31;v=((i<<5|i>>>27)+(s^u^c)|0)+((w+d|0)+1859775393|0)|0;d=c;c=u;u=s<<30|s>>>2;s=i;i=v;a[n>>2]=w}for(n=e+160|0;(n|0)<(e+240|0);n=n+4|0){w=(a[n-12>>2]^a[n-32>>2]^a[n-56>>2]^a[n-64>>2])<<1|(a[n-12>>2]^a[n-32>>2]^a[n-56>>2]^a[n-64>>2])>>>31;v=((i<<5|i>>>27)+(s&u|s&c|u&c)|0)+((w+d|0)-1894007588|0)|0;d=c;c=u;u=s<<30|s>>>2;s=i;i=v;a[n>>2]=w}for(n=e+240|0;(n|0)<(e+320|0);n=n+4|0){w=(a[n-12>>2]^a[n-32>>2]^a[n-56>>2]^a[n-64>>2])<<1|(a[n-12>>2]^a[n-32>>2]^a[n-56>>2]^a[n-64>>2])>>>31;v=((i<<5|i>>>27)+(s^u^c)|0)+((w+d|0)-899497514|0)|0;d=c;c=u;u=s<<30|s>>>2;s=i;i=v;a[n>>2]=w}i=i+o|0;s=s+f|0;u=u+h|0;c=c+p|0;d=d+l|0}a[r+320>>2]=i;a[r+324>>2]=s;a[r+328>>2]=u;a[r+332>>2]=c;a[r+336>>2]=d}return{hash:i}}},{}],4:[function(e,r,t){"use strict";function n(e,r){if(!(e instanceof r)){throw new TypeError("Cannot call a class as a function")}}var a=e("./rusha");var i=e("./utils"),o=i.toHex;var s=function(){function e(){n(this,e);this._rusha=new a;this._rusha.resetState()}e.prototype.update=function e(r){this._rusha.append(r);return this};e.prototype.digest=function e(r){var e=this._rusha.rawEnd().buffer;if(!r){return e}if(r==="hex"){return o(e)}throw new Error("unsupported digest encoding")};return e}();r.exports=function(){return new s}},{"./rusha":6,"./utils":7}],5:[function(e,r,t){"use strict";var n=e("webworkify");var a=e("./rusha");var i=e("./hash");var o=e("./worker");var s=e("./utils"),f=s.isDedicatedWorkerScope;var u=typeof self!=="undefined"&&f(self);a.disableWorkerBehaviour=u?o():function(){};a.createWorker=function(){var r=n(e("./worker"));var t=r.terminate;r.terminate=function(){URL.revokeObjectURL(r.objectURL);t.call(r)};return r};a.createHash=i;r.exports=a},{"./hash":4,"./rusha":6,"./utils":7,"./worker":8,webworkify:1}],6:[function(e,r,t){"use strict";function n(e,r){if(!(e instanceof r)){throw new TypeError("Cannot call a class as a function")}}var a=e("./core.sjs");var i=e("./utils"),o=i.toHex,s=i.ceilHeapSize;var f=e("./conv");var u=function(e){for(e+=9;e%64>0;e+=1){}return e};var h=function(e,r){var t=new Uint8Array(e.buffer);var n=r%4,a=r-n;switch(n){case 0:t[a+3]=0;case 1:t[a+2]=0;case 2:t[a+1]=0;case 3:t[a+0]=0}for(var i=(r>>2)+1;i<e.length;i++){e[i]=0}};var c=function(e,r,t){e[r>>2]|=128<<24-(r%4<<3);e[((r>>2)+2&~15)+14]=t/(1<<29)|0;e[((r>>2)+2&~15)+15]=t<<3};var p=function(e,r){var t=new Int32Array(e,r+320,5);var n=new Int32Array(5);var a=new DataView(n.buffer);a.setInt32(0,t[0],false);a.setInt32(4,t[1],false);a.setInt32(8,t[2],false);a.setInt32(12,t[3],false);a.setInt32(16,t[4],false);return n};var d=function(){function e(r){n(this,e);r=r||64*1024;if(r%64>0){throw new Error("Chunk size must be a multiple of 128 bit")}this._offset=0;this._maxChunkLen=r;this._padMaxChunkLen=u(r);this._heap=new ArrayBuffer(s(this._padMaxChunkLen+320+20));this._h32=new Int32Array(this._heap);this._h8=new Int8Array(this._heap);this._core=new a({Int32Array:Int32Array},{},this._heap)}e.prototype._initState=function e(r,t){this._offset=0;var n=new Int32Array(r,t+320,5);n[0]=1732584193;n[1]=-271733879;n[2]=-1732584194;n[3]=271733878;n[4]=-1009589776};e.prototype._padChunk=function e(r,t){var n=u(r);var a=new Int32Array(this._heap,0,n>>2);h(a,r);c(a,r,t);return n};e.prototype._write=function e(r,t,n,a){f(r,this._h8,this._h32,t,n,a||0)};e.prototype._coreCall=function e(r,t,n,a,i){var o=n;this._write(r,t,n);if(i){o=this._padChunk(n,a)}this._core.hash(o,this._padMaxChunkLen)};e.prototype.rawDigest=function e(r){var t=r.byteLength||r.length||r.size||0;this._initState(this._heap,this._padMaxChunkLen);var n=0,a=this._maxChunkLen;for(n=0;t>n+a;n+=a){this._coreCall(r,n,a,t,false)}this._coreCall(r,n,t-n,t,true);return p(this._heap,this._padMaxChunkLen)};e.prototype.digest=function e(r){return o(this.rawDigest(r).buffer)};e.prototype.digestFromString=function e(r){return this.digest(r)};e.prototype.digestFromBuffer=function e(r){return this.digest(r)};e.prototype.digestFromArrayBuffer=function e(r){return this.digest(r)};e.prototype.resetState=function e(){this._initState(this._heap,this._padMaxChunkLen);return this};e.prototype.append=function e(r){var t=0;var n=r.byteLength||r.length||r.size||0;var a=this._offset%this._maxChunkLen;var i=void 0;this._offset+=n;while(t<n){i=Math.min(n-t,this._maxChunkLen-a);this._write(r,t,i,a);a+=i;t+=i;if(a===this._maxChunkLen){this._core.hash(this._maxChunkLen,this._padMaxChunkLen);a=0}}return this};e.prototype.getState=function e(){var r=this._offset%this._maxChunkLen;var t=void 0;if(!r){var n=new Int32Array(this._heap,this._padMaxChunkLen+320,5);t=n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength)}else{t=this._heap.slice(0)}return{offset:this._offset,heap:t}};e.prototype.setState=function e(r){this._offset=r.offset;if(r.heap.byteLength===20){var t=new Int32Array(this._heap,this._padMaxChunkLen+320,5);t.set(new Int32Array(r.heap))}else{this._h32.set(new Int32Array(r.heap))}return this};e.prototype.rawEnd=function e(){var r=this._offset;var t=r%this._maxChunkLen;var n=this._padChunk(t,r);this._core.hash(n,this._padMaxChunkLen);var a=p(this._heap,this._padMaxChunkLen);this._initState(this._heap,this._padMaxChunkLen);return a};e.prototype.end=function e(){return o(this.rawEnd().buffer)};return e}();r.exports=d;r.exports._core=a},{"./conv":2,"./core.sjs":3,"./utils":7}],7:[function(e,r,t){"use strict";var n=new Array(256);for(var a=0;a<256;a++){n[a]=(a<16?"0":"")+a.toString(16)}r.exports.toHex=function(e){var r=new Uint8Array(e);var t=new Array(e.byteLength);for(var a=0;a<t.length;a++){t[a]=n[r[a]]}return t.join("")};r.exports.ceilHeapSize=function(e){var r=0;if(e<=65536)return 65536;if(e<16777216){for(r=1;r<e;r=r<<1){}}else{for(r=16777216;r<e;r+=16777216){}}return r};r.exports.isDedicatedWorkerScope=function(e){var r="WorkerGlobalScope"in e&&e instanceof e.WorkerGlobalScope;var t="SharedWorkerGlobalScope"in e&&e instanceof e.SharedWorkerGlobalScope;var n="ServiceWorkerGlobalScope"in e&&e instanceof e.ServiceWorkerGlobalScope;return r&&!t&&!n}},{}],8:[function(e,r,t){"use strict";r.exports=function(){var r=e("./rusha");var t=function(e,r,t){try{return t(null,e.digest(r))}catch(e){return t(e)}};var n=function(e,r,t,a,i){var o=new self.FileReader;o.onloadend=function s(){if(o.error){return i(o.error)}var f=o.result;r+=o.result.byteLength;try{e.append(f)}catch(e){i(e);return}if(r<a.size){n(e,r,t,a,i)}else{i(null,e.end())}};o.readAsArrayBuffer(a.slice(r,r+t))};var a=true;self.onmessage=function(e){if(!a){return}var i=e.data.data,o=e.data.file,s=e.data.id;if(typeof s==="undefined")return;if(!o&&!i)return;var f=e.data.blockSize||4*1024*1024;var u=new r(f);u.resetState();var h=function(e,r){if(!e){self.postMessage({id:s,hash:r})}else{self.postMessage({id:s,error:e.name})}};if(i)t(u,i,h);if(o)n(u,0,f,o,h)};return function(){a=false}}},{"./rusha":6}]},{},[5])(5)});
{
"name": "rusha",
"version": "0.8.10",
"version": "0.8.11",
"description": "A high-performance pure-javascript SHA1 implementation suitable for large binary data.",

@@ -5,0 +5,0 @@ "main": "dist/rusha.js",

@@ -8,23 +8,7 @@ /* eslint-env commonjs, browser */

const runWorker = require('./worker');
const { isDedicatedWorkerScope } = require('./utils');
const isRunningInWorker = 'WorkerGlobalScope' in self
&& self instanceof self.WorkerGlobalScope;
const isRunningInSharedWorker = 'SharedWorkerGlobalScope' in self
&& self instanceof self.SharedWorkerGlobalScope;
const isRunningInServiceWorker = 'ServiceWorkerGlobalScope' in self
&& self instanceof self.ServiceWorkerGlobalScope;
const isRunningInDedicatedWorker = typeof self !== 'undefined'
&& isDedicatedWorkerScope(self);
// Detects whether we run inside a dedicated worker or not.
//
// We can't just check for `DedicatedWorkerGlobalScope`, since IE11
// has a bug where it only supports `WorkerGlobalScope`.
//
// Therefore, we consider us as running inside a dedicated worker
// when we are running inside a worker, but not in a shared or service worker.
//
// When new types of workers are introduced, we will need to adjust this code.
const isRunningInDedicatedWorker = isRunningInWorker
&& !isRunningInSharedWorker
&& !isRunningInServiceWorker;
Rusha.disableWorkerBehaviour = isRunningInDedicatedWorker ? runWorker() : () => {};

@@ -31,0 +15,0 @@

@@ -43,1 +43,27 @@ /* eslint-env commonjs, browser */

};
//
// isDedicatedWorkerScope
//
module.exports.isDedicatedWorkerScope = (self) => {
const isRunningInWorker = 'WorkerGlobalScope' in self
&& self instanceof self.WorkerGlobalScope;
const isRunningInSharedWorker = 'SharedWorkerGlobalScope' in self
&& self instanceof self.SharedWorkerGlobalScope;
const isRunningInServiceWorker = 'ServiceWorkerGlobalScope' in self
&& self instanceof self.ServiceWorkerGlobalScope;
// Detects whether we run inside a dedicated worker or not.
//
// We can't just check for `DedicatedWorkerGlobalScope`, since IE11
// has a bug where it only supports `WorkerGlobalScope`.
//
// Therefore, we consider us as running inside a dedicated worker
// when we are running inside a worker, but not in a shared or service worker.
//
// When new types of workers are introduced, we will need to adjust this code.
return isRunningInWorker
&& !isRunningInSharedWorker
&& !isRunningInServiceWorker;
};

@@ -59,1 +59,37 @@ 'use strict';

});
describe('isDedicatedWorkerScope', () => {
it('detects a standard dedicated worker scope', () => {
class CustomWorkerScope {};
class CustomDedicatedWorkerScope extends CustomWorkerScope {};
const scope = new CustomDedicatedWorkerScope;
scope.WorkerGlobalScope = CustomWorkerScope;
scope.DedicatedWorkerGlobalScope = CustomDedicatedWorkerScope;
assert.equal(true, utils.isDedicatedWorkerScope(scope));
});
it('detects a legacy dedicated worker scope (IE11)', () => {
class CustomWorkerScope {};
const scope = new CustomWorkerScope;
scope.WorkerGlobalScope = CustomWorkerScope;
assert.equal(true, utils.isDedicatedWorkerScope(scope));
});
it('bails out on a shared worker scope', () => {
class CustomWorkerScope {};
class CustomSharedWorkerScope extends CustomWorkerScope {};
const scope = new CustomSharedWorkerScope;
scope.WorkerGlobalScope = CustomWorkerScope;
scope.SharedWorkerGlobalScope = CustomSharedWorkerScope;
assert.equal(false, utils.isDedicatedWorkerScope(scope));
});
it('bails out on a service worker scope', () => {
class CustomWorkerScope {};
class CustomServiceWorkerScope extends CustomWorkerScope {};
const scope = new CustomServiceWorkerScope;
scope.WorkerGlobalScope = CustomWorkerScope;
scope.ServiceWorkerGlobalScope = CustomServiceWorkerScope;
assert.equal(false, utils.isDedicatedWorkerScope(scope));
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc