diff --git a/qevents.js.download b/qevents.js.download new file mode 100644 index 0000000000..f3d0e497cb --- /dev/null +++ b/qevents.js.download @@ -0,0 +1,63 @@ +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.qevents=e():t.qevents=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t["default"]}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s="./shared/qevents/main.js")}({"./shared/Class.js":function(t,e){function n(t,e){function n(){if(i||(t.call(c),r(h,e,a),i=!0,e=null),this!==c){var n=this.__init__;n&&n.apply(this,arguments)}}var i,a=s.prototype=t.prototype,h=new s;return n.prototype=h,n.extend=o,h.constructor=n,n}function r(t,e,n){for(var r in e)e.hasOwnProperty(r)&&(t[r]=n?i(r,e,n):e[r])}function i(t,e,n){var r=e[t],i=n[t];return"function"==typeof r&&"function"==typeof i&&r!==i&&a.test(r)?function(){var e=this._super;this._super=n[t];try{return r.apply(this,arguments)}finally{this._super=e}}:r}function o(t){return n(this,t)}var a=/xyz/.test(function(){xyz})?/\b_super\b/:/.*/,s=function(){},c={};e.Class=o.call(function(){},{})},"./shared/email_normalizer.js":function(t,e){e.normalizeEmail=function(t){var e=/@(.*mail\.facebook\.com|quora\.com)/,n=/\+.*?@/,r="@gmail.com".length;return t=t.toLowerCase(),-1!=t.indexOf("+")&&-1==t.search(e)&&(t=t.replace(n,"@")),t.endsWith("@gmail.com")&&(t=t.slice(0,-r).replace(/\./g,"")+"@gmail.com"),t}},"./shared/hash_email.js":function(t,e,n){var r=n("./third_party/sjcl.js");e.validateEmail=function(t){return/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(t)},e.validateSHA256=function(t){return/^[a-z0-9]{64}$/i.test(t)},e.sha256HexDigest=function(t){var e=r.hash.sha256.hash(t);return r.codec.hex.fromBits(e)}},"./shared/polyfills/array.js":function(t,e){var n=function(t,e,n){"function"==typeof Object.defineProperty?Object.defineProperty(t,e,{configurable:!0,value:n,writable:!0,enumerable:!1}):t[e]=n};if(!Array.prototype.every){var r=function(t,e){"use strict";var n,r;if(null===this)throw new TypeError("this is null or not defined");var i=Object(this),o=i.length>>>0;if("function"!=typeof t)throw new TypeError;for(arguments.length>1&&(n=e),r=0;r>>0,r=arguments.length>=2?arguments[1]:void 0,i=0;i>>0;if(0===i)return-1;var o=+e||0;if(Math.abs(o)===Infinity&&(o=0),o>=i)return-1;for(n=Math.max(o>=0?o:i-Math.abs(o),0);n>>0;if("function"!=typeof t)throw new TypeError(t+" is not a function");for(arguments.length>1&&(n=e),r=0;r>>0;if("function"!=typeof t)throw new TypeError(t+" is not a function");for(arguments.length>1&&(n=e),r=new Array(a),i=0;i>>0;if("function"!=typeof t)throw new TypeError;for(var r=[],i=arguments.length>=2?arguments[1]:void 0,o=0;o>>0,i=0;if(2==arguments.length)e=arguments[1];else{for(;i=r)throw new TypeError("Reduce of empty array with no initial value");e=n[i++]}for(;i>>0;if(0===i)return-1;for(e=i-1,arguments.length>1&&(e=Number(arguments[1]),e!=e?e=0:0!==e&&e!=1/0&&e!=-1/0&&(e=(e>0||-1)*Math.floor(Math.abs(e)))),n=e>=0?Math.min(e,i-1):i-Math.abs(e);n>=0;n--)if(n in r&&r[n]===t)return n;return-1};n(Array.prototype,"lastIndexOf",u)}if(!Array.prototype.includes){var l=function(t){"use strict";if(null==this)throw new TypeError("Array.prototype.includes called on null or undefined");var e=Object(this),n=parseInt(e.length,10)||0;if(0===n)return!1;var r,i=parseInt(arguments[1],10)||0;i>=0?r=i:(r=n+i)<0&&(r=0);for(var o;rn.length)&&(e=n.length),e-=t.length;var r=n.indexOf(t,e);return-1!==r&&r===e}),String.prototype.startsWith||(String.prototype.startsWith=function(t,e){return e=e||0,this.substr(e,t.length)===t}),String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}),String.prototype.includes||(String.prototype.includes=function(t,e){"use strict";return"number"!=typeof e&&(e=0),!(e+t.length>this.length)&&-1!==this.indexOf(t,e)})},"./shared/qevents/main.js":function(t,e,n){n("./shared/polyfills/string.js"),n("./shared/polyfills/array.js"),n("./shared/polyfills/function.js"),n("./shared/polyfills/object.js"),n("./shared/polyfills/date.js"),n("./shared/qevents/pixel.js").init(),n("./shared/qevents/queue.js").flush()},"./shared/qevents/pixel.js":function(t,e,n){function r(){try{var t=o("ia_share_url");if(null!==t)return t}catch(t){}try{return ia_document!==undefined&&ia_document.shareURL}catch(t){return}}function i(t){var e,n=[];for(var r in t)e=t[r],a(r)&&s(e)&&n.push(r+"="+encodeURIComponent(e));return n.join("&")}function o(t){var e=null,n=[];return window.location.search.substr(1).split("&").forEach(function(r){n=r.split("="),n[0]===t&&(e=decodeURIComponent(n[1]))}),e}function a(t){return"string"==typeof t}function s(t){return"string"==typeof t||!isNaN(Number(t))}function c(){function t(t,e){var n=window.history[t];window.history[t]=function(){var t=n.apply(this,arguments);return e.apply(this,arguments),t}}window.history.pushState&&window.history.replaceState&&(t("pushState",h),t("replaceState",h),window.addEventListener("popstate",h,!1))}function h(){!0!==window.qp.disablePushState&&e.quoraPixelHelper("track","ViewContent")}var u,l=n("./shared/Class.js").Class,f=n("./shared/email_normalizer.js"),d=n("./shared/hash_email.js"),p=n("./shared/qevents/timer.js").PixelTimer,y=l.extend({__init__:function(t,e){if("string"!=typeof t)throw new Error("Quora Pixel Error: The second argument passed to qp is invalid.");this.uuid=t,this.email=this._getEmailFromPassback(e),this.eventSource=this._getEventSourceFromPassback(e),this.lastViewContentUrl=""},track:function(t,n){if("string"!=typeof t)throw new Error("Quora Pixel Error: The second argument passed to qp is invalid.");var r,i,o=this._getIsFBIAUrl(),a=this._getValueFromPassback(n),s=this._getEventIdFromPassback(n),c=this._getUrl();this._shouldTrack(t,c)&&(r=this._getMetadata(t,c,o,a,undefined,undefined,s),i=this._getPixelUrl(r),e.firePixel(i))},trackDwellTime:function(t,n){if("number"!=typeof t)throw new Error("Quora Pixel Error: Invalid dwell time.");var r,i,o=this._getUrl();r=this._getMetadata("DwellTime",o,undefined,undefined,t,n,undefined),i=this._getPixelUrl(r),e.firePixel(i)},_shouldTrack:function(t,e){return("ViewContent"!=t||e!=this.lastViewContentUrl)&&("DwellTime"!=t&&("ViewContent"==t&&(this.lastViewContentUrl=e),!0))},_getMetadata:function(t,e,n,r,i,o,a){var s={j:1,u:e,tag:t,ts:(new Date).getTime()};return n&&(s.fbia=1),r!==undefined&&(s.v=r),this.email!==undefined&&(s.em=this.email),this.eventSource!==undefined&&(s.i=this.eventSource),"DwellTime"===t&&i!==undefined&&(s.dwt=i),o!==undefined&&(s.ive=o),a!==undefined&&(s.evid=a),s},_getValueFromPassback:function(t){var e;if(t!==undefined&&null!==t&&t.value!==undefined&&"number"!=typeof(e=t.value)&&"string"!=typeof e)throw new Error("Quora Pixel Error: The third argument passed to qp is invalid.");return e},_getEventIdFromPassback:function(t){var e;return t!==undefined&&null!==t&&t.event_id!==undefined&&(e=t.event_id),e},_getEmailFromPassback:function(t){var e;if(t!==undefined&&null!==t)if(t.email!==undefined){if("string"!=typeof(e=f.normalizeEmail(t.email))||!d.validateEmail(e))throw new Error("Quora Pixel Error: The third argument passed to qp is invalid.");e=d.sha256HexDigest(e)}else if(t.hashed_email!==undefined&&("string"!=typeof(e=t.hashed_email)||!d.validateSHA256(e)))throw new Error("Quora Pixel Error: The third argument passed to qp is invalid.");return e},_getEventSourceFromPassback:function(t){var e;if(t!==undefined&&null!==t&&t.event_source!==undefined&&"string"!=typeof(e=t.event_source))throw new Error("Quora Pixel Error: The event source argument passed to qp is invalid.");return e},_getUrl:function(){var t=r();return t||(t=window.location.href),t},_getIsFBIAUrl:function(){return Boolean(r())},_getPixelUrl:function(t){return this._getBasePixelUrl()+this.uuid+"/pixel?"+i(t)},_getBasePixelUrl:function(){return"https://q.quora.com/_/ad/"}}),m=l.extend({__init__:function(){this.uuidToPixel={}},installPixel:function(t,e){if(this.uuidToPixel[t]===undefined){var n=new y(t,e);this.uuidToPixel[t]=n}},track:function(t,e){var n=Object.keys(this.uuidToPixel);if(!n.length)throw new Error("Quora Pixel Error: Base pixel code is not installed properly.");for(var r=0;r0&&t(r,e),a=undefined}}function o(){"undefined"!=typeof document.msHidden?(s="msHidden",c="msvisibilitychange"):"undefined"!=typeof document.webkitHidden?(s="webkitHidden",c="webkitvisibilitychange"):"undefined"!=typeof document.mozHidden?(s="mozHidden",c="mozvisibilitychange"):(s="hidden",c="visibilitychange")}var a,s,c,h=n("./shared/Class.js").Class;e.PixelTimer=h.extend({__init__:function(t){o(),document.addEventListener(c,function(){"visible"===document[s]||!1===document[s]?r():"hidden"!==document[s]&&!0!==document[s]||i(t,s)}),window.addEventListener("pageshow",function(t){r()}),window.addEventListener("pagehide",function(e){i(t,"pagehide")}),window.addEventListener("blur",function(){i(t,"blur")}),window.addEventListener("focus",function(){r()})}})},"./third_party/sjcl.js":function(t,e){/*! + +SJCL is open. You can use, modify and redistribute it under a BSD +license or under the GNU GPL, version 2.0. + +--------------------------------------------------------------------- + +http://opensource.org/licenses/BSD-2-Clause + +Copyright (c) 2009-2015, Emily Stark, Mike Hamburg and Dan Boneh at +Stanford University. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +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. + +--------------------------------------------------------------------- + +http://opensource.org/licenses/GPL-2.0 + +The Stanford Javascript Crypto Library (hosted here on GitHub) is a +project by the Stanford Computer Security Lab to build a secure, +powerful, fast, small, easy-to-use, cross-browser library for +cryptography in Javascript. + +Copyright (c) 2009-2015, Emily Stark, Mike Hamburg and Dan Boneh at +Stanford University. + +This program is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2 of the License, or (at your +option) any later version. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*/ +"use strict";function n(t,e,n){if(4!==e.length)throw new h.exception.invalid("invalid aes block size");var r=t.b[n],i=e[0]^r[0],o=e[n?3:1]^r[1],a=e[2]^r[2];e=e[n?1:3]^r[3];var s,c,u,l,f=r.length/4-2,d=4,p=[0,0,0,0];s=t.s[n],t=s[0];var y=s[1],m=s[2],g=s[3],v=s[4];for(l=0;l>>24]^y[o>>16&255]^m[a>>8&255]^g[255&e]^r[d],c=t[o>>>24]^y[a>>16&255]^m[e>>8&255]^g[255&i]^r[d+1],u=t[a>>>24]^y[e>>16&255]^m[i>>8&255]^g[255&o]^r[d+2],e=t[e>>>24]^y[i>>16&255]^m[o>>8&255]^g[255&a]^r[d+3],d+=4,i=s,o=c,a=u;for(l=0;4>l;l++)p[n?3&-l:l]=v[i>>>24]<<24^v[o>>16&255]<<16^v[a>>8&255]<<8^v[255&e]^r[d++],s=i,i=o,o=a,a=e,e=s;return p}function r(t,e){var n,r,i,o=t.F,a=t.b,s=o[0],c=o[1],h=o[2],u=o[3],l=o[4],f=o[5],d=o[6],p=o[7];for(n=0;64>n;n++)16>n?r=e[n]:(r=e[n+1&15],i=e[n+14&15],r=e[15&n]=(r>>>7^r>>>18^r>>>3^r<<25^r<<14)+(i>>>17^i>>>19^i>>>10^i<<15^i<<13)+e[15&n]+e[n+9&15]|0),r=r+p+(l>>>6^l>>>11^l>>>25^l<<26^l<<21^l<<7)+(d^l&(f^d))+a[n],p=d,d=f,f=l,l=u+r|0,u=h,h=c,c=s,s=r+(c&h^u&(c^h))+(c>>>2^c>>>13^c>>>22^c<<30^c<<19^c<<10)|0;o[0]=o[0]+s|0,o[1]=o[1]+c|0,o[2]=o[2]+h|0,o[3]=o[3]+u|0,o[4]=o[4]+l|0,o[5]=o[5]+f|0,o[6]=o[6]+d|0,o[7]=o[7]+p|0}function i(t,e){var n,r=h.random.K[t],i=[];for(n in r)r.hasOwnProperty(n)&&i.push(r[n]);for(n=0;ne&&(t.h[e]=t.h[e]+1|0,!t.h[e]);e++);return t.L.encrypt(t.h)}function c(t,e){return function(){e.apply(t,arguments)}}var h={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(t){this.toString=function(){return"CORRUPT: "+this.message},this.message=t},invalid:function(t){this.toString=function(){return"INVALID: "+this.message},this.message=t},bug:function(t){this.toString=function(){return"BUG: "+this.message},this.message=t},notReady:function(t){this.toString=function(){return"NOT READY: "+this.message},this.message=t}}};h.cipher.aes=function(t){this.s[0][0][0]||this.O();var e,n,r,i,o=this.s[0][4],a=this.s[1];e=t.length;var s=1;if(4!==e&&6!==e&&8!==e)throw new h.exception.invalid("invalid aes key size");for(this.b=[r=t.slice(0),i=[]],t=e;t<4*e+28;t++)n=r[t-1],(0==t%e||8===e&&4==t%e)&&(n=o[n>>>24]<<24^o[n>>16&255]<<16^o[n>>8&255]<<8^o[255&n],0==t%e&&(n=n<<8^n>>>24^s<<24,s=s<<1^283*(s>>7))),r[t]=r[t-e]^n;for(e=0;t;e++,t--)n=r[3&e?t:t-4],i[e]=4>=t||4>e?n:a[0][o[n>>>24]]^a[1][o[n>>16&255]]^a[2][o[n>>8&255]]^a[3][o[255&n]]},h.cipher.aes.prototype={encrypt:function(t){return n(this,t,0)},decrypt:function(t){return n(this,t,1)},s:[[[],[],[],[],[]],[[],[],[],[],[]]],O:function(){var t,e,n,r,i,o,a,s=this.s[0],c=this.s[1],h=s[4],u=c[4],l=[],f=[];for(t=0;256>t;t++)f[(l[t]=t<<1^283*(t>>7))^t]=t;for(e=n=0;!h[e];e^=r||1,n=f[n]||1)for(o=n^n<<1^n<<2^n<<3^n<<4,o=o>>8^255&o^99,h[e]=o,u[o]=e,i=l[t=l[r=l[e]]],a=16843009*i^65537*t^257*r^16843008*e,i=257*l[o]^16843008*o,t=0;4>t;t++)s[t][e]=i=i<<24^i>>>8,c[t][o]=a=a<<24^a>>>8;for(t=0;5>t;t++)s[t]=s[t].slice(0),c[t]=c[t].slice(0)}},h.bitArray={bitSlice:function(t,e,n){return t=h.bitArray.$(t.slice(e/32),32-(31&e)).slice(1),void 0===n?t:h.bitArray.clamp(t,n-e)},extract:function(t,e,n){var r=Math.floor(-e-n&31);return(-32&(e+n-1^e)?t[e/32|0]<<32-r^t[e/32+1|0]>>>r:t[e/32|0]>>>r)&(1<>e-1,1)),t},partial:function(t,e,n){return 32===t?e:(n?0|e:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(h.bitArray.bitLength(t)!==h.bitArray.bitLength(e))return!1;var n,r=0;for(n=0;n>>e),n=t[i]<<32-e;return i=t.length?t[t.length-1]:0,t=h.bitArray.getPartial(i),r.push(h.bitArray.partial(e+t&31,32>>24|n>>>8&65280|(65280&n)<<8|n<<24;return t}},h.codec.utf8String={fromBits:function(t){var e,n,r="",i=h.bitArray.bitLength(t);for(e=0;e>>8>>>8>>>8),n<<=8;return decodeURIComponent(escape(r))},toBits:function(t){t=unescape(encodeURIComponent(t));var e,n=[],r=0;for(e=0;e>>a)>>>i),a(r=u.indexOf(t.charAt(n)))){if(!e)try{return h.codec.base32hex.toBits(t)}catch(t){}throw new h.exception.invalid("this isn't "+f+"!")}c>a?(c-=a,s.push(l^r>>>c),l=r<>>i)>>>26),6>i?(a=t[n]<<6-i,i+=26,n++):(a<<=6,i-=6);for(;3&r.length&&!e;)r+="=";return r},toBits:function(t,e){t=t.replace(/\s|=/g,"");var n,r,i=[],o=0,a=h.codec.base64.B,s=0;for(e&&(a=a.substr(0,62)+"-_"),n=0;n(r=a.indexOf(t.charAt(n))))throw new h.exception.invalid("this isn't base64!");26>>o),s=r<<32-o):(o+=6,s^=r<<32-o)}return 56&o&&i.push(h.bitArray.partial(56&o,s,1)),i}},h.codec.base64url={fromBits:function(t){return h.codec.base64.fromBits(t,1,1)},toBits:function(t){return h.codec.base64.toBits(t,1)}},h.hash.sha256=function(t){this.b[0]||this.O(),t?(this.F=t.F.slice(0),this.A=t.A.slice(0),this.l=t.l):this.reset()},h.hash.sha256.hash=function(t){return(new h.hash.sha256).update(t).finalize()},h.hash.sha256.prototype={blockSize:512,reset:function(){return this.F=this.Y.slice(0),this.A=[],this.l=0,this},update:function(t){"string"==typeof t&&(t=h.codec.utf8String.toBits(t));var e,n=this.A=h.bitArray.concat(this.A,t);if(e=this.l,9007199254740991<(t=this.l=e+h.bitArray.bitLength(t)))throw new h.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!=typeof Uint32Array){var i=new Uint32Array(n),o=0;for(e=512+e-(512+e&511);e<=t;e+=512)r(this,i.subarray(16*o,16*(o+1))),o+=1;n.splice(0,16*o)}else for(e=512+e-(512+e&511);e<=t;e+=512)r(this,n.splice(0,16));return this},finalize:function(){var t,e=this.A,n=this.F,e=h.bitArray.concat(e,[h.bitArray.partial(1,1)]);for(t=e.length+2;15&t;t++)e.push(0);for(e.push(Math.floor(this.l/4294967296)),e.push(0|this.l);e.length;)r(this,e.splice(0,16));return this.reset(),n},Y:[],b:[],O:function(){function t(t){return 4294967296*(t-Math.floor(t))|0}for(var e,n,r=0,i=2;64>r;i++){for(n=!0,e=2;e*e<=i;e++)if(0==i%e){n=!1;break}n&&(8>r&&(this.Y[r]=t(Math.pow(i,.5))),this.b[r]=t(Math.pow(i,1/3)),r++)}}},h.mode.ccm={name:"ccm",G:[],listenProgress:function(t){h.mode.ccm.G.push(t)},unListenProgress:function(t){-1<(t=h.mode.ccm.G.indexOf(t))&&h.mode.ccm.G.splice(t,1)},fa:function(t){var e,n=h.mode.ccm.G.slice();for(e=0;ec)throw new h.exception.invalid("ccm: iv must be at least 7 bytes");for(o=2;4>o&&u>>>8*o;o++);return o<15-c&&(o=15-c),n=s.clamp(n,8*(15-o)),e=h.mode.ccm.V(t,e,n,r,i,o),a=h.mode.ccm.C(t,a,n,e,i,o),s.concat(a.data,a.tag)},decrypt:function(t,e,n,r,i){i=i||64,r=r||[];var o=h.bitArray,a=o.bitLength(n)/8,s=o.bitLength(e),c=o.clamp(e,s-i),u=o.bitSlice(e,s-i),s=(s-i)/8;if(7>a)throw new h.exception.invalid("ccm: iv must be at least 7 bytes");for(e=2;4>e&&s>>>8*e;e++);if(e<15-a&&(e=15-a),n=o.clamp(n,8*(15-e)),c=h.mode.ccm.C(t,c,n,u,i,e),t=h.mode.ccm.V(t,c.data,n,r,i,e),!o.equal(c.tag,t))throw new h.exception.corrupt("ccm: tag doesn't match");return c.data},na:function(t,e,n,r,i,o){var a=[],s=h.bitArray,c=s.i;if(r=[s.partial(8,(e.length?64:0)|r-2<<2|o-1)],r=s.concat(r,n),r[3]|=i,r=t.encrypt(r),e.length)for(n=s.bitLength(e)/8,65279>=n?a=[s.partial(16,n)]:4294967295>=n&&(a=s.concat([s.partial(16,65534)],[n])),a=s.concat(a,e),e=0;ei||16l&&(h.mode.ccm.fa(a/c),l+=f),n[3]++,i=t.encrypt(n),e[a]^=i[0],e[a+1]^=i[1],e[a+2]^=i[2],e[a+3]^=i[3];return{tag:r,data:s.clamp(e,u)}}},h.mode.ocb2={name:"ocb2",encrypt:function(t,e,n,r,i,o){if(128!==h.bitArray.bitLength(n))throw new h.exception.invalid("ocb iv must be 128 bits");var a,s=h.mode.ocb2.S,c=h.bitArray,u=c.i,l=[0,0,0,0];n=s(t.encrypt(n));var f,d=[];for(r=r||[],i=i||64,a=0;a+4i.bitLength(n)&&(s=o(s,r(s)),n=i.concat(n,[-2147483648,0,0,0])),a=o(a,n),t.encrypt(o(r(o(s,r(s))),a))},S:function(t){return[t[0]<<1^t[1]>>>31,t[1]<<1^t[2]>>>31,t[2]<<1^t[3]>>>31,t[3]<<1^135*(t[0]>>>31)]}},h.mode.gcm={name:"gcm",encrypt:function(t,e,n,r,i){var o=e.slice(0);return e=h.bitArray,r=r||[],t=h.mode.gcm.C(!0,t,o,r,n,i||128),e.concat(t.data,t.tag)},decrypt:function(t,e,n,r,i){var o=e.slice(0),a=h.bitArray,s=a.bitLength(o);if(i=i||128,r=r||[],i<=s?(e=a.bitSlice(o,s-i),o=a.bitSlice(o,0,s-i)):(e=o,o=[]),t=h.mode.gcm.C(!1,t,o,r,n,i),!a.equal(t.tag,e))throw new h.exception.corrupt("gcm: tag doesn't match");return t.data},ka:function(t,e){var n,r,i,o,a,s=h.bitArray.i;for(i=[0,0,0,0],o=e.slice(0),n=0;128>n;n++){for((r=0!=(t[Math.floor(n/32)]&1<<31-n%32))&&(i=s(i,o)),a=0!=(1&o[3]),r=3;0>>1|(1&o[r-1])<<31;o[0]>>>=1,a&&(o[0]^=-520093696)}return i},j:function(t,e,n){var r,i=n.length;for(e=e.slice(0),r=0;ri&&(t=e.hash(t)),n=0;nr||0>n)throw new h.exception.invalid("invalid params to pbkdf2");"string"==typeof t&&(t=h.codec.utf8String.toBits(t)),"string"==typeof e&&(e=h.codec.utf8String.toBits(e)),i=i||h.misc.hmac,t=new i(t);var o,a,s,c,u=[],l=h.bitArray;for(c=1;32*u.length<(r||1);c++){for(i=o=t.encrypt(l.concat(e,[c])),a=1;ao;o++)i.push(4294967296*Math.random()|0);for(o=0;o=1<this.o&&(this.o=c),this.P++,this.b=h.hash.sha256.hash(this.b.concat(i)),this.L=new h.cipher.aes(this.b),n=0;4>n&&(this.h[n]=this.h[n]+1|0,!this.h[n]);n++);}for(n=0;n>>=1;this.c[s].update([r,this.N++,2,e,a,t.length].concat(t))}break;case"string":void 0===e&&(e=t.length),this.c[s].update([r,this.N++,3,e,a,t.length]),this.c[s].update(t);break;default:u=1}if(u)throw new h.exception.bug("random: addEntropy only supports number, array of numbers or string");this.m[s]+=e,this.f+=e,c===this.u&&(this.isReady()!==this.u&&i("seeded",Math.max(this.o,this.f)),i("progress",this.getProgress()))},isReady:function(t){return t=this.T[void 0!==t?t:this.M],this.o&&this.o>=t?this.m[0]>this.ba&&(new Date).valueOf()>this.Z?this.J|this.I:this.I:this.f>=t?this.J|this.u:this.u},getProgress:function(t){return t=this.T[t||this.M],this.o>=t?1:this.f>t?1:this.f/t},startCollectors:function(){if(!this.D){if(this.a={loadTimeCollector:c(this,this.ma),mouseCollector:c(this,this.oa),keyboardCollector:c(this,this.la),accelerometerCollector:c(this,this.ea),touchCollector:c(this,this.qa)},window.addEventListener)window.addEventListener("load",this.a.loadTimeCollector,!1),window.addEventListener("mousemove",this.a.mouseCollector,!1),window.addEventListener("keypress",this.a.keyboardCollector,!1),window.addEventListener("devicemotion",this.a.accelerometerCollector,!1),window.addEventListener("touchmove",this.a.touchCollector,!1);else{if(!document.attachEvent)throw new h.exception.bug("can't attach event");document.attachEvent("onload",this.a.loadTimeCollector),document.attachEvent("onmousemove",this.a.mouseCollector),document.attachEvent("keypress",this.a.keyboardCollector)}this.D=!0}},stopCollectors:function(){this.D&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,!1),window.removeEventListener("mousemove",this.a.mouseCollector,!1),window.removeEventListener("keypress",this.a.keyboardCollector,!1),window.removeEventListener("devicemotion",this.a.accelerometerCollector,!1),window.removeEventListener("touchmove",this.a.touchCollector,!1)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove",this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.D=!1)},addEventListener:function(t,e){this.K[t][this.ga++]=e},removeEventListener:function(t,e){var n,r,i=this.K[t],o=[];for(r in i)i.hasOwnProperty(r)&&i[r]===e&&o.push(r);for(n=0;n=a.iter||64!==a.ts&&96!==a.ts&&128!==a.ts||128!==a.ks&&192!==a.ks&&256!==a.ks||2>a.iv.length||4=e.iter||64!==e.ts&&96!==e.ts&&128!==e.ts||128!==e.ks&&192!==e.ks&&256!==e.ks||!e.iv||2>e.iv.length||4