diff --git a/resources/celerity/map.php b/resources/celerity/map.php --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -11,7 +11,7 @@ 'core.pkg.js' => '5f50c01b', 'darkconsole.pkg.js' => '8ab24e01', 'differential.pkg.css' => '1940be3f', - 'differential.pkg.js' => '53c1ccc2', + 'differential.pkg.js' => '0b9d2159', 'diffusion.pkg.css' => '591664fa', 'diffusion.pkg.js' => 'bfc0737b', 'maniphest.pkg.css' => '68d4dd3d', @@ -155,6 +155,7 @@ 'rsrc/css/sprite-menu.css' => '9ef76324', 'rsrc/css/sprite-projects.css' => 'b0d9e24f', 'rsrc/css/sprite-tokens.css' => '1706b943', + 'rsrc/externals/cryptojs/sha1.js' => '58a13a73', 'rsrc/externals/font/fontawesome/fontawesome-webfont.eot' => '5fb6fb0e', 'rsrc/externals/font/fontawesome/fontawesome-webfont.ttf' => 'a653cb11', 'rsrc/externals/font/fontawesome/fontawesome-webfont.woff' => '80526fc8', @@ -438,7 +439,7 @@ 'rsrc/js/application/uiexample/gesture-example.js' => '558829c2', 'rsrc/js/application/uiexample/notification-example.js' => '8ce821c5', 'rsrc/js/core/Busy.js' => '6453c869', - 'rsrc/js/core/DragAndDropFileUpload.js' => '8c49f386', + 'rsrc/js/core/DragAndDropFileUpload.js' => 'eb849c84', 'rsrc/js/core/DraggableList.js' => 'a16ec1c6', 'rsrc/js/core/FileUpload.js' => 'a4ae61bf', 'rsrc/js/core/Hovercard.js' => '7e8468ae', @@ -521,6 +522,7 @@ 'conpherence-thread-manager' => '0324970d', 'conpherence-update-css' => '1099a660', 'conpherence-widget-pane-css' => '3d575438', + 'cryptojs-sha1' => '58a13a73', 'differential-changeset-view-css' => '6a8b172a', 'differential-core-view-css' => '7ac3cabc', 'differential-inline-comment-editor' => '0286a1db', @@ -719,7 +721,7 @@ 'phabricator-core-css' => '86bfbe8c', 'phabricator-countdown-css' => '86b7b0a0', 'phabricator-dashboard-css' => '17937d22', - 'phabricator-drag-and-drop-file-upload' => '8c49f386', + 'phabricator-drag-and-drop-file-upload' => 'eb849c84', 'phabricator-draggable-list' => 'a16ec1c6', 'phabricator-fatal-config-template-css' => '8e6c6fcd', 'phabricator-feed-css' => 'b513b5f4', @@ -1515,14 +1517,6 @@ 'javelin-request', 'javelin-typeahead-source', ), - '8c49f386' => array( - 'javelin-install', - 'javelin-util', - 'javelin-request', - 'javelin-dom', - 'javelin-uri', - 'phabricator-file-upload', - ), '8ce821c5' => array( 'phabricator-notification', 'javelin-stratcom', @@ -1916,6 +1910,15 @@ 'phabricator-phtize', 'javelin-dom', ), + 'eb849c84' => array( + 'javelin-install', + 'javelin-util', + 'javelin-request', + 'javelin-dom', + 'javelin-uri', + 'phabricator-file-upload', + 'cryptojs-sha1', + ), 'efe49472' => array( 'javelin-install', 'javelin-util', diff --git a/webroot/rsrc/externals/cryptojs/LICENSE b/webroot/rsrc/externals/cryptojs/LICENSE new file mode 100644 --- /dev/null +++ b/webroot/rsrc/externals/cryptojs/LICENSE @@ -0,0 +1,11 @@ +(c) 2009-2013 by Jeff Mott. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer. + +Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the following disclaimer in the documentation or other materials provided with the distribution. + +Neither the name CryptoJS nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS," AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/webroot/rsrc/externals/cryptojs/sha1.js b/webroot/rsrc/externals/cryptojs/sha1.js new file mode 100755 --- /dev/null +++ b/webroot/rsrc/externals/cryptojs/sha1.js @@ -0,0 +1,19 @@ +/** + * CryptoJS v3.1.2 + * code.google.com/p/crypto-js + * (c) 2009-2013 by Jeff Mott. All rights reserved. + * code.google.com/p/crypto-js/wiki/License + * + * @provides cryptojs-sha1 + * @do-not-minify + * @nolint + */ +var CryptoJS=CryptoJS||function(e,m){var p={},j=p.lib={},l=function(){},f=j.Base={extend:function(a){l.prototype=this;var c=new l;a&&c.mixIn(a);c.hasOwnProperty("init")||(c.init=function(){c.$super.init.apply(this,arguments)});c.init.prototype=c;c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}}, +n=j.WordArray=f.extend({init:function(a,c){a=this.words=a||[];this.sigBytes=c!=m?c:4*a.length},toString:function(a){return(a||h).stringify(this)},concat:function(a){var c=this.words,q=a.words,d=this.sigBytes;a=a.sigBytes;this.clamp();if(d%4)for(var b=0;b>>2]|=(q[b>>>2]>>>24-8*(b%4)&255)<<24-8*((d+b)%4);else if(65535>>2]=q[b>>>2];else c.push.apply(c,q);this.sigBytes+=a;return this},clamp:function(){var a=this.words,c=this.sigBytes;a[c>>>2]&=4294967295<< +32-8*(c%4);a.length=e.ceil(c/4)},clone:function(){var a=f.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var c=[],b=0;b>>2]>>>24-8*(d%4)&255;b.push((f>>>4).toString(16));b.push((f&15).toString(16))}return b.join("")},parse:function(a){for(var c=a.length,b=[],d=0;d>>3]|=parseInt(a.substr(d, +2),16)<<24-4*(d%8);return new n.init(b,c/2)}},g=b.Latin1={stringify:function(a){var c=a.words;a=a.sigBytes;for(var b=[],d=0;d>>2]>>>24-8*(d%4)&255));return b.join("")},parse:function(a){for(var c=a.length,b=[],d=0;d>>2]|=(a.charCodeAt(d)&255)<<24-8*(d%4);return new n.init(b,c)}},r=b.Utf8={stringify:function(a){try{return decodeURIComponent(escape(g.stringify(a)))}catch(c){throw Error("Malformed UTF-8 data");}},parse:function(a){return g.parse(unescape(encodeURIComponent(a)))}}, +k=j.BufferedBlockAlgorithm=f.extend({reset:function(){this._data=new n.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=r.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var c=this._data,b=c.words,d=c.sigBytes,f=this.blockSize,h=d/(4*f),h=a?e.ceil(h):e.max((h|0)-this._minBufferSize,0);a=h*f;d=e.min(4*a,d);if(a){for(var g=0;ga;a++){if(16>a)l[a]=f[n+a]|0;else{var c=l[a-3]^l[a-8]^l[a-14]^l[a-16];l[a]=c<<1|c>>>31}c=(h<<5|h>>>27)+j+l[a];c=20>a?c+((g&e|~g&k)+1518500249):40>a?c+((g^e^k)+1859775393):60>a?c+((g&e|g&k|e&k)-1894007588):c+((g^e^ +k)-899497514);j=k;k=e;e=g<<30|g>>>2;g=h;h=c}b[0]=b[0]+h|0;b[1]=b[1]+g|0;b[2]=b[2]+e|0;b[3]=b[3]+k|0;b[4]=b[4]+j|0},_doFinalize:function(){var f=this._data,e=f.words,b=8*this._nDataBytes,h=8*f.sigBytes;e[h>>>5]|=128<<24-h%32;e[(h+64>>>9<<4)+14]=Math.floor(b/4294967296);e[(h+64>>>9<<4)+15]=b;f.sigBytes=4*e.length;this._process();return this._hash},clone:function(){var e=j.clone.call(this);e._hash=this._hash.clone();return e}});e.SHA1=j._createHelper(m);e.HmacSHA1=j._createHmacHelper(m)})(); diff --git a/webroot/rsrc/js/core/DragAndDropFileUpload.js b/webroot/rsrc/js/core/DragAndDropFileUpload.js --- a/webroot/rsrc/js/core/DragAndDropFileUpload.js +++ b/webroot/rsrc/js/core/DragAndDropFileUpload.js @@ -5,6 +5,7 @@ * javelin-dom * javelin-uri * phabricator-file-upload + * cryptojs-sha1 * @provides phabricator-drag-and-drop-file-upload * @javelin */ @@ -170,6 +171,44 @@ } }, _sendRequest : function(spec) { + JX.log(spec.size); + + JX.log(CryptoJS.SHA1("quack").toString(CryptoJS.enc.Hex)); + + var reader = new FileReader(); + var cursor = 0; + var hash = CryptoJS.algo.SHA1.create(); + var chunk = (1024 * 1024); + var begin; + + function next() { + var start = cursor; + var end = Math.min(cursor + chunk, spec.size); + cursor = end; + begin = +(new Date()); + reader.readAsBinaryString(spec.slice(start, end)); + } + + reader.onloadend = function(evt) { + if (evt.target.readyState == FileReader.DONE) { + JX.log('read took ' + (new Date() - begin) + ' ms'); + var result = evt.target.result; + begin = +(new Date()); + hash.update(result); + JX.log('update took ' + (new Date() - begin) + ' ms'); + if (cursor >= spec.size) { + var checksum = hash.finalize().toString(CryptoJS.enc.Hex); + JX.log(checksum); + } else { + next(); + } + } + }; + + next(); + + return; + var file = new JX.PhabricatorFileUpload() .setName(spec.name) .setTotalBytes(spec.size)