UNPKG

536 kBJavaScriptView Raw
1var abiDecoder =
2/******/ (function(modules) { // webpackBootstrap
3/******/ // The module cache
4/******/ var installedModules = {};
5
6/******/ // The require function
7/******/ function __webpack_require__(moduleId) {
8
9/******/ // Check if module is in cache
10/******/ if(installedModules[moduleId])
11/******/ return installedModules[moduleId].exports;
12
13/******/ // Create a new module (and put it into the cache)
14/******/ var module = installedModules[moduleId] = {
15/******/ i: moduleId,
16/******/ l: false,
17/******/ exports: {}
18/******/ };
19
20/******/ // Execute the module function
21/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22
23/******/ // Flag the module as loaded
24/******/ module.l = true;
25
26/******/ // Return the exports of the module
27/******/ return module.exports;
28/******/ }
29
30
31/******/ // expose the modules object (__webpack_modules__)
32/******/ __webpack_require__.m = modules;
33
34/******/ // expose the module cache
35/******/ __webpack_require__.c = installedModules;
36
37/******/ // identity function for calling harmony imports with the correct context
38/******/ __webpack_require__.i = function(value) { return value; };
39
40/******/ // define getter function for harmony exports
41/******/ __webpack_require__.d = function(exports, name, getter) {
42/******/ if(!__webpack_require__.o(exports, name)) {
43/******/ Object.defineProperty(exports, name, {
44/******/ configurable: false,
45/******/ enumerable: true,
46/******/ get: getter
47/******/ });
48/******/ }
49/******/ };
50
51/******/ // getDefaultExport function for compatibility with non-harmony modules
52/******/ __webpack_require__.n = function(module) {
53/******/ var getter = module && module.__esModule ?
54/******/ function getDefault() { return module['default']; } :
55/******/ function getModuleExports() { return module; };
56/******/ __webpack_require__.d(getter, 'a', getter);
57/******/ return getter;
58/******/ };
59
60/******/ // Object.prototype.hasOwnProperty.call
61/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
62
63/******/ // __webpack_public_path__
64/******/ __webpack_require__.p = "";
65
66/******/ // Load entry module and return exports
67/******/ return __webpack_require__(__webpack_require__.s = 157);
68/******/ })
69/************************************************************************/
70/******/ ([
71/* 0 */
72/***/ (function(module, exports, __webpack_require__) {
73
74;(function (root, factory) {
75 if (true) {
76 // CommonJS
77 module.exports = exports = factory();
78 }
79 else if (typeof define === "function" && define.amd) {
80 // AMD
81 define([], factory);
82 }
83 else {
84 // Global (browser)
85 root.CryptoJS = factory();
86 }
87}(this, function () {
88
89 /**
90 * CryptoJS core components.
91 */
92 var CryptoJS = CryptoJS || (function (Math, undefined) {
93 /*
94 * Local polyfil of Object.create
95 */
96 var create = Object.create || (function () {
97 function F() {};
98
99 return function (obj) {
100 var subtype;
101
102 F.prototype = obj;
103
104 subtype = new F();
105
106 F.prototype = null;
107
108 return subtype;
109 };
110 }())
111
112 /**
113 * CryptoJS namespace.
114 */
115 var C = {};
116
117 /**
118 * Library namespace.
119 */
120 var C_lib = C.lib = {};
121
122 /**
123 * Base object for prototypal inheritance.
124 */
125 var Base = C_lib.Base = (function () {
126
127
128 return {
129 /**
130 * Creates a new object that inherits from this object.
131 *
132 * @param {Object} overrides Properties to copy into the new object.
133 *
134 * @return {Object} The new object.
135 *
136 * @static
137 *
138 * @example
139 *
140 * var MyType = CryptoJS.lib.Base.extend({
141 * field: 'value',
142 *
143 * method: function () {
144 * }
145 * });
146 */
147 extend: function (overrides) {
148 // Spawn
149 var subtype = create(this);
150
151 // Augment
152 if (overrides) {
153 subtype.mixIn(overrides);
154 }
155
156 // Create default initializer
157 if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {
158 subtype.init = function () {
159 subtype.$super.init.apply(this, arguments);
160 };
161 }
162
163 // Initializer's prototype is the subtype object
164 subtype.init.prototype = subtype;
165
166 // Reference supertype
167 subtype.$super = this;
168
169 return subtype;
170 },
171
172 /**
173 * Extends this object and runs the init method.
174 * Arguments to create() will be passed to init().
175 *
176 * @return {Object} The new object.
177 *
178 * @static
179 *
180 * @example
181 *
182 * var instance = MyType.create();
183 */
184 create: function () {
185 var instance = this.extend();
186 instance.init.apply(instance, arguments);
187
188 return instance;
189 },
190
191 /**
192 * Initializes a newly created object.
193 * Override this method to add some logic when your objects are created.
194 *
195 * @example
196 *
197 * var MyType = CryptoJS.lib.Base.extend({
198 * init: function () {
199 * // ...
200 * }
201 * });
202 */
203 init: function () {
204 },
205
206 /**
207 * Copies properties into this object.
208 *
209 * @param {Object} properties The properties to mix in.
210 *
211 * @example
212 *
213 * MyType.mixIn({
214 * field: 'value'
215 * });
216 */
217 mixIn: function (properties) {
218 for (var propertyName in properties) {
219 if (properties.hasOwnProperty(propertyName)) {
220 this[propertyName] = properties[propertyName];
221 }
222 }
223
224 // IE won't copy toString using the loop above
225 if (properties.hasOwnProperty('toString')) {
226 this.toString = properties.toString;
227 }
228 },
229
230 /**
231 * Creates a copy of this object.
232 *
233 * @return {Object} The clone.
234 *
235 * @example
236 *
237 * var clone = instance.clone();
238 */
239 clone: function () {
240 return this.init.prototype.extend(this);
241 }
242 };
243 }());
244
245 /**
246 * An array of 32-bit words.
247 *
248 * @property {Array} words The array of 32-bit words.
249 * @property {number} sigBytes The number of significant bytes in this word array.
250 */
251 var WordArray = C_lib.WordArray = Base.extend({
252 /**
253 * Initializes a newly created word array.
254 *
255 * @param {Array} words (Optional) An array of 32-bit words.
256 * @param {number} sigBytes (Optional) The number of significant bytes in the words.
257 *
258 * @example
259 *
260 * var wordArray = CryptoJS.lib.WordArray.create();
261 * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
262 * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
263 */
264 init: function (words, sigBytes) {
265 words = this.words = words || [];
266
267 if (sigBytes != undefined) {
268 this.sigBytes = sigBytes;
269 } else {
270 this.sigBytes = words.length * 4;
271 }
272 },
273
274 /**
275 * Converts this word array to a string.
276 *
277 * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
278 *
279 * @return {string} The stringified word array.
280 *
281 * @example
282 *
283 * var string = wordArray + '';
284 * var string = wordArray.toString();
285 * var string = wordArray.toString(CryptoJS.enc.Utf8);
286 */
287 toString: function (encoder) {
288 return (encoder || Hex).stringify(this);
289 },
290
291 /**
292 * Concatenates a word array to this word array.
293 *
294 * @param {WordArray} wordArray The word array to append.
295 *
296 * @return {WordArray} This word array.
297 *
298 * @example
299 *
300 * wordArray1.concat(wordArray2);
301 */
302 concat: function (wordArray) {
303 // Shortcuts
304 var thisWords = this.words;
305 var thatWords = wordArray.words;
306 var thisSigBytes = this.sigBytes;
307 var thatSigBytes = wordArray.sigBytes;
308
309 // Clamp excess bits
310 this.clamp();
311
312 // Concat
313 if (thisSigBytes % 4) {
314 // Copy one byte at a time
315 for (var i = 0; i < thatSigBytes; i++) {
316 var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
317 thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
318 }
319 } else {
320 // Copy one word at a time
321 for (var i = 0; i < thatSigBytes; i += 4) {
322 thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2];
323 }
324 }
325 this.sigBytes += thatSigBytes;
326
327 // Chainable
328 return this;
329 },
330
331 /**
332 * Removes insignificant bits.
333 *
334 * @example
335 *
336 * wordArray.clamp();
337 */
338 clamp: function () {
339 // Shortcuts
340 var words = this.words;
341 var sigBytes = this.sigBytes;
342
343 // Clamp
344 words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
345 words.length = Math.ceil(sigBytes / 4);
346 },
347
348 /**
349 * Creates a copy of this word array.
350 *
351 * @return {WordArray} The clone.
352 *
353 * @example
354 *
355 * var clone = wordArray.clone();
356 */
357 clone: function () {
358 var clone = Base.clone.call(this);
359 clone.words = this.words.slice(0);
360
361 return clone;
362 },
363
364 /**
365 * Creates a word array filled with random bytes.
366 *
367 * @param {number} nBytes The number of random bytes to generate.
368 *
369 * @return {WordArray} The random word array.
370 *
371 * @static
372 *
373 * @example
374 *
375 * var wordArray = CryptoJS.lib.WordArray.random(16);
376 */
377 random: function (nBytes) {
378 var words = [];
379
380 var r = (function (m_w) {
381 var m_w = m_w;
382 var m_z = 0x3ade68b1;
383 var mask = 0xffffffff;
384
385 return function () {
386 m_z = (0x9069 * (m_z & 0xFFFF) + (m_z >> 0x10)) & mask;
387 m_w = (0x4650 * (m_w & 0xFFFF) + (m_w >> 0x10)) & mask;
388 var result = ((m_z << 0x10) + m_w) & mask;
389 result /= 0x100000000;
390 result += 0.5;
391 return result * (Math.random() > .5 ? 1 : -1);
392 }
393 });
394
395 for (var i = 0, rcache; i < nBytes; i += 4) {
396 var _r = r((rcache || Math.random()) * 0x100000000);
397
398 rcache = _r() * 0x3ade67b7;
399 words.push((_r() * 0x100000000) | 0);
400 }
401
402 return new WordArray.init(words, nBytes);
403 }
404 });
405
406 /**
407 * Encoder namespace.
408 */
409 var C_enc = C.enc = {};
410
411 /**
412 * Hex encoding strategy.
413 */
414 var Hex = C_enc.Hex = {
415 /**
416 * Converts a word array to a hex string.
417 *
418 * @param {WordArray} wordArray The word array.
419 *
420 * @return {string} The hex string.
421 *
422 * @static
423 *
424 * @example
425 *
426 * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
427 */
428 stringify: function (wordArray) {
429 // Shortcuts
430 var words = wordArray.words;
431 var sigBytes = wordArray.sigBytes;
432
433 // Convert
434 var hexChars = [];
435 for (var i = 0; i < sigBytes; i++) {
436 var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
437 hexChars.push((bite >>> 4).toString(16));
438 hexChars.push((bite & 0x0f).toString(16));
439 }
440
441 return hexChars.join('');
442 },
443
444 /**
445 * Converts a hex string to a word array.
446 *
447 * @param {string} hexStr The hex string.
448 *
449 * @return {WordArray} The word array.
450 *
451 * @static
452 *
453 * @example
454 *
455 * var wordArray = CryptoJS.enc.Hex.parse(hexString);
456 */
457 parse: function (hexStr) {
458 // Shortcut
459 var hexStrLength = hexStr.length;
460
461 // Convert
462 var words = [];
463 for (var i = 0; i < hexStrLength; i += 2) {
464 words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
465 }
466
467 return new WordArray.init(words, hexStrLength / 2);
468 }
469 };
470
471 /**
472 * Latin1 encoding strategy.
473 */
474 var Latin1 = C_enc.Latin1 = {
475 /**
476 * Converts a word array to a Latin1 string.
477 *
478 * @param {WordArray} wordArray The word array.
479 *
480 * @return {string} The Latin1 string.
481 *
482 * @static
483 *
484 * @example
485 *
486 * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
487 */
488 stringify: function (wordArray) {
489 // Shortcuts
490 var words = wordArray.words;
491 var sigBytes = wordArray.sigBytes;
492
493 // Convert
494 var latin1Chars = [];
495 for (var i = 0; i < sigBytes; i++) {
496 var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
497 latin1Chars.push(String.fromCharCode(bite));
498 }
499
500 return latin1Chars.join('');
501 },
502
503 /**
504 * Converts a Latin1 string to a word array.
505 *
506 * @param {string} latin1Str The Latin1 string.
507 *
508 * @return {WordArray} The word array.
509 *
510 * @static
511 *
512 * @example
513 *
514 * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
515 */
516 parse: function (latin1Str) {
517 // Shortcut
518 var latin1StrLength = latin1Str.length;
519
520 // Convert
521 var words = [];
522 for (var i = 0; i < latin1StrLength; i++) {
523 words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
524 }
525
526 return new WordArray.init(words, latin1StrLength);
527 }
528 };
529
530 /**
531 * UTF-8 encoding strategy.
532 */
533 var Utf8 = C_enc.Utf8 = {
534 /**
535 * Converts a word array to a UTF-8 string.
536 *
537 * @param {WordArray} wordArray The word array.
538 *
539 * @return {string} The UTF-8 string.
540 *
541 * @static
542 *
543 * @example
544 *
545 * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
546 */
547 stringify: function (wordArray) {
548 try {
549 return decodeURIComponent(escape(Latin1.stringify(wordArray)));
550 } catch (e) {
551 throw new Error('Malformed UTF-8 data');
552 }
553 },
554
555 /**
556 * Converts a UTF-8 string to a word array.
557 *
558 * @param {string} utf8Str The UTF-8 string.
559 *
560 * @return {WordArray} The word array.
561 *
562 * @static
563 *
564 * @example
565 *
566 * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
567 */
568 parse: function (utf8Str) {
569 return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
570 }
571 };
572
573 /**
574 * Abstract buffered block algorithm template.
575 *
576 * The property blockSize must be implemented in a concrete subtype.
577 *
578 * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
579 */
580 var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
581 /**
582 * Resets this block algorithm's data buffer to its initial state.
583 *
584 * @example
585 *
586 * bufferedBlockAlgorithm.reset();
587 */
588 reset: function () {
589 // Initial values
590 this._data = new WordArray.init();
591 this._nDataBytes = 0;
592 },
593
594 /**
595 * Adds new data to this block algorithm's buffer.
596 *
597 * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
598 *
599 * @example
600 *
601 * bufferedBlockAlgorithm._append('data');
602 * bufferedBlockAlgorithm._append(wordArray);
603 */
604 _append: function (data) {
605 // Convert string to WordArray, else assume WordArray already
606 if (typeof data == 'string') {
607 data = Utf8.parse(data);
608 }
609
610 // Append
611 this._data.concat(data);
612 this._nDataBytes += data.sigBytes;
613 },
614
615 /**
616 * Processes available data blocks.
617 *
618 * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
619 *
620 * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
621 *
622 * @return {WordArray} The processed data.
623 *
624 * @example
625 *
626 * var processedData = bufferedBlockAlgorithm._process();
627 * var processedData = bufferedBlockAlgorithm._process(!!'flush');
628 */
629 _process: function (doFlush) {
630 // Shortcuts
631 var data = this._data;
632 var dataWords = data.words;
633 var dataSigBytes = data.sigBytes;
634 var blockSize = this.blockSize;
635 var blockSizeBytes = blockSize * 4;
636
637 // Count blocks ready
638 var nBlocksReady = dataSigBytes / blockSizeBytes;
639 if (doFlush) {
640 // Round up to include partial blocks
641 nBlocksReady = Math.ceil(nBlocksReady);
642 } else {
643 // Round down to include only full blocks,
644 // less the number of blocks that must remain in the buffer
645 nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
646 }
647
648 // Count words ready
649 var nWordsReady = nBlocksReady * blockSize;
650
651 // Count bytes ready
652 var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
653
654 // Process blocks
655 if (nWordsReady) {
656 for (var offset = 0; offset < nWordsReady; offset += blockSize) {
657 // Perform concrete-algorithm logic
658 this._doProcessBlock(dataWords, offset);
659 }
660
661 // Remove processed words
662 var processedWords = dataWords.splice(0, nWordsReady);
663 data.sigBytes -= nBytesReady;
664 }
665
666 // Return processed words
667 return new WordArray.init(processedWords, nBytesReady);
668 },
669
670 /**
671 * Creates a copy of this object.
672 *
673 * @return {Object} The clone.
674 *
675 * @example
676 *
677 * var clone = bufferedBlockAlgorithm.clone();
678 */
679 clone: function () {
680 var clone = Base.clone.call(this);
681 clone._data = this._data.clone();
682
683 return clone;
684 },
685
686 _minBufferSize: 0
687 });
688
689 /**
690 * Abstract hasher template.
691 *
692 * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
693 */
694 var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
695 /**
696 * Configuration options.
697 */
698 cfg: Base.extend(),
699
700 /**
701 * Initializes a newly created hasher.
702 *
703 * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
704 *
705 * @example
706 *
707 * var hasher = CryptoJS.algo.SHA256.create();
708 */
709 init: function (cfg) {
710 // Apply config defaults
711 this.cfg = this.cfg.extend(cfg);
712
713 // Set initial values
714 this.reset();
715 },
716
717 /**
718 * Resets this hasher to its initial state.
719 *
720 * @example
721 *
722 * hasher.reset();
723 */
724 reset: function () {
725 // Reset data buffer
726 BufferedBlockAlgorithm.reset.call(this);
727
728 // Perform concrete-hasher logic
729 this._doReset();
730 },
731
732 /**
733 * Updates this hasher with a message.
734 *
735 * @param {WordArray|string} messageUpdate The message to append.
736 *
737 * @return {Hasher} This hasher.
738 *
739 * @example
740 *
741 * hasher.update('message');
742 * hasher.update(wordArray);
743 */
744 update: function (messageUpdate) {
745 // Append
746 this._append(messageUpdate);
747
748 // Update the hash
749 this._process();
750
751 // Chainable
752 return this;
753 },
754
755 /**
756 * Finalizes the hash computation.
757 * Note that the finalize operation is effectively a destructive, read-once operation.
758 *
759 * @param {WordArray|string} messageUpdate (Optional) A final message update.
760 *
761 * @return {WordArray} The hash.
762 *
763 * @example
764 *
765 * var hash = hasher.finalize();
766 * var hash = hasher.finalize('message');
767 * var hash = hasher.finalize(wordArray);
768 */
769 finalize: function (messageUpdate) {
770 // Final message update
771 if (messageUpdate) {
772 this._append(messageUpdate);
773 }
774
775 // Perform concrete-hasher logic
776 var hash = this._doFinalize();
777
778 return hash;
779 },
780
781 blockSize: 512/32,
782
783 /**
784 * Creates a shortcut function to a hasher's object interface.
785 *
786 * @param {Hasher} hasher The hasher to create a helper for.
787 *
788 * @return {Function} The shortcut function.
789 *
790 * @static
791 *
792 * @example
793 *
794 * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
795 */
796 _createHelper: function (hasher) {
797 return function (message, cfg) {
798 return new hasher.init(cfg).finalize(message);
799 };
800 },
801
802 /**
803 * Creates a shortcut function to the HMAC's object interface.
804 *
805 * @param {Hasher} hasher The hasher to use in this HMAC helper.
806 *
807 * @return {Function} The shortcut function.
808 *
809 * @static
810 *
811 * @example
812 *
813 * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
814 */
815 _createHmacHelper: function (hasher) {
816 return function (message, key) {
817 return new C_algo.HMAC.init(hasher, key).finalize(message);
818 };
819 }
820 });
821
822 /**
823 * Algorithm namespace.
824 */
825 var C_algo = C.algo = {};
826
827 return C;
828 }(Math));
829
830
831 return CryptoJS;
832
833}));
834
835/***/ }),
836/* 1 */
837/***/ (function(module, exports, __webpack_require__) {
838
839;(function (root, factory) {
840 if (true) {
841 // CommonJS
842 module.exports = exports = factory(__webpack_require__(0));
843 }
844 else if (typeof define === "function" && define.amd) {
845 // AMD
846 define(["./core"], factory);
847 }
848 else {
849 // Global (browser)
850 factory(root.CryptoJS);
851 }
852}(this, function (CryptoJS) {
853
854 /**
855 * Cipher core components.
856 */
857 CryptoJS.lib.Cipher || (function (undefined) {
858 // Shortcuts
859 var C = CryptoJS;
860 var C_lib = C.lib;
861 var Base = C_lib.Base;
862 var WordArray = C_lib.WordArray;
863 var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
864 var C_enc = C.enc;
865 var Utf8 = C_enc.Utf8;
866 var Base64 = C_enc.Base64;
867 var C_algo = C.algo;
868 var EvpKDF = C_algo.EvpKDF;
869
870 /**
871 * Abstract base cipher template.
872 *
873 * @property {number} keySize This cipher's key size. Default: 4 (128 bits)
874 * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits)
875 * @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
876 * @property {number} _DEC_XFORM_MODE A constant representing decryption mode.
877 */
878 var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
879 /**
880 * Configuration options.
881 *
882 * @property {WordArray} iv The IV to use for this operation.
883 */
884 cfg: Base.extend(),
885
886 /**
887 * Creates this cipher in encryption mode.
888 *
889 * @param {WordArray} key The key.
890 * @param {Object} cfg (Optional) The configuration options to use for this operation.
891 *
892 * @return {Cipher} A cipher instance.
893 *
894 * @static
895 *
896 * @example
897 *
898 * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
899 */
900 createEncryptor: function (key, cfg) {
901 return this.create(this._ENC_XFORM_MODE, key, cfg);
902 },
903
904 /**
905 * Creates this cipher in decryption mode.
906 *
907 * @param {WordArray} key The key.
908 * @param {Object} cfg (Optional) The configuration options to use for this operation.
909 *
910 * @return {Cipher} A cipher instance.
911 *
912 * @static
913 *
914 * @example
915 *
916 * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
917 */
918 createDecryptor: function (key, cfg) {
919 return this.create(this._DEC_XFORM_MODE, key, cfg);
920 },
921
922 /**
923 * Initializes a newly created cipher.
924 *
925 * @param {number} xformMode Either the encryption or decryption transormation mode constant.
926 * @param {WordArray} key The key.
927 * @param {Object} cfg (Optional) The configuration options to use for this operation.
928 *
929 * @example
930 *
931 * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
932 */
933 init: function (xformMode, key, cfg) {
934 // Apply config defaults
935 this.cfg = this.cfg.extend(cfg);
936
937 // Store transform mode and key
938 this._xformMode = xformMode;
939 this._key = key;
940
941 // Set initial values
942 this.reset();
943 },
944
945 /**
946 * Resets this cipher to its initial state.
947 *
948 * @example
949 *
950 * cipher.reset();
951 */
952 reset: function () {
953 // Reset data buffer
954 BufferedBlockAlgorithm.reset.call(this);
955
956 // Perform concrete-cipher logic
957 this._doReset();
958 },
959
960 /**
961 * Adds data to be encrypted or decrypted.
962 *
963 * @param {WordArray|string} dataUpdate The data to encrypt or decrypt.
964 *
965 * @return {WordArray} The data after processing.
966 *
967 * @example
968 *
969 * var encrypted = cipher.process('data');
970 * var encrypted = cipher.process(wordArray);
971 */
972 process: function (dataUpdate) {
973 // Append
974 this._append(dataUpdate);
975
976 // Process available blocks
977 return this._process();
978 },
979
980 /**
981 * Finalizes the encryption or decryption process.
982 * Note that the finalize operation is effectively a destructive, read-once operation.
983 *
984 * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.
985 *
986 * @return {WordArray} The data after final processing.
987 *
988 * @example
989 *
990 * var encrypted = cipher.finalize();
991 * var encrypted = cipher.finalize('data');
992 * var encrypted = cipher.finalize(wordArray);
993 */
994 finalize: function (dataUpdate) {
995 // Final data update
996 if (dataUpdate) {
997 this._append(dataUpdate);
998 }
999
1000 // Perform concrete-cipher logic
1001 var finalProcessedData = this._doFinalize();
1002
1003 return finalProcessedData;
1004 },
1005
1006 keySize: 128/32,
1007
1008 ivSize: 128/32,
1009
1010 _ENC_XFORM_MODE: 1,
1011
1012 _DEC_XFORM_MODE: 2,
1013
1014 /**
1015 * Creates shortcut functions to a cipher's object interface.
1016 *
1017 * @param {Cipher} cipher The cipher to create a helper for.
1018 *
1019 * @return {Object} An object with encrypt and decrypt shortcut functions.
1020 *
1021 * @static
1022 *
1023 * @example
1024 *
1025 * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
1026 */
1027 _createHelper: (function () {
1028 function selectCipherStrategy(key) {
1029 if (typeof key == 'string') {
1030 return PasswordBasedCipher;
1031 } else {
1032 return SerializableCipher;
1033 }
1034 }
1035
1036 return function (cipher) {
1037 return {
1038 encrypt: function (message, key, cfg) {
1039 return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);
1040 },
1041
1042 decrypt: function (ciphertext, key, cfg) {
1043 return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);
1044 }
1045 };
1046 };
1047 }())
1048 });
1049
1050 /**
1051 * Abstract base stream cipher template.
1052 *
1053 * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits)
1054 */
1055 var StreamCipher = C_lib.StreamCipher = Cipher.extend({
1056 _doFinalize: function () {
1057 // Process partial blocks
1058 var finalProcessedBlocks = this._process(!!'flush');
1059
1060 return finalProcessedBlocks;
1061 },
1062
1063 blockSize: 1
1064 });
1065
1066 /**
1067 * Mode namespace.
1068 */
1069 var C_mode = C.mode = {};
1070
1071 /**
1072 * Abstract base block cipher mode template.
1073 */
1074 var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({
1075 /**
1076 * Creates this mode for encryption.
1077 *
1078 * @param {Cipher} cipher A block cipher instance.
1079 * @param {Array} iv The IV words.
1080 *
1081 * @static
1082 *
1083 * @example
1084 *
1085 * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
1086 */
1087 createEncryptor: function (cipher, iv) {
1088 return this.Encryptor.create(cipher, iv);
1089 },
1090
1091 /**
1092 * Creates this mode for decryption.
1093 *
1094 * @param {Cipher} cipher A block cipher instance.
1095 * @param {Array} iv The IV words.
1096 *
1097 * @static
1098 *
1099 * @example
1100 *
1101 * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
1102 */
1103 createDecryptor: function (cipher, iv) {
1104 return this.Decryptor.create(cipher, iv);
1105 },
1106
1107 /**
1108 * Initializes a newly created mode.
1109 *
1110 * @param {Cipher} cipher A block cipher instance.
1111 * @param {Array} iv The IV words.
1112 *
1113 * @example
1114 *
1115 * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);
1116 */
1117 init: function (cipher, iv) {
1118 this._cipher = cipher;
1119 this._iv = iv;
1120 }
1121 });
1122
1123 /**
1124 * Cipher Block Chaining mode.
1125 */
1126 var CBC = C_mode.CBC = (function () {
1127 /**
1128 * Abstract base CBC mode.
1129 */
1130 var CBC = BlockCipherMode.extend();
1131
1132 /**
1133 * CBC encryptor.
1134 */
1135 CBC.Encryptor = CBC.extend({
1136 /**
1137 * Processes the data block at offset.
1138 *
1139 * @param {Array} words The data words to operate on.
1140 * @param {number} offset The offset where the block starts.
1141 *
1142 * @example
1143 *
1144 * mode.processBlock(data.words, offset);
1145 */
1146 processBlock: function (words, offset) {
1147 // Shortcuts
1148 var cipher = this._cipher;
1149 var blockSize = cipher.blockSize;
1150
1151 // XOR and encrypt
1152 xorBlock.call(this, words, offset, blockSize);
1153 cipher.encryptBlock(words, offset);
1154
1155 // Remember this block to use with next block
1156 this._prevBlock = words.slice(offset, offset + blockSize);
1157 }
1158 });
1159
1160 /**
1161 * CBC decryptor.
1162 */
1163 CBC.Decryptor = CBC.extend({
1164 /**
1165 * Processes the data block at offset.
1166 *
1167 * @param {Array} words The data words to operate on.
1168 * @param {number} offset The offset where the block starts.
1169 *
1170 * @example
1171 *
1172 * mode.processBlock(data.words, offset);
1173 */
1174 processBlock: function (words, offset) {
1175 // Shortcuts
1176 var cipher = this._cipher;
1177 var blockSize = cipher.blockSize;
1178
1179 // Remember this block to use with next block
1180 var thisBlock = words.slice(offset, offset + blockSize);
1181
1182 // Decrypt and XOR
1183 cipher.decryptBlock(words, offset);
1184 xorBlock.call(this, words, offset, blockSize);
1185
1186 // This block becomes the previous block
1187 this._prevBlock = thisBlock;
1188 }
1189 });
1190
1191 function xorBlock(words, offset, blockSize) {
1192 // Shortcut
1193 var iv = this._iv;
1194
1195 // Choose mixing block
1196 if (iv) {
1197 var block = iv;
1198
1199 // Remove IV for subsequent blocks
1200 this._iv = undefined;
1201 } else {
1202 var block = this._prevBlock;
1203 }
1204
1205 // XOR blocks
1206 for (var i = 0; i < blockSize; i++) {
1207 words[offset + i] ^= block[i];
1208 }
1209 }
1210
1211 return CBC;
1212 }());
1213
1214 /**
1215 * Padding namespace.
1216 */
1217 var C_pad = C.pad = {};
1218
1219 /**
1220 * PKCS #5/7 padding strategy.
1221 */
1222 var Pkcs7 = C_pad.Pkcs7 = {
1223 /**
1224 * Pads data using the algorithm defined in PKCS #5/7.
1225 *
1226 * @param {WordArray} data The data to pad.
1227 * @param {number} blockSize The multiple that the data should be padded to.
1228 *
1229 * @static
1230 *
1231 * @example
1232 *
1233 * CryptoJS.pad.Pkcs7.pad(wordArray, 4);
1234 */
1235 pad: function (data, blockSize) {
1236 // Shortcut
1237 var blockSizeBytes = blockSize * 4;
1238
1239 // Count padding bytes
1240 var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
1241
1242 // Create padding word
1243 var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes;
1244
1245 // Create padding
1246 var paddingWords = [];
1247 for (var i = 0; i < nPaddingBytes; i += 4) {
1248 paddingWords.push(paddingWord);
1249 }
1250 var padding = WordArray.create(paddingWords, nPaddingBytes);
1251
1252 // Add padding
1253 data.concat(padding);
1254 },
1255
1256 /**
1257 * Unpads data that had been padded using the algorithm defined in PKCS #5/7.
1258 *
1259 * @param {WordArray} data The data to unpad.
1260 *
1261 * @static
1262 *
1263 * @example
1264 *
1265 * CryptoJS.pad.Pkcs7.unpad(wordArray);
1266 */
1267 unpad: function (data) {
1268 // Get number of padding bytes from last byte
1269 var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
1270
1271 // Remove padding
1272 data.sigBytes -= nPaddingBytes;
1273 }
1274 };
1275
1276 /**
1277 * Abstract base block cipher template.
1278 *
1279 * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits)
1280 */
1281 var BlockCipher = C_lib.BlockCipher = Cipher.extend({
1282 /**
1283 * Configuration options.
1284 *
1285 * @property {Mode} mode The block mode to use. Default: CBC
1286 * @property {Padding} padding The padding strategy to use. Default: Pkcs7
1287 */
1288 cfg: Cipher.cfg.extend({
1289 mode: CBC,
1290 padding: Pkcs7
1291 }),
1292
1293 reset: function () {
1294 // Reset cipher
1295 Cipher.reset.call(this);
1296
1297 // Shortcuts
1298 var cfg = this.cfg;
1299 var iv = cfg.iv;
1300 var mode = cfg.mode;
1301
1302 // Reset block mode
1303 if (this._xformMode == this._ENC_XFORM_MODE) {
1304 var modeCreator = mode.createEncryptor;
1305 } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
1306 var modeCreator = mode.createDecryptor;
1307
1308 // Keep at least one block in the buffer for unpadding
1309 this._minBufferSize = 1;
1310 }
1311 this._mode = modeCreator.call(mode, this, iv && iv.words);
1312 },
1313
1314 _doProcessBlock: function (words, offset) {
1315 this._mode.processBlock(words, offset);
1316 },
1317
1318 _doFinalize: function () {
1319 // Shortcut
1320 var padding = this.cfg.padding;
1321
1322 // Finalize
1323 if (this._xformMode == this._ENC_XFORM_MODE) {
1324 // Pad data
1325 padding.pad(this._data, this.blockSize);
1326
1327 // Process final blocks
1328 var finalProcessedBlocks = this._process(!!'flush');
1329 } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
1330 // Process final blocks
1331 var finalProcessedBlocks = this._process(!!'flush');
1332
1333 // Unpad data
1334 padding.unpad(finalProcessedBlocks);
1335 }
1336
1337 return finalProcessedBlocks;
1338 },
1339
1340 blockSize: 128/32
1341 });
1342
1343 /**
1344 * A collection of cipher parameters.
1345 *
1346 * @property {WordArray} ciphertext The raw ciphertext.
1347 * @property {WordArray} key The key to this ciphertext.
1348 * @property {WordArray} iv The IV used in the ciphering operation.
1349 * @property {WordArray} salt The salt used with a key derivation function.
1350 * @property {Cipher} algorithm The cipher algorithm.
1351 * @property {Mode} mode The block mode used in the ciphering operation.
1352 * @property {Padding} padding The padding scheme used in the ciphering operation.
1353 * @property {number} blockSize The block size of the cipher.
1354 * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string.
1355 */
1356 var CipherParams = C_lib.CipherParams = Base.extend({
1357 /**
1358 * Initializes a newly created cipher params object.
1359 *
1360 * @param {Object} cipherParams An object with any of the possible cipher parameters.
1361 *
1362 * @example
1363 *
1364 * var cipherParams = CryptoJS.lib.CipherParams.create({
1365 * ciphertext: ciphertextWordArray,
1366 * key: keyWordArray,
1367 * iv: ivWordArray,
1368 * salt: saltWordArray,
1369 * algorithm: CryptoJS.algo.AES,
1370 * mode: CryptoJS.mode.CBC,
1371 * padding: CryptoJS.pad.PKCS7,
1372 * blockSize: 4,
1373 * formatter: CryptoJS.format.OpenSSL
1374 * });
1375 */
1376 init: function (cipherParams) {
1377 this.mixIn(cipherParams);
1378 },
1379
1380 /**
1381 * Converts this cipher params object to a string.
1382 *
1383 * @param {Format} formatter (Optional) The formatting strategy to use.
1384 *
1385 * @return {string} The stringified cipher params.
1386 *
1387 * @throws Error If neither the formatter nor the default formatter is set.
1388 *
1389 * @example
1390 *
1391 * var string = cipherParams + '';
1392 * var string = cipherParams.toString();
1393 * var string = cipherParams.toString(CryptoJS.format.OpenSSL);
1394 */
1395 toString: function (formatter) {
1396 return (formatter || this.formatter).stringify(this);
1397 }
1398 });
1399
1400 /**
1401 * Format namespace.
1402 */
1403 var C_format = C.format = {};
1404
1405 /**
1406 * OpenSSL formatting strategy.
1407 */
1408 var OpenSSLFormatter = C_format.OpenSSL = {
1409 /**
1410 * Converts a cipher params object to an OpenSSL-compatible string.
1411 *
1412 * @param {CipherParams} cipherParams The cipher params object.
1413 *
1414 * @return {string} The OpenSSL-compatible string.
1415 *
1416 * @static
1417 *
1418 * @example
1419 *
1420 * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
1421 */
1422 stringify: function (cipherParams) {
1423 // Shortcuts
1424 var ciphertext = cipherParams.ciphertext;
1425 var salt = cipherParams.salt;
1426
1427 // Format
1428 if (salt) {
1429 var wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
1430 } else {
1431 var wordArray = ciphertext;
1432 }
1433
1434 return wordArray.toString(Base64);
1435 },
1436
1437 /**
1438 * Converts an OpenSSL-compatible string to a cipher params object.
1439 *
1440 * @param {string} openSSLStr The OpenSSL-compatible string.
1441 *
1442 * @return {CipherParams} The cipher params object.
1443 *
1444 * @static
1445 *
1446 * @example
1447 *
1448 * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
1449 */
1450 parse: function (openSSLStr) {
1451 // Parse base64
1452 var ciphertext = Base64.parse(openSSLStr);
1453
1454 // Shortcut
1455 var ciphertextWords = ciphertext.words;
1456
1457 // Test for salt
1458 if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) {
1459 // Extract salt
1460 var salt = WordArray.create(ciphertextWords.slice(2, 4));
1461
1462 // Remove salt from ciphertext
1463 ciphertextWords.splice(0, 4);
1464 ciphertext.sigBytes -= 16;
1465 }
1466
1467 return CipherParams.create({ ciphertext: ciphertext, salt: salt });
1468 }
1469 };
1470
1471 /**
1472 * A cipher wrapper that returns ciphertext as a serializable cipher params object.
1473 */
1474 var SerializableCipher = C_lib.SerializableCipher = Base.extend({
1475 /**
1476 * Configuration options.
1477 *
1478 * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL
1479 */
1480 cfg: Base.extend({
1481 format: OpenSSLFormatter
1482 }),
1483
1484 /**
1485 * Encrypts a message.
1486 *
1487 * @param {Cipher} cipher The cipher algorithm to use.
1488 * @param {WordArray|string} message The message to encrypt.
1489 * @param {WordArray} key The key.
1490 * @param {Object} cfg (Optional) The configuration options to use for this operation.
1491 *
1492 * @return {CipherParams} A cipher params object.
1493 *
1494 * @static
1495 *
1496 * @example
1497 *
1498 * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
1499 * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
1500 * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });
1501 */
1502 encrypt: function (cipher, message, key, cfg) {
1503 // Apply config defaults
1504 cfg = this.cfg.extend(cfg);
1505
1506 // Encrypt
1507 var encryptor = cipher.createEncryptor(key, cfg);
1508 var ciphertext = encryptor.finalize(message);
1509
1510 // Shortcut
1511 var cipherCfg = encryptor.cfg;
1512
1513 // Create and return serializable cipher params
1514 return CipherParams.create({
1515 ciphertext: ciphertext,
1516 key: key,
1517 iv: cipherCfg.iv,
1518 algorithm: cipher,
1519 mode: cipherCfg.mode,
1520 padding: cipherCfg.padding,
1521 blockSize: cipher.blockSize,
1522 formatter: cfg.format
1523 });
1524 },
1525
1526 /**
1527 * Decrypts serialized ciphertext.
1528 *
1529 * @param {Cipher} cipher The cipher algorithm to use.
1530 * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
1531 * @param {WordArray} key The key.
1532 * @param {Object} cfg (Optional) The configuration options to use for this operation.
1533 *
1534 * @return {WordArray} The plaintext.
1535 *
1536 * @static
1537 *
1538 * @example
1539 *
1540 * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });
1541 * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });
1542 */
1543 decrypt: function (cipher, ciphertext, key, cfg) {
1544 // Apply config defaults
1545 cfg = this.cfg.extend(cfg);
1546
1547 // Convert string to CipherParams
1548 ciphertext = this._parse(ciphertext, cfg.format);
1549
1550 // Decrypt
1551 var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext);
1552
1553 return plaintext;
1554 },
1555
1556 /**
1557 * Converts serialized ciphertext to CipherParams,
1558 * else assumed CipherParams already and returns ciphertext unchanged.
1559 *
1560 * @param {CipherParams|string} ciphertext The ciphertext.
1561 * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext.
1562 *
1563 * @return {CipherParams} The unserialized ciphertext.
1564 *
1565 * @static
1566 *
1567 * @example
1568 *
1569 * var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
1570 */
1571 _parse: function (ciphertext, format) {
1572 if (typeof ciphertext == 'string') {
1573 return format.parse(ciphertext, this);
1574 } else {
1575 return ciphertext;
1576 }
1577 }
1578 });
1579
1580 /**
1581 * Key derivation function namespace.
1582 */
1583 var C_kdf = C.kdf = {};
1584
1585 /**
1586 * OpenSSL key derivation function.
1587 */
1588 var OpenSSLKdf = C_kdf.OpenSSL = {
1589 /**
1590 * Derives a key and IV from a password.
1591 *
1592 * @param {string} password The password to derive from.
1593 * @param {number} keySize The size in words of the key to generate.
1594 * @param {number} ivSize The size in words of the IV to generate.
1595 * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly.
1596 *
1597 * @return {CipherParams} A cipher params object with the key, IV, and salt.
1598 *
1599 * @static
1600 *
1601 * @example
1602 *
1603 * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32);
1604 * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt');
1605 */
1606 execute: function (password, keySize, ivSize, salt) {
1607 // Generate random salt
1608 if (!salt) {
1609 salt = WordArray.random(64/8);
1610 }
1611
1612 // Derive key and IV
1613 var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt);
1614
1615 // Separate key and IV
1616 var iv = WordArray.create(key.words.slice(keySize), ivSize * 4);
1617 key.sigBytes = keySize * 4;
1618
1619 // Return params
1620 return CipherParams.create({ key: key, iv: iv, salt: salt });
1621 }
1622 };
1623
1624 /**
1625 * A serializable cipher wrapper that derives the key from a password,
1626 * and returns ciphertext as a serializable cipher params object.
1627 */
1628 var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({
1629 /**
1630 * Configuration options.
1631 *
1632 * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL
1633 */
1634 cfg: SerializableCipher.cfg.extend({
1635 kdf: OpenSSLKdf
1636 }),
1637
1638 /**
1639 * Encrypts a message using a password.
1640 *
1641 * @param {Cipher} cipher The cipher algorithm to use.
1642 * @param {WordArray|string} message The message to encrypt.
1643 * @param {string} password The password.
1644 * @param {Object} cfg (Optional) The configuration options to use for this operation.
1645 *
1646 * @return {CipherParams} A cipher params object.
1647 *
1648 * @static
1649 *
1650 * @example
1651 *
1652 * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');
1653 * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });
1654 */
1655 encrypt: function (cipher, message, password, cfg) {
1656 // Apply config defaults
1657 cfg = this.cfg.extend(cfg);
1658
1659 // Derive key and other params
1660 var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize);
1661
1662 // Add IV to config
1663 cfg.iv = derivedParams.iv;
1664
1665 // Encrypt
1666 var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg);
1667
1668 // Mix in derived params
1669 ciphertext.mixIn(derivedParams);
1670
1671 return ciphertext;
1672 },
1673
1674 /**
1675 * Decrypts serialized ciphertext using a password.
1676 *
1677 * @param {Cipher} cipher The cipher algorithm to use.
1678 * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
1679 * @param {string} password The password.
1680 * @param {Object} cfg (Optional) The configuration options to use for this operation.
1681 *
1682 * @return {WordArray} The plaintext.
1683 *
1684 * @static
1685 *
1686 * @example
1687 *
1688 * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });
1689 * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });
1690 */
1691 decrypt: function (cipher, ciphertext, password, cfg) {
1692 // Apply config defaults
1693 cfg = this.cfg.extend(cfg);
1694
1695 // Convert string to CipherParams
1696 ciphertext = this._parse(ciphertext, cfg.format);
1697
1698 // Derive key and other params
1699 var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt);
1700
1701 // Add IV to config
1702 cfg.iv = derivedParams.iv;
1703
1704 // Decrypt
1705 var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg);
1706
1707 return plaintext;
1708 }
1709 });
1710 }());
1711
1712
1713}));
1714
1715/***/ }),
1716/* 2 */
1717/***/ (function(module, exports, __webpack_require__) {
1718
1719/*
1720 This file is part of web3.js.
1721
1722 web3.js is free software: you can redistribute it and/or modify
1723 it under the terms of the GNU Lesser General Public License as published by
1724 the Free Software Foundation, either version 3 of the License, or
1725 (at your option) any later version.
1726
1727 web3.js is distributed in the hope that it will be useful,
1728 but WITHOUT ANY WARRANTY; without even the implied warranty of
1729 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1730 GNU Lesser General Public License for more details.
1731
1732 You should have received a copy of the GNU Lesser General Public License
1733 along with web3.js. If not, see <http://www.gnu.org/licenses/>.
1734*/
1735/**
1736 * @file utils.js
1737 * @author Marek Kotewicz <marek@ethdev.com>
1738 * @date 2015
1739 */
1740
1741/**
1742 * Utils
1743 *
1744 * @module utils
1745 */
1746
1747/**
1748 * Utility functions
1749 *
1750 * @class [utils] utils
1751 * @constructor
1752 */
1753
1754
1755var BigNumber = __webpack_require__(18);
1756var sha3 = __webpack_require__(19);
1757var utf8 = __webpack_require__(124);
1758
1759var unitMap = {
1760 'noether': '0',
1761 'wei': '1',
1762 'kwei': '1000',
1763 'Kwei': '1000',
1764 'babbage': '1000',
1765 'femtoether': '1000',
1766 'mwei': '1000000',
1767 'Mwei': '1000000',
1768 'lovelace': '1000000',
1769 'picoether': '1000000',
1770 'gwei': '1000000000',
1771 'Gwei': '1000000000',
1772 'shannon': '1000000000',
1773 'nanoether': '1000000000',
1774 'nano': '1000000000',
1775 'szabo': '1000000000000',
1776 'microether': '1000000000000',
1777 'micro': '1000000000000',
1778 'finney': '1000000000000000',
1779 'milliether': '1000000000000000',
1780 'milli': '1000000000000000',
1781 'ether': '1000000000000000000',
1782 'kether': '1000000000000000000000',
1783 'grand': '1000000000000000000000',
1784 'mether': '1000000000000000000000000',
1785 'gether': '1000000000000000000000000000',
1786 'tether': '1000000000000000000000000000000'
1787};
1788
1789/**
1790 * Should be called to pad string to expected length
1791 *
1792 * @method padLeft
1793 * @param {String} string to be padded
1794 * @param {Number} characters that result string should have
1795 * @param {String} sign, by default 0
1796 * @returns {String} right aligned string
1797 */
1798var padLeft = function (string, chars, sign) {
1799 return new Array(chars - string.length + 1).join(sign ? sign : "0") + string;
1800};
1801
1802/**
1803 * Should be called to pad string to expected length
1804 *
1805 * @method padRight
1806 * @param {String} string to be padded
1807 * @param {Number} characters that result string should have
1808 * @param {String} sign, by default 0
1809 * @returns {String} right aligned string
1810 */
1811var padRight = function (string, chars, sign) {
1812 return string + (new Array(chars - string.length + 1).join(sign ? sign : "0"));
1813};
1814
1815/**
1816 * Should be called to get utf8 from it's hex representation
1817 *
1818 * @method toUtf8
1819 * @param {String} string in hex
1820 * @returns {String} ascii string representation of hex value
1821 */
1822var toUtf8 = function(hex) {
1823// Find termination
1824 var str = "";
1825 var i = 0, l = hex.length;
1826 if (hex.substring(0, 2) === '0x') {
1827 i = 2;
1828 }
1829 for (; i < l; i+=2) {
1830 var code = parseInt(hex.substr(i, 2), 16);
1831 if (code === 0)
1832 break;
1833 str += String.fromCharCode(code);
1834 }
1835
1836 return utf8.decode(str);
1837};
1838
1839/**
1840 * Should be called to get ascii from it's hex representation
1841 *
1842 * @method toAscii
1843 * @param {String} string in hex
1844 * @returns {String} ascii string representation of hex value
1845 */
1846var toAscii = function(hex) {
1847// Find termination
1848 var str = "";
1849 var i = 0, l = hex.length;
1850 if (hex.substring(0, 2) === '0x') {
1851 i = 2;
1852 }
1853 for (; i < l; i+=2) {
1854 var code = parseInt(hex.substr(i, 2), 16);
1855 str += String.fromCharCode(code);
1856 }
1857
1858 return str;
1859};
1860
1861/**
1862 * Should be called to get hex representation (prefixed by 0x) of utf8 string
1863 *
1864 * @method fromUtf8
1865 * @param {String} string
1866 * @param {Number} optional padding
1867 * @returns {String} hex representation of input string
1868 */
1869var fromUtf8 = function(str) {
1870 str = utf8.encode(str);
1871 var hex = "";
1872 for(var i = 0; i < str.length; i++) {
1873 var code = str.charCodeAt(i);
1874 if (code === 0)
1875 break;
1876 var n = code.toString(16);
1877 hex += n.length < 2 ? '0' + n : n;
1878 }
1879
1880 return "0x" + hex;
1881};
1882
1883/**
1884 * Should be called to get hex representation (prefixed by 0x) of ascii string
1885 *
1886 * @method fromAscii
1887 * @param {String} string
1888 * @param {Number} optional padding
1889 * @returns {String} hex representation of input string
1890 */
1891var fromAscii = function(str) {
1892 var hex = "";
1893 for(var i = 0; i < str.length; i++) {
1894 var code = str.charCodeAt(i);
1895 var n = code.toString(16);
1896 hex += n.length < 2 ? '0' + n : n;
1897 }
1898
1899 return "0x" + hex;
1900};
1901
1902/**
1903 * Should be used to create full function/event name from json abi
1904 *
1905 * @method transformToFullName
1906 * @param {Object} json-abi
1907 * @return {String} full fnction/event name
1908 */
1909var transformToFullName = function (json) {
1910 if (json.name.indexOf('(') !== -1) {
1911 return json.name;
1912 }
1913
1914 var typeName = json.inputs.map(function(i){return i.type; }).join();
1915 return json.name + '(' + typeName + ')';
1916};
1917
1918/**
1919 * Should be called to get display name of contract function
1920 *
1921 * @method extractDisplayName
1922 * @param {String} name of function/event
1923 * @returns {String} display name for function/event eg. multiply(uint256) -> multiply
1924 */
1925var extractDisplayName = function (name) {
1926 var length = name.indexOf('(');
1927 return length !== -1 ? name.substr(0, length) : name;
1928};
1929
1930/// @returns overloaded part of function/event name
1931var extractTypeName = function (name) {
1932 /// TODO: make it invulnerable
1933 var length = name.indexOf('(');
1934 return length !== -1 ? name.substr(length + 1, name.length - 1 - (length + 1)).replace(' ', '') : "";
1935};
1936
1937/**
1938 * Converts value to it's decimal representation in string
1939 *
1940 * @method toDecimal
1941 * @param {String|Number|BigNumber}
1942 * @return {String}
1943 */
1944var toDecimal = function (value) {
1945 return toBigNumber(value).toNumber();
1946};
1947
1948/**
1949 * Converts value to it's hex representation
1950 *
1951 * @method fromDecimal
1952 * @param {String|Number|BigNumber}
1953 * @return {String}
1954 */
1955var fromDecimal = function (value) {
1956 var number = toBigNumber(value);
1957 var result = number.toString(16);
1958
1959 return number.lessThan(0) ? '-0x' + result.substr(1) : '0x' + result;
1960};
1961
1962/**
1963 * Auto converts any given value into it's hex representation.
1964 *
1965 * And even stringifys objects before.
1966 *
1967 * @method toHex
1968 * @param {String|Number|BigNumber|Object}
1969 * @return {String}
1970 */
1971var toHex = function (val) {
1972 /*jshint maxcomplexity: 8 */
1973
1974 if (isBoolean(val))
1975 return fromDecimal(+val);
1976
1977 if (isBigNumber(val))
1978 return fromDecimal(val);
1979
1980 if (isObject(val))
1981 return fromUtf8(JSON.stringify(val));
1982
1983 // if its a negative number, pass it through fromDecimal
1984 if (isString(val)) {
1985 if (val.indexOf('-0x') === 0)
1986 return fromDecimal(val);
1987 else if(val.indexOf('0x') === 0)
1988 return val;
1989 else if (!isFinite(val))
1990 return fromAscii(val);
1991 }
1992
1993 return fromDecimal(val);
1994};
1995
1996/**
1997 * Returns value of unit in Wei
1998 *
1999 * @method getValueOfUnit
2000 * @param {String} unit the unit to convert to, default ether
2001 * @returns {BigNumber} value of the unit (in Wei)
2002 * @throws error if the unit is not correct:w
2003 */
2004var getValueOfUnit = function (unit) {
2005 unit = unit ? unit.toLowerCase() : 'ether';
2006 var unitValue = unitMap[unit];
2007 if (unitValue === undefined) {
2008 throw new Error('This unit doesn\'t exists, please use the one of the following units' + JSON.stringify(unitMap, null, 2));
2009 }
2010 return new BigNumber(unitValue, 10);
2011};
2012
2013/**
2014 * Takes a number of wei and converts it to any other ether unit.
2015 *
2016 * Possible units are:
2017 * SI Short SI Full Effigy Other
2018 * - kwei femtoether babbage
2019 * - mwei picoether lovelace
2020 * - gwei nanoether shannon nano
2021 * - -- microether szabo micro
2022 * - -- milliether finney milli
2023 * - ether -- --
2024 * - kether -- grand
2025 * - mether
2026 * - gether
2027 * - tether
2028 *
2029 * @method fromWei
2030 * @param {Number|String} number can be a number, number string or a HEX of a decimal
2031 * @param {String} unit the unit to convert to, default ether
2032 * @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number
2033*/
2034var fromWei = function(number, unit) {
2035 var returnValue = toBigNumber(number).dividedBy(getValueOfUnit(unit));
2036
2037 return isBigNumber(number) ? returnValue : returnValue.toString(10);
2038};
2039
2040/**
2041 * Takes a number of a unit and converts it to wei.
2042 *
2043 * Possible units are:
2044 * SI Short SI Full Effigy Other
2045 * - kwei femtoether babbage
2046 * - mwei picoether lovelace
2047 * - gwei nanoether shannon nano
2048 * - -- microether szabo micro
2049 * - -- microether szabo micro
2050 * - -- milliether finney milli
2051 * - ether -- --
2052 * - kether -- grand
2053 * - mether
2054 * - gether
2055 * - tether
2056 *
2057 * @method toWei
2058 * @param {Number|String|BigNumber} number can be a number, number string or a HEX of a decimal
2059 * @param {String} unit the unit to convert from, default ether
2060 * @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number
2061*/
2062var toWei = function(number, unit) {
2063 var returnValue = toBigNumber(number).times(getValueOfUnit(unit));
2064
2065 return isBigNumber(number) ? returnValue : returnValue.toString(10);
2066};
2067
2068/**
2069 * Takes an input and transforms it into an bignumber
2070 *
2071 * @method toBigNumber
2072 * @param {Number|String|BigNumber} a number, string, HEX string or BigNumber
2073 * @return {BigNumber} BigNumber
2074*/
2075var toBigNumber = function(number) {
2076 /*jshint maxcomplexity:5 */
2077 number = number || 0;
2078 if (isBigNumber(number))
2079 return number;
2080
2081 if (isString(number) && (number.indexOf('0x') === 0 || number.indexOf('-0x') === 0)) {
2082 return new BigNumber(number.replace('0x',''), 16);
2083 }
2084
2085 return new BigNumber(number.toString(10), 10);
2086};
2087
2088/**
2089 * Takes and input transforms it into bignumber and if it is negative value, into two's complement
2090 *
2091 * @method toTwosComplement
2092 * @param {Number|String|BigNumber}
2093 * @return {BigNumber}
2094 */
2095var toTwosComplement = function (number) {
2096 var bigNumber = toBigNumber(number).round();
2097 if (bigNumber.lessThan(0)) {
2098 return new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16).plus(bigNumber).plus(1);
2099 }
2100 return bigNumber;
2101};
2102
2103/**
2104 * Checks if the given string is strictly an address
2105 *
2106 * @method isStrictAddress
2107 * @param {String} address the given HEX adress
2108 * @return {Boolean}
2109*/
2110var isStrictAddress = function (address) {
2111 return /^0x[0-9a-f]{40}$/i.test(address);
2112};
2113
2114/**
2115 * Checks if the given string is an address
2116 *
2117 * @method isAddress
2118 * @param {String} address the given HEX adress
2119 * @return {Boolean}
2120*/
2121var isAddress = function (address) {
2122 if (!/^(0x)?[0-9a-f]{40}$/i.test(address)) {
2123 // check if it has the basic requirements of an address
2124 return false;
2125 } else if (/^(0x)?[0-9a-f]{40}$/.test(address) || /^(0x)?[0-9A-F]{40}$/.test(address)) {
2126 // If it's all small caps or all all caps, return true
2127 return true;
2128 } else {
2129 // Otherwise check each case
2130 return isChecksumAddress(address);
2131 }
2132};
2133
2134
2135
2136/**
2137 * Checks if the given string is a checksummed address
2138 *
2139 * @method isChecksumAddress
2140 * @param {String} address the given HEX adress
2141 * @return {Boolean}
2142*/
2143var isChecksumAddress = function (address) {
2144 // Check each case
2145 address = address.replace('0x','');
2146 var addressHash = sha3(address.toLowerCase());
2147
2148 for (var i = 0; i < 40; i++ ) {
2149 // the nth letter should be uppercase if the nth digit of casemap is 1
2150 if ((parseInt(addressHash[i], 16) > 7 && address[i].toUpperCase() !== address[i]) || (parseInt(addressHash[i], 16) <= 7 && address[i].toLowerCase() !== address[i])) {
2151 return false;
2152 }
2153 }
2154 return true;
2155};
2156
2157
2158
2159/**
2160 * Makes a checksum address
2161 *
2162 * @method toChecksumAddress
2163 * @param {String} address the given HEX adress
2164 * @return {String}
2165*/
2166var toChecksumAddress = function (address) {
2167 if (typeof address === 'undefined') return '';
2168
2169 address = address.toLowerCase().replace('0x','');
2170 var addressHash = sha3(address);
2171 var checksumAddress = '0x';
2172
2173 for (var i = 0; i < address.length; i++ ) {
2174 // If ith character is 9 to f then make it uppercase
2175 if (parseInt(addressHash[i], 16) > 7) {
2176 checksumAddress += address[i].toUpperCase();
2177 } else {
2178 checksumAddress += address[i];
2179 }
2180 }
2181 return checksumAddress;
2182};
2183
2184/**
2185 * Transforms given string to valid 20 bytes-length addres with 0x prefix
2186 *
2187 * @method toAddress
2188 * @param {String} address
2189 * @return {String} formatted address
2190 */
2191var toAddress = function (address) {
2192 if (isStrictAddress(address)) {
2193 return address;
2194 }
2195
2196 if (/^[0-9a-f]{40}$/.test(address)) {
2197 return '0x' + address;
2198 }
2199
2200 return '0x' + padLeft(toHex(address).substr(2), 40);
2201};
2202
2203/**
2204 * Returns true if object is BigNumber, otherwise false
2205 *
2206 * @method isBigNumber
2207 * @param {Object}
2208 * @return {Boolean}
2209 */
2210var isBigNumber = function (object) {
2211 return object instanceof BigNumber ||
2212 (object && object.constructor && object.constructor.name === 'BigNumber');
2213};
2214
2215/**
2216 * Returns true if object is string, otherwise false
2217 *
2218 * @method isString
2219 * @param {Object}
2220 * @return {Boolean}
2221 */
2222var isString = function (object) {
2223 return typeof object === 'string' ||
2224 (object && object.constructor && object.constructor.name === 'String');
2225};
2226
2227/**
2228 * Returns true if object is function, otherwise false
2229 *
2230 * @method isFunction
2231 * @param {Object}
2232 * @return {Boolean}
2233 */
2234var isFunction = function (object) {
2235 return typeof object === 'function';
2236};
2237
2238/**
2239 * Returns true if object is Objet, otherwise false
2240 *
2241 * @method isObject
2242 * @param {Object}
2243 * @return {Boolean}
2244 */
2245var isObject = function (object) {
2246 return typeof object === 'object';
2247};
2248
2249/**
2250 * Returns true if object is boolean, otherwise false
2251 *
2252 * @method isBoolean
2253 * @param {Object}
2254 * @return {Boolean}
2255 */
2256var isBoolean = function (object) {
2257 return typeof object === 'boolean';
2258};
2259
2260/**
2261 * Returns true if object is array, otherwise false
2262 *
2263 * @method isArray
2264 * @param {Object}
2265 * @return {Boolean}
2266 */
2267var isArray = function (object) {
2268 return object instanceof Array;
2269};
2270
2271/**
2272 * Returns true if given string is valid json object
2273 *
2274 * @method isJson
2275 * @param {String}
2276 * @return {Boolean}
2277 */
2278var isJson = function (str) {
2279 try {
2280 return !!JSON.parse(str);
2281 } catch (e) {
2282 return false;
2283 }
2284};
2285
2286module.exports = {
2287 padLeft: padLeft,
2288 padRight: padRight,
2289 toHex: toHex,
2290 toDecimal: toDecimal,
2291 fromDecimal: fromDecimal,
2292 toUtf8: toUtf8,
2293 toAscii: toAscii,
2294 fromUtf8: fromUtf8,
2295 fromAscii: fromAscii,
2296 transformToFullName: transformToFullName,
2297 extractDisplayName: extractDisplayName,
2298 extractTypeName: extractTypeName,
2299 toWei: toWei,
2300 fromWei: fromWei,
2301 toBigNumber: toBigNumber,
2302 toTwosComplement: toTwosComplement,
2303 toAddress: toAddress,
2304 isBigNumber: isBigNumber,
2305 isStrictAddress: isStrictAddress,
2306 isAddress: isAddress,
2307 isChecksumAddress: isChecksumAddress,
2308 toChecksumAddress: toChecksumAddress,
2309 isFunction: isFunction,
2310 isString: isString,
2311 isObject: isObject,
2312 isBoolean: isBoolean,
2313 isArray: isArray,
2314 isJson: isJson
2315};
2316
2317
2318/***/ }),
2319/* 3 */
2320/***/ (function(module, exports, __webpack_require__) {
2321
2322/*
2323 This file is part of web3.js.
2324
2325 web3.js is free software: you can redistribute it and/or modify
2326 it under the terms of the GNU Lesser General Public License as published by
2327 the Free Software Foundation, either version 3 of the License, or
2328 (at your option) any later version.
2329
2330 web3.js is distributed in the hope that it will be useful,
2331 but WITHOUT ANY WARRANTY; without even the implied warranty of
2332 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2333 GNU Lesser General Public License for more details.
2334
2335 You should have received a copy of the GNU Lesser General Public License
2336 along with web3.js. If not, see <http://www.gnu.org/licenses/>.
2337*/
2338/**
2339 * @file formatters.js
2340 * @author Marek Kotewicz <marek@ethdev.com>
2341 * @date 2015
2342 */
2343
2344var BigNumber = __webpack_require__(18);
2345var utils = __webpack_require__(2);
2346var c = __webpack_require__(29);
2347var SolidityParam = __webpack_require__(61);
2348
2349
2350/**
2351 * Formats input value to byte representation of int
2352 * If value is negative, return it's two's complement
2353 * If the value is floating point, round it down
2354 *
2355 * @method formatInputInt
2356 * @param {String|Number|BigNumber} value that needs to be formatted
2357 * @returns {SolidityParam}
2358 */
2359var formatInputInt = function (value) {
2360 BigNumber.config(c.ETH_BIGNUMBER_ROUNDING_MODE);
2361 var result = utils.padLeft(utils.toTwosComplement(value).toString(16), 64);
2362 return new SolidityParam(result);
2363};
2364
2365/**
2366 * Formats input bytes
2367 *
2368 * @method formatInputBytes
2369 * @param {String}
2370 * @returns {SolidityParam}
2371 */
2372var formatInputBytes = function (value) {
2373 var result = utils.toHex(value).substr(2);
2374 var l = Math.floor((result.length + 63) / 64);
2375 result = utils.padRight(result, l * 64);
2376 return new SolidityParam(result);
2377};
2378
2379/**
2380 * Formats input bytes
2381 *
2382 * @method formatDynamicInputBytes
2383 * @param {String}
2384 * @returns {SolidityParam}
2385 */
2386var formatInputDynamicBytes = function (value) {
2387 var result = utils.toHex(value).substr(2);
2388 var length = result.length / 2;
2389 var l = Math.floor((result.length + 63) / 64);
2390 result = utils.padRight(result, l * 64);
2391 return new SolidityParam(formatInputInt(length).value + result);
2392};
2393
2394/**
2395 * Formats input value to byte representation of string
2396 *
2397 * @method formatInputString
2398 * @param {String}
2399 * @returns {SolidityParam}
2400 */
2401var formatInputString = function (value) {
2402 var result = utils.fromUtf8(value).substr(2);
2403 var length = result.length / 2;
2404 var l = Math.floor((result.length + 63) / 64);
2405 result = utils.padRight(result, l * 64);
2406 return new SolidityParam(formatInputInt(length).value + result);
2407};
2408
2409/**
2410 * Formats input value to byte representation of bool
2411 *
2412 * @method formatInputBool
2413 * @param {Boolean}
2414 * @returns {SolidityParam}
2415 */
2416var formatInputBool = function (value) {
2417 var result = '000000000000000000000000000000000000000000000000000000000000000' + (value ? '1' : '0');
2418 return new SolidityParam(result);
2419};
2420
2421/**
2422 * Formats input value to byte representation of real
2423 * Values are multiplied by 2^m and encoded as integers
2424 *
2425 * @method formatInputReal
2426 * @param {String|Number|BigNumber}
2427 * @returns {SolidityParam}
2428 */
2429var formatInputReal = function (value) {
2430 return formatInputInt(new BigNumber(value).times(new BigNumber(2).pow(128)));
2431};
2432
2433/**
2434 * Check if input value is negative
2435 *
2436 * @method signedIsNegative
2437 * @param {String} value is hex format
2438 * @returns {Boolean} true if it is negative, otherwise false
2439 */
2440var signedIsNegative = function (value) {
2441 return (new BigNumber(value.substr(0, 1), 16).toString(2).substr(0, 1)) === '1';
2442};
2443
2444/**
2445 * Formats right-aligned output bytes to int
2446 *
2447 * @method formatOutputInt
2448 * @param {SolidityParam} param
2449 * @returns {BigNumber} right-aligned output bytes formatted to big number
2450 */
2451var formatOutputInt = function (param) {
2452 var value = param.staticPart() || "0";
2453
2454 // check if it's negative number
2455 // it it is, return two's complement
2456 if (signedIsNegative(value)) {
2457 return new BigNumber(value, 16).minus(new BigNumber('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 16)).minus(1);
2458 }
2459 return new BigNumber(value, 16);
2460};
2461
2462/**
2463 * Formats right-aligned output bytes to uint
2464 *
2465 * @method formatOutputUInt
2466 * @param {SolidityParam}
2467 * @returns {BigNumeber} right-aligned output bytes formatted to uint
2468 */
2469var formatOutputUInt = function (param) {
2470 var value = param.staticPart() || "0";
2471 return new BigNumber(value, 16);
2472};
2473
2474/**
2475 * Formats right-aligned output bytes to real
2476 *
2477 * @method formatOutputReal
2478 * @param {SolidityParam}
2479 * @returns {BigNumber} input bytes formatted to real
2480 */
2481var formatOutputReal = function (param) {
2482 return formatOutputInt(param).dividedBy(new BigNumber(2).pow(128));
2483};
2484
2485/**
2486 * Formats right-aligned output bytes to ureal
2487 *
2488 * @method formatOutputUReal
2489 * @param {SolidityParam}
2490 * @returns {BigNumber} input bytes formatted to ureal
2491 */
2492var formatOutputUReal = function (param) {
2493 return formatOutputUInt(param).dividedBy(new BigNumber(2).pow(128));
2494};
2495
2496/**
2497 * Should be used to format output bool
2498 *
2499 * @method formatOutputBool
2500 * @param {SolidityParam}
2501 * @returns {Boolean} right-aligned input bytes formatted to bool
2502 */
2503var formatOutputBool = function (param) {
2504 return param.staticPart() === '0000000000000000000000000000000000000000000000000000000000000001' ? true : false;
2505};
2506
2507/**
2508 * Should be used to format output bytes
2509 *
2510 * @method formatOutputBytes
2511 * @param {SolidityParam} left-aligned hex representation of string
2512 * @param {String} name type name
2513 * @returns {String} hex string
2514 */
2515var formatOutputBytes = function (param, name) {
2516 var matches = name.match(/^bytes([0-9]*)/);
2517 var size = parseInt(matches[1]);
2518 return '0x' + param.staticPart().slice(0, 2 * size);
2519};
2520
2521/**
2522 * Should be used to format output bytes
2523 *
2524 * @method formatOutputDynamicBytes
2525 * @param {SolidityParam} left-aligned hex representation of string
2526 * @returns {String} hex string
2527 */
2528var formatOutputDynamicBytes = function (param) {
2529 var length = (new BigNumber(param.dynamicPart().slice(0, 64), 16)).toNumber() * 2;
2530 return '0x' + param.dynamicPart().substr(64, length);
2531};
2532
2533/**
2534 * Should be used to format output string
2535 *
2536 * @method formatOutputString
2537 * @param {SolidityParam} left-aligned hex representation of string
2538 * @returns {String} ascii string
2539 */
2540var formatOutputString = function (param) {
2541 var length = (new BigNumber(param.dynamicPart().slice(0, 64), 16)).toNumber() * 2;
2542 return utils.toUtf8(param.dynamicPart().substr(64, length));
2543};
2544
2545/**
2546 * Should be used to format output address
2547 *
2548 * @method formatOutputAddress
2549 * @param {SolidityParam} right-aligned input bytes
2550 * @returns {String} address
2551 */
2552var formatOutputAddress = function (param) {
2553 var value = param.staticPart();
2554 return "0x" + value.slice(value.length - 40, value.length);
2555};
2556
2557module.exports = {
2558 formatInputInt: formatInputInt,
2559 formatInputBytes: formatInputBytes,
2560 formatInputDynamicBytes: formatInputDynamicBytes,
2561 formatInputString: formatInputString,
2562 formatInputBool: formatInputBool,
2563 formatInputReal: formatInputReal,
2564 formatOutputInt: formatOutputInt,
2565 formatOutputUInt: formatOutputUInt,
2566 formatOutputReal: formatOutputReal,
2567 formatOutputUReal: formatOutputUReal,
2568 formatOutputBool: formatOutputBool,
2569 formatOutputBytes: formatOutputBytes,
2570 formatOutputDynamicBytes: formatOutputDynamicBytes,
2571 formatOutputString: formatOutputString,
2572 formatOutputAddress: formatOutputAddress
2573};
2574
2575
2576/***/ }),
2577/* 4 */
2578/***/ (function(module, exports, __webpack_require__) {
2579
2580var f = __webpack_require__(3);
2581var SolidityParam = __webpack_require__(61);
2582
2583/**
2584 * SolidityType prototype is used to encode/decode solidity params of certain type
2585 */
2586var SolidityType = function (config) {
2587 this._inputFormatter = config.inputFormatter;
2588 this._outputFormatter = config.outputFormatter;
2589};
2590
2591/**
2592 * Should be used to determine if this SolidityType do match given name
2593 *
2594 * @method isType
2595 * @param {String} name
2596 * @return {Bool} true if type match this SolidityType, otherwise false
2597 */
2598SolidityType.prototype.isType = function (name) {
2599 throw "this method should be overrwritten for type " + name;
2600};
2601
2602/**
2603 * Should be used to determine what is the length of static part in given type
2604 *
2605 * @method staticPartLength
2606 * @param {String} name
2607 * @return {Number} length of static part in bytes
2608 */
2609SolidityType.prototype.staticPartLength = function (name) {
2610 // If name isn't an array then treat it like a single element array.
2611 return (this.nestedTypes(name) || ['[1]'])
2612 .map(function (type) {
2613 // the length of the nested array
2614 return parseInt(type.slice(1, -1), 10) || 1;
2615 })
2616 .reduce(function (previous, current) {
2617 return previous * current;
2618 // all basic types are 32 bytes long
2619 }, 32);
2620};
2621
2622/**
2623 * Should be used to determine if type is dynamic array
2624 * eg:
2625 * "type[]" => true
2626 * "type[4]" => false
2627 *
2628 * @method isDynamicArray
2629 * @param {String} name
2630 * @return {Bool} true if the type is dynamic array
2631 */
2632SolidityType.prototype.isDynamicArray = function (name) {
2633 var nestedTypes = this.nestedTypes(name);
2634 return !!nestedTypes && !nestedTypes[nestedTypes.length - 1].match(/[0-9]{1,}/g);
2635};
2636
2637/**
2638 * Should be used to determine if type is static array
2639 * eg:
2640 * "type[]" => false
2641 * "type[4]" => true
2642 *
2643 * @method isStaticArray
2644 * @param {String} name
2645 * @return {Bool} true if the type is static array
2646 */
2647SolidityType.prototype.isStaticArray = function (name) {
2648 var nestedTypes = this.nestedTypes(name);
2649 return !!nestedTypes && !!nestedTypes[nestedTypes.length - 1].match(/[0-9]{1,}/g);
2650};
2651
2652/**
2653 * Should return length of static array
2654 * eg.
2655 * "int[32]" => 32
2656 * "int256[14]" => 14
2657 * "int[2][3]" => 3
2658 * "int" => 1
2659 * "int[1]" => 1
2660 * "int[]" => 1
2661 *
2662 * @method staticArrayLength
2663 * @param {String} name
2664 * @return {Number} static array length
2665 */
2666SolidityType.prototype.staticArrayLength = function (name) {
2667 var nestedTypes = this.nestedTypes(name);
2668 if (nestedTypes) {
2669 return parseInt(nestedTypes[nestedTypes.length - 1].match(/[0-9]{1,}/g) || 1);
2670 }
2671 return 1;
2672};
2673
2674/**
2675 * Should return nested type
2676 * eg.
2677 * "int[32]" => "int"
2678 * "int256[14]" => "int256"
2679 * "int[2][3]" => "int[2]"
2680 * "int" => "int"
2681 * "int[]" => "int"
2682 *
2683 * @method nestedName
2684 * @param {String} name
2685 * @return {String} nested name
2686 */
2687SolidityType.prototype.nestedName = function (name) {
2688 // remove last [] in name
2689 var nestedTypes = this.nestedTypes(name);
2690 if (!nestedTypes) {
2691 return name;
2692 }
2693
2694 return name.substr(0, name.length - nestedTypes[nestedTypes.length - 1].length);
2695};
2696
2697/**
2698 * Should return true if type has dynamic size by default
2699 * such types are "string", "bytes"
2700 *
2701 * @method isDynamicType
2702 * @param {String} name
2703 * @return {Bool} true if is dynamic, otherwise false
2704 */
2705SolidityType.prototype.isDynamicType = function () {
2706 return false;
2707};
2708
2709/**
2710 * Should return array of nested types
2711 * eg.
2712 * "int[2][3][]" => ["[2]", "[3]", "[]"]
2713 * "int[] => ["[]"]
2714 * "int" => null
2715 *
2716 * @method nestedTypes
2717 * @param {String} name
2718 * @return {Array} array of nested types
2719 */
2720SolidityType.prototype.nestedTypes = function (name) {
2721 // return list of strings eg. "[]", "[3]", "[]", "[2]"
2722 return name.match(/(\[[0-9]*\])/g);
2723};
2724
2725/**
2726 * Should be used to encode the value
2727 *
2728 * @method encode
2729 * @param {Object} value
2730 * @param {String} name
2731 * @return {String} encoded value
2732 */
2733SolidityType.prototype.encode = function (value, name) {
2734 var self = this;
2735 if (this.isDynamicArray(name)) {
2736
2737 return (function () {
2738 var length = value.length; // in int
2739 var nestedName = self.nestedName(name);
2740
2741 var result = [];
2742 result.push(f.formatInputInt(length).encode());
2743
2744 value.forEach(function (v) {
2745 result.push(self.encode(v, nestedName));
2746 });
2747
2748 return result;
2749 })();
2750
2751 } else if (this.isStaticArray(name)) {
2752
2753 return (function () {
2754 var length = self.staticArrayLength(name); // in int
2755 var nestedName = self.nestedName(name);
2756
2757 var result = [];
2758 for (var i = 0; i < length; i++) {
2759 result.push(self.encode(value[i], nestedName));
2760 }
2761
2762 return result;
2763 })();
2764
2765 }
2766
2767 return this._inputFormatter(value, name).encode();
2768};
2769
2770/**
2771 * Should be used to decode value from bytes
2772 *
2773 * @method decode
2774 * @param {String} bytes
2775 * @param {Number} offset in bytes
2776 * @param {String} name type name
2777 * @returns {Object} decoded value
2778 */
2779SolidityType.prototype.decode = function (bytes, offset, name) {
2780 var self = this;
2781
2782 if (this.isDynamicArray(name)) {
2783
2784 return (function () {
2785 var arrayOffset = parseInt('0x' + bytes.substr(offset * 2, 64)); // in bytes
2786 var length = parseInt('0x' + bytes.substr(arrayOffset * 2, 64)); // in int
2787 var arrayStart = arrayOffset + 32; // array starts after length; // in bytes
2788
2789 var nestedName = self.nestedName(name);
2790 var nestedStaticPartLength = self.staticPartLength(nestedName); // in bytes
2791 var roundedNestedStaticPartLength = Math.floor((nestedStaticPartLength + 31) / 32) * 32;
2792 var result = [];
2793
2794 for (var i = 0; i < length * roundedNestedStaticPartLength; i += roundedNestedStaticPartLength) {
2795 result.push(self.decode(bytes, arrayStart + i, nestedName));
2796 }
2797
2798 return result;
2799 })();
2800
2801 } else if (this.isStaticArray(name)) {
2802
2803 return (function () {
2804 var length = self.staticArrayLength(name); // in int
2805 var arrayStart = offset; // in bytes
2806
2807 var nestedName = self.nestedName(name);
2808 var nestedStaticPartLength = self.staticPartLength(nestedName); // in bytes
2809 var roundedNestedStaticPartLength = Math.floor((nestedStaticPartLength + 31) / 32) * 32;
2810 var result = [];
2811
2812 for (var i = 0; i < length * roundedNestedStaticPartLength; i += roundedNestedStaticPartLength) {
2813 result.push(self.decode(bytes, arrayStart + i, nestedName));
2814 }
2815
2816 return result;
2817 })();
2818 } else if (this.isDynamicType(name)) {
2819
2820 return (function () {
2821 var dynamicOffset = parseInt('0x' + bytes.substr(offset * 2, 64)); // in bytes
2822 var length = parseInt('0x' + bytes.substr(dynamicOffset * 2, 64)); // in bytes
2823 var roundedLength = Math.floor((length + 31) / 32); // in int
2824 var param = new SolidityParam(bytes.substr(dynamicOffset * 2, ( 1 + roundedLength) * 64), 0);
2825 return self._outputFormatter(param, name);
2826 })();
2827 }
2828
2829 var length = this.staticPartLength(name);
2830 var param = new SolidityParam(bytes.substr(offset * 2, length * 2));
2831 return this._outputFormatter(param, name);
2832};
2833
2834module.exports = SolidityType;
2835
2836
2837/***/ }),
2838/* 5 */
2839/***/ (function(module, exports, __webpack_require__) {
2840
2841/*
2842 This file is part of web3.js.
2843
2844 web3.js is free software: you can redistribute it and/or modify
2845 it under the terms of the GNU Lesser General Public License as published by
2846 the Free Software Foundation, either version 3 of the License, or
2847 (at your option) any later version.
2848
2849 web3.js is distributed in the hope that it will be useful,
2850 but WITHOUT ANY WARRANTY; without even the implied warranty of
2851 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2852 GNU Lesser General Public License for more details.
2853
2854 You should have received a copy of the GNU Lesser General Public License
2855 along with web3.js. If not, see <http://www.gnu.org/licenses/>.
2856*/
2857/**
2858 * @file formatters.js
2859 * @author Marek Kotewicz <marek@ethdev.com>
2860 * @author Fabian Vogelsteller <fabian@ethdev.com>
2861 * @date 2015
2862 */
2863
2864var utils = __webpack_require__(2);
2865var config = __webpack_require__(29);
2866var Iban = __webpack_require__(31);
2867
2868/**
2869 * Should the format output to a big number
2870 *
2871 * @method outputBigNumberFormatter
2872 * @param {String|Number|BigNumber}
2873 * @returns {BigNumber} object
2874 */
2875var outputBigNumberFormatter = function (number) {
2876 return utils.toBigNumber(number);
2877};
2878
2879var isPredefinedBlockNumber = function (blockNumber) {
2880 return blockNumber === 'latest' || blockNumber === 'pending' || blockNumber === 'earliest';
2881};
2882
2883var inputDefaultBlockNumberFormatter = function (blockNumber) {
2884 if (blockNumber === undefined) {
2885 return config.defaultBlock;
2886 }
2887 return inputBlockNumberFormatter(blockNumber);
2888};
2889
2890var inputBlockNumberFormatter = function (blockNumber) {
2891 if (blockNumber === undefined) {
2892 return undefined;
2893 } else if (isPredefinedBlockNumber(blockNumber)) {
2894 return blockNumber;
2895 }
2896 return utils.toHex(blockNumber);
2897};
2898
2899/**
2900 * Formats the input of a transaction and converts all values to HEX
2901 *
2902 * @method inputCallFormatter
2903 * @param {Object} transaction options
2904 * @returns object
2905*/
2906var inputCallFormatter = function (options){
2907
2908 options.from = options.from || config.defaultAccount;
2909
2910 if (options.from) {
2911 options.from = inputAddressFormatter(options.from);
2912 }
2913
2914 if (options.to) { // it might be contract creation
2915 options.to = inputAddressFormatter(options.to);
2916 }
2917
2918 ['gasPrice', 'gas', 'value', 'nonce'].filter(function (key) {
2919 return options[key] !== undefined;
2920 }).forEach(function(key){
2921 options[key] = utils.fromDecimal(options[key]);
2922 });
2923
2924 return options;
2925};
2926
2927/**
2928 * Formats the input of a transaction and converts all values to HEX
2929 *
2930 * @method inputTransactionFormatter
2931 * @param {Object} transaction options
2932 * @returns object
2933*/
2934var inputTransactionFormatter = function (options){
2935
2936 options.from = options.from || config.defaultAccount;
2937 options.from = inputAddressFormatter(options.from);
2938
2939 if (options.to) { // it might be contract creation
2940 options.to = inputAddressFormatter(options.to);
2941 }
2942
2943 ['gasPrice', 'gas', 'value', 'nonce'].filter(function (key) {
2944 return options[key] !== undefined;
2945 }).forEach(function(key){
2946 options[key] = utils.fromDecimal(options[key]);
2947 });
2948
2949 return options;
2950};
2951
2952/**
2953 * Formats the output of a transaction to its proper values
2954 *
2955 * @method outputTransactionFormatter
2956 * @param {Object} tx
2957 * @returns {Object}
2958*/
2959var outputTransactionFormatter = function (tx){
2960 if(tx.blockNumber !== null)
2961 tx.blockNumber = utils.toDecimal(tx.blockNumber);
2962 if(tx.transactionIndex !== null)
2963 tx.transactionIndex = utils.toDecimal(tx.transactionIndex);
2964 tx.nonce = utils.toDecimal(tx.nonce);
2965 tx.gas = utils.toDecimal(tx.gas);
2966 tx.gasPrice = utils.toBigNumber(tx.gasPrice);
2967 tx.value = utils.toBigNumber(tx.value);
2968 return tx;
2969};
2970
2971/**
2972 * Formats the output of a transaction receipt to its proper values
2973 *
2974 * @method outputTransactionReceiptFormatter
2975 * @param {Object} receipt
2976 * @returns {Object}
2977*/
2978var outputTransactionReceiptFormatter = function (receipt){
2979 if(receipt.blockNumber !== null)
2980 receipt.blockNumber = utils.toDecimal(receipt.blockNumber);
2981 if(receipt.transactionIndex !== null)
2982 receipt.transactionIndex = utils.toDecimal(receipt.transactionIndex);
2983 receipt.cumulativeGasUsed = utils.toDecimal(receipt.cumulativeGasUsed);
2984 receipt.gasUsed = utils.toDecimal(receipt.gasUsed);
2985
2986 if(utils.isArray(receipt.logs)) {
2987 receipt.logs = receipt.logs.map(function(log){
2988 return outputLogFormatter(log);
2989 });
2990 }
2991
2992 return receipt;
2993};
2994
2995/**
2996 * Formats the output of a block to its proper values
2997 *
2998 * @method outputBlockFormatter
2999 * @param {Object} block
3000 * @returns {Object}
3001*/
3002var outputBlockFormatter = function(block) {
3003
3004 // transform to number
3005 block.gasLimit = utils.toDecimal(block.gasLimit);
3006 block.gasUsed = utils.toDecimal(block.gasUsed);
3007 block.size = utils.toDecimal(block.size);
3008 block.timestamp = utils.toDecimal(block.timestamp);
3009 if(block.number !== null)
3010 block.number = utils.toDecimal(block.number);
3011
3012 block.difficulty = utils.toBigNumber(block.difficulty);
3013 block.totalDifficulty = utils.toBigNumber(block.totalDifficulty);
3014
3015 if (utils.isArray(block.transactions)) {
3016 block.transactions.forEach(function(item){
3017 if(!utils.isString(item))
3018 return outputTransactionFormatter(item);
3019 });
3020 }
3021
3022 return block;
3023};
3024
3025/**
3026 * Formats the output of a log
3027 *
3028 * @method outputLogFormatter
3029 * @param {Object} log object
3030 * @returns {Object} log
3031*/
3032var outputLogFormatter = function(log) {
3033 if(log.blockNumber !== null)
3034 log.blockNumber = utils.toDecimal(log.blockNumber);
3035 if(log.transactionIndex !== null)
3036 log.transactionIndex = utils.toDecimal(log.transactionIndex);
3037 if(log.logIndex !== null)
3038 log.logIndex = utils.toDecimal(log.logIndex);
3039
3040 return log;
3041};
3042
3043/**
3044 * Formats the input of a whisper post and converts all values to HEX
3045 *
3046 * @method inputPostFormatter
3047 * @param {Object} transaction object
3048 * @returns {Object}
3049*/
3050var inputPostFormatter = function(post) {
3051
3052 // post.payload = utils.toHex(post.payload);
3053 post.ttl = utils.fromDecimal(post.ttl);
3054 post.workToProve = utils.fromDecimal(post.workToProve);
3055 post.priority = utils.fromDecimal(post.priority);
3056
3057 // fallback
3058 if (!utils.isArray(post.topics)) {
3059 post.topics = post.topics ? [post.topics] : [];
3060 }
3061
3062 // format the following options
3063 post.topics = post.topics.map(function(topic){
3064 // convert only if not hex
3065 return (topic.indexOf('0x') === 0) ? topic : utils.fromUtf8(topic);
3066 });
3067
3068 return post;
3069};
3070
3071/**
3072 * Formats the output of a received post message
3073 *
3074 * @method outputPostFormatter
3075 * @param {Object}
3076 * @returns {Object}
3077 */
3078var outputPostFormatter = function(post){
3079
3080 post.expiry = utils.toDecimal(post.expiry);
3081 post.sent = utils.toDecimal(post.sent);
3082 post.ttl = utils.toDecimal(post.ttl);
3083 post.workProved = utils.toDecimal(post.workProved);
3084 // post.payloadRaw = post.payload;
3085 // post.payload = utils.toAscii(post.payload);
3086
3087 // if (utils.isJson(post.payload)) {
3088 // post.payload = JSON.parse(post.payload);
3089 // }
3090
3091 // format the following options
3092 if (!post.topics) {
3093 post.topics = [];
3094 }
3095 post.topics = post.topics.map(function(topic){
3096 return utils.toAscii(topic);
3097 });
3098
3099 return post;
3100};
3101
3102var inputAddressFormatter = function (address) {
3103 var iban = new Iban(address);
3104 if (iban.isValid() && iban.isDirect()) {
3105 return '0x' + iban.address();
3106 } else if (utils.isStrictAddress(address)) {
3107 return address;
3108 } else if (utils.isAddress(address)) {
3109 return '0x' + address;
3110 }
3111 throw new Error('invalid address');
3112};
3113
3114
3115var outputSyncingFormatter = function(result) {
3116
3117 result.startingBlock = utils.toDecimal(result.startingBlock);
3118 result.currentBlock = utils.toDecimal(result.currentBlock);
3119 result.highestBlock = utils.toDecimal(result.highestBlock);
3120 if (result.knownStates) {
3121 result.knownStates = utils.toDecimal(result.knownStates);
3122 result.pulledStates = utils.toDecimal(result.pulledStates);
3123 }
3124
3125 return result;
3126};
3127
3128module.exports = {
3129 inputDefaultBlockNumberFormatter: inputDefaultBlockNumberFormatter,
3130 inputBlockNumberFormatter: inputBlockNumberFormatter,
3131 inputCallFormatter: inputCallFormatter,
3132 inputTransactionFormatter: inputTransactionFormatter,
3133 inputAddressFormatter: inputAddressFormatter,
3134 inputPostFormatter: inputPostFormatter,
3135 outputBigNumberFormatter: outputBigNumberFormatter,
3136 outputTransactionFormatter: outputTransactionFormatter,
3137 outputTransactionReceiptFormatter: outputTransactionReceiptFormatter,
3138 outputBlockFormatter: outputBlockFormatter,
3139 outputLogFormatter: outputLogFormatter,
3140 outputPostFormatter: outputPostFormatter,
3141 outputSyncingFormatter: outputSyncingFormatter
3142};
3143
3144
3145
3146/***/ }),
3147/* 6 */
3148/***/ (function(module, exports) {
3149
3150// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
3151var global = module.exports = typeof window != 'undefined' && window.Math == Math
3152 ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')();
3153if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef
3154
3155/***/ }),
3156/* 7 */
3157/***/ (function(module, exports) {
3158
3159var hasOwnProperty = {}.hasOwnProperty;
3160module.exports = function(it, key){
3161 return hasOwnProperty.call(it, key);
3162};
3163
3164/***/ }),
3165/* 8 */
3166/***/ (function(module, exports, __webpack_require__) {
3167
3168// to indexed object, toObject with fallback for non-array-like ES3 strings
3169var IObject = __webpack_require__(76)
3170 , defined = __webpack_require__(34);
3171module.exports = function(it){
3172 return IObject(defined(it));
3173};
3174
3175/***/ }),
3176/* 9 */
3177/***/ (function(module, exports, __webpack_require__) {
3178
3179/*
3180 This file is part of web3.js.
3181
3182 web3.js is free software: you can redistribute it and/or modify
3183 it under the terms of the GNU Lesser General Public License as published by
3184 the Free Software Foundation, either version 3 of the License, or
3185 (at your option) any later version.
3186
3187 web3.js is distributed in the hope that it will be useful,
3188 but WITHOUT ANY WARRANTY; without even the implied warranty of
3189 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3190 GNU Lesser General Public License for more details.
3191
3192 You should have received a copy of the GNU Lesser General Public License
3193 along with web3.js. If not, see <http://www.gnu.org/licenses/>.
3194*/
3195/**
3196 * @file method.js
3197 * @author Marek Kotewicz <marek@ethdev.com>
3198 * @date 2015
3199 */
3200
3201var utils = __webpack_require__(2);
3202var errors = __webpack_require__(20);
3203
3204var Method = function (options) {
3205 this.name = options.name;
3206 this.call = options.call;
3207 this.params = options.params || 0;
3208 this.inputFormatter = options.inputFormatter;
3209 this.outputFormatter = options.outputFormatter;
3210 this.requestManager = null;
3211};
3212
3213Method.prototype.setRequestManager = function (rm) {
3214 this.requestManager = rm;
3215};
3216
3217/**
3218 * Should be used to determine name of the jsonrpc method based on arguments
3219 *
3220 * @method getCall
3221 * @param {Array} arguments
3222 * @return {String} name of jsonrpc method
3223 */
3224Method.prototype.getCall = function (args) {
3225 return utils.isFunction(this.call) ? this.call(args) : this.call;
3226};
3227
3228/**
3229 * Should be used to extract callback from array of arguments. Modifies input param
3230 *
3231 * @method extractCallback
3232 * @param {Array} arguments
3233 * @return {Function|Null} callback, if exists
3234 */
3235Method.prototype.extractCallback = function (args) {
3236 if (utils.isFunction(args[args.length - 1])) {
3237 return args.pop(); // modify the args array!
3238 }
3239};
3240
3241/**
3242 * Should be called to check if the number of arguments is correct
3243 *
3244 * @method validateArgs
3245 * @param {Array} arguments
3246 * @throws {Error} if it is not
3247 */
3248Method.prototype.validateArgs = function (args) {
3249 if (args.length !== this.params) {
3250 throw errors.InvalidNumberOfParams();
3251 }
3252};
3253
3254/**
3255 * Should be called to format input args of method
3256 *
3257 * @method formatInput
3258 * @param {Array}
3259 * @return {Array}
3260 */
3261Method.prototype.formatInput = function (args) {
3262 if (!this.inputFormatter) {
3263 return args;
3264 }
3265
3266 return this.inputFormatter.map(function (formatter, index) {
3267 return formatter ? formatter(args[index]) : args[index];
3268 });
3269};
3270
3271/**
3272 * Should be called to format output(result) of method
3273 *
3274 * @method formatOutput
3275 * @param {Object}
3276 * @return {Object}
3277 */
3278Method.prototype.formatOutput = function (result) {
3279 return this.outputFormatter && result ? this.outputFormatter(result) : result;
3280};
3281
3282/**
3283 * Should create payload from given input args
3284 *
3285 * @method toPayload
3286 * @param {Array} args
3287 * @return {Object}
3288 */
3289Method.prototype.toPayload = function (args) {
3290 var call = this.getCall(args);
3291 var callback = this.extractCallback(args);
3292 var params = this.formatInput(args);
3293 this.validateArgs(params);
3294
3295 return {
3296 method: call,
3297 params: params,
3298 callback: callback
3299 };
3300};
3301
3302Method.prototype.attachToObject = function (obj) {
3303 var func = this.buildCall();
3304 func.call = this.call; // TODO!!! that's ugly. filter.js uses it
3305 var name = this.name.split('.');
3306 if (name.length > 1) {
3307 obj[name[0]] = obj[name[0]] || {};
3308 obj[name[0]][name[1]] = func;
3309 } else {
3310 obj[name[0]] = func;
3311 }
3312};
3313
3314Method.prototype.buildCall = function() {
3315 var method = this;
3316 var send = function () {
3317 var payload = method.toPayload(Array.prototype.slice.call(arguments));
3318 if (payload.callback) {
3319 return method.requestManager.sendAsync(payload, function (err, result) {
3320 payload.callback(err, method.formatOutput(result));
3321 });
3322 }
3323 return method.formatOutput(method.requestManager.send(payload));
3324 };
3325 send.request = this.request.bind(this);
3326 return send;
3327};
3328
3329/**
3330 * Should be called to create pure JSONRPC request which can be used in batch request
3331 *
3332 * @method request
3333 * @param {...} params
3334 * @return {Object} jsonrpc request
3335 */
3336Method.prototype.request = function () {
3337 var payload = this.toPayload(Array.prototype.slice.call(arguments));
3338 payload.format = this.formatOutput.bind(this);
3339 return payload;
3340};
3341
3342module.exports = Method;
3343
3344
3345
3346/***/ }),
3347/* 10 */
3348/***/ (function(module, exports, __webpack_require__) {
3349
3350// Thank's IE8 for his funny defineProperty
3351module.exports = !__webpack_require__(23)(function(){
3352 return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7;
3353});
3354
3355/***/ }),
3356/* 11 */
3357/***/ (function(module, exports, __webpack_require__) {
3358
3359var dP = __webpack_require__(12)
3360 , createDesc = __webpack_require__(26);
3361module.exports = __webpack_require__(10) ? function(object, key, value){
3362 return dP.f(object, key, createDesc(1, value));
3363} : function(object, key, value){
3364 object[key] = value;
3365 return object;
3366};
3367
3368/***/ }),
3369/* 12 */
3370/***/ (function(module, exports, __webpack_require__) {
3371
3372var anObject = __webpack_require__(22)
3373 , IE8_DOM_DEFINE = __webpack_require__(51)
3374 , toPrimitive = __webpack_require__(43)
3375 , dP = Object.defineProperty;
3376
3377exports.f = __webpack_require__(10) ? Object.defineProperty : function defineProperty(O, P, Attributes){
3378 anObject(O);
3379 P = toPrimitive(P, true);
3380 anObject(Attributes);
3381 if(IE8_DOM_DEFINE)try {
3382 return dP(O, P, Attributes);
3383 } catch(e){ /* empty */ }
3384 if('get' in Attributes || 'set' in Attributes)throw TypeError('Accessors not supported!');
3385 if('value' in Attributes)O[P] = Attributes.value;
3386 return O;
3387};
3388
3389/***/ }),
3390/* 13 */
3391/***/ (function(module, exports, __webpack_require__) {
3392
3393var store = __webpack_require__(41)('wks')
3394 , uid = __webpack_require__(27)
3395 , Symbol = __webpack_require__(6).Symbol
3396 , USE_SYMBOL = typeof Symbol == 'function';
3397
3398var $exports = module.exports = function(name){
3399 return store[name] || (store[name] =
3400 USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));
3401};
3402
3403$exports.store = store;
3404
3405/***/ }),
3406/* 14 */
3407/***/ (function(module, exports, __webpack_require__) {
3408
3409;(function (root, factory) {
3410 if (true) {
3411 // CommonJS
3412 module.exports = exports = factory(__webpack_require__(0));
3413 }
3414 else if (typeof define === "function" && define.amd) {
3415 // AMD
3416 define(["./core"], factory);
3417 }
3418 else {
3419 // Global (browser)
3420 factory(root.CryptoJS);
3421 }
3422}(this, function (CryptoJS) {
3423
3424 (function () {
3425 // Shortcuts
3426 var C = CryptoJS;
3427 var C_lib = C.lib;
3428 var WordArray = C_lib.WordArray;
3429 var C_enc = C.enc;
3430
3431 /**
3432 * Base64 encoding strategy.
3433 */
3434 var Base64 = C_enc.Base64 = {
3435 /**
3436 * Converts a word array to a Base64 string.
3437 *
3438 * @param {WordArray} wordArray The word array.
3439 *
3440 * @return {string} The Base64 string.
3441 *
3442 * @static
3443 *
3444 * @example
3445 *
3446 * var base64String = CryptoJS.enc.Base64.stringify(wordArray);
3447 */
3448 stringify: function (wordArray) {
3449 // Shortcuts
3450 var words = wordArray.words;
3451 var sigBytes = wordArray.sigBytes;
3452 var map = this._map;
3453
3454 // Clamp excess bits
3455 wordArray.clamp();
3456
3457 // Convert
3458 var base64Chars = [];
3459 for (var i = 0; i < sigBytes; i += 3) {
3460 var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
3461 var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
3462 var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
3463
3464 var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
3465
3466 for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
3467 base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
3468 }
3469 }
3470
3471 // Add padding
3472 var paddingChar = map.charAt(64);
3473 if (paddingChar) {
3474 while (base64Chars.length % 4) {
3475 base64Chars.push(paddingChar);
3476 }
3477 }
3478
3479 return base64Chars.join('');
3480 },
3481
3482 /**
3483 * Converts a Base64 string to a word array.
3484 *
3485 * @param {string} base64Str The Base64 string.
3486 *
3487 * @return {WordArray} The word array.
3488 *
3489 * @static
3490 *
3491 * @example
3492 *
3493 * var wordArray = CryptoJS.enc.Base64.parse(base64String);
3494 */
3495 parse: function (base64Str) {
3496 // Shortcuts
3497 var base64StrLength = base64Str.length;
3498 var map = this._map;
3499 var reverseMap = this._reverseMap;
3500
3501 if (!reverseMap) {
3502 reverseMap = this._reverseMap = [];
3503 for (var j = 0; j < map.length; j++) {
3504 reverseMap[map.charCodeAt(j)] = j;
3505 }
3506 }
3507
3508 // Ignore padding
3509 var paddingChar = map.charAt(64);
3510 if (paddingChar) {
3511 var paddingIndex = base64Str.indexOf(paddingChar);
3512 if (paddingIndex !== -1) {
3513 base64StrLength = paddingIndex;
3514 }
3515 }
3516
3517 // Convert
3518 return parseLoop(base64Str, base64StrLength, reverseMap);
3519
3520 },
3521
3522 _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
3523 };
3524
3525 function parseLoop(base64Str, base64StrLength, reverseMap) {
3526 var words = [];
3527 var nBytes = 0;
3528 for (var i = 0; i < base64StrLength; i++) {
3529 if (i % 4) {
3530 var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2);
3531 var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2);
3532 words[nBytes >>> 2] |= (bits1 | bits2) << (24 - (nBytes % 4) * 8);
3533 nBytes++;
3534 }
3535 }
3536 return WordArray.create(words, nBytes);
3537 }
3538 }());
3539
3540
3541 return CryptoJS.enc.Base64;
3542
3543}));
3544
3545/***/ }),
3546/* 15 */
3547/***/ (function(module, exports, __webpack_require__) {
3548
3549;(function (root, factory, undef) {
3550 if (true) {
3551 // CommonJS
3552 module.exports = exports = factory(__webpack_require__(0), __webpack_require__(47), __webpack_require__(46));
3553 }
3554 else if (typeof define === "function" && define.amd) {
3555 // AMD
3556 define(["./core", "./sha1", "./hmac"], factory);
3557 }
3558 else {
3559 // Global (browser)
3560 factory(root.CryptoJS);
3561 }
3562}(this, function (CryptoJS) {
3563
3564 (function () {
3565 // Shortcuts
3566 var C = CryptoJS;
3567 var C_lib = C.lib;
3568 var Base = C_lib.Base;
3569 var WordArray = C_lib.WordArray;
3570 var C_algo = C.algo;
3571 var MD5 = C_algo.MD5;
3572
3573 /**
3574 * This key derivation function is meant to conform with EVP_BytesToKey.
3575 * www.openssl.org/docs/crypto/EVP_BytesToKey.html
3576 */
3577 var EvpKDF = C_algo.EvpKDF = Base.extend({
3578 /**
3579 * Configuration options.
3580 *
3581 * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
3582 * @property {Hasher} hasher The hash algorithm to use. Default: MD5
3583 * @property {number} iterations The number of iterations to perform. Default: 1
3584 */
3585 cfg: Base.extend({
3586 keySize: 128/32,
3587 hasher: MD5,
3588 iterations: 1
3589 }),
3590
3591 /**
3592 * Initializes a newly created key derivation function.
3593 *
3594 * @param {Object} cfg (Optional) The configuration options to use for the derivation.
3595 *
3596 * @example
3597 *
3598 * var kdf = CryptoJS.algo.EvpKDF.create();
3599 * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 });
3600 * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 });
3601 */
3602 init: function (cfg) {
3603 this.cfg = this.cfg.extend(cfg);
3604 },
3605
3606 /**
3607 * Derives a key from a password.
3608 *
3609 * @param {WordArray|string} password The password.
3610 * @param {WordArray|string} salt A salt.
3611 *
3612 * @return {WordArray} The derived key.
3613 *
3614 * @example
3615 *
3616 * var key = kdf.compute(password, salt);
3617 */
3618 compute: function (password, salt) {
3619 // Shortcut
3620 var cfg = this.cfg;
3621
3622 // Init hasher
3623 var hasher = cfg.hasher.create();
3624
3625 // Initial values
3626 var derivedKey = WordArray.create();
3627
3628 // Shortcuts
3629 var derivedKeyWords = derivedKey.words;
3630 var keySize = cfg.keySize;
3631 var iterations = cfg.iterations;
3632
3633 // Generate key
3634 while (derivedKeyWords.length < keySize) {
3635 if (block) {
3636 hasher.update(block);
3637 }
3638 var block = hasher.update(password).finalize(salt);
3639 hasher.reset();
3640
3641 // Iterations
3642 for (var i = 1; i < iterations; i++) {
3643 block = hasher.finalize(block);
3644 hasher.reset();
3645 }
3646
3647 derivedKey.concat(block);
3648 }
3649 derivedKey.sigBytes = keySize * 4;
3650
3651 return derivedKey;
3652 }
3653 });
3654
3655 /**
3656 * Derives a key from a password.
3657 *
3658 * @param {WordArray|string} password The password.
3659 * @param {WordArray|string} salt A salt.
3660 * @param {Object} cfg (Optional) The configuration options to use for this computation.
3661 *
3662 * @return {WordArray} The derived key.
3663 *
3664 * @static
3665 *
3666 * @example
3667 *
3668 * var key = CryptoJS.EvpKDF(password, salt);
3669 * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 });
3670 * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 });
3671 */
3672 C.EvpKDF = function (password, salt, cfg) {
3673 return EvpKDF.create(cfg).compute(password, salt);
3674 };
3675 }());
3676
3677
3678 return CryptoJS.EvpKDF;
3679
3680}));
3681
3682/***/ }),
3683/* 16 */
3684/***/ (function(module, exports, __webpack_require__) {
3685
3686;(function (root, factory) {
3687 if (true) {
3688 // CommonJS
3689 module.exports = exports = factory(__webpack_require__(0));
3690 }
3691 else if (typeof define === "function" && define.amd) {
3692 // AMD
3693 define(["./core"], factory);
3694 }
3695 else {
3696 // Global (browser)
3697 factory(root.CryptoJS);
3698 }
3699}(this, function (CryptoJS) {
3700
3701 (function (Math) {
3702 // Shortcuts
3703 var C = CryptoJS;
3704 var C_lib = C.lib;
3705 var WordArray = C_lib.WordArray;
3706 var Hasher = C_lib.Hasher;
3707 var C_algo = C.algo;
3708
3709 // Constants table
3710 var T = [];
3711
3712 // Compute constants
3713 (function () {
3714 for (var i = 0; i < 64; i++) {
3715 T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0;
3716 }
3717 }());
3718
3719 /**
3720 * MD5 hash algorithm.
3721 */
3722 var MD5 = C_algo.MD5 = Hasher.extend({
3723 _doReset: function () {
3724 this._hash = new WordArray.init([
3725 0x67452301, 0xefcdab89,
3726 0x98badcfe, 0x10325476
3727 ]);
3728 },
3729
3730 _doProcessBlock: function (M, offset) {
3731 // Swap endian
3732 for (var i = 0; i < 16; i++) {
3733 // Shortcuts
3734 var offset_i = offset + i;
3735 var M_offset_i = M[offset_i];
3736
3737 M[offset_i] = (
3738 (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
3739 (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
3740 );
3741 }
3742
3743 // Shortcuts
3744 var H = this._hash.words;
3745
3746 var M_offset_0 = M[offset + 0];
3747 var M_offset_1 = M[offset + 1];
3748 var M_offset_2 = M[offset + 2];
3749 var M_offset_3 = M[offset + 3];
3750 var M_offset_4 = M[offset + 4];
3751 var M_offset_5 = M[offset + 5];
3752 var M_offset_6 = M[offset + 6];
3753 var M_offset_7 = M[offset + 7];
3754 var M_offset_8 = M[offset + 8];
3755 var M_offset_9 = M[offset + 9];
3756 var M_offset_10 = M[offset + 10];
3757 var M_offset_11 = M[offset + 11];
3758 var M_offset_12 = M[offset + 12];
3759 var M_offset_13 = M[offset + 13];
3760 var M_offset_14 = M[offset + 14];
3761 var M_offset_15 = M[offset + 15];
3762
3763 // Working varialbes
3764 var a = H[0];
3765 var b = H[1];
3766 var c = H[2];
3767 var d = H[3];
3768
3769 // Computation
3770 a = FF(a, b, c, d, M_offset_0, 7, T[0]);
3771 d = FF(d, a, b, c, M_offset_1, 12, T[1]);
3772 c = FF(c, d, a, b, M_offset_2, 17, T[2]);
3773 b = FF(b, c, d, a, M_offset_3, 22, T[3]);
3774 a = FF(a, b, c, d, M_offset_4, 7, T[4]);
3775 d = FF(d, a, b, c, M_offset_5, 12, T[5]);
3776 c = FF(c, d, a, b, M_offset_6, 17, T[6]);
3777 b = FF(b, c, d, a, M_offset_7, 22, T[7]);
3778 a = FF(a, b, c, d, M_offset_8, 7, T[8]);
3779 d = FF(d, a, b, c, M_offset_9, 12, T[9]);
3780 c = FF(c, d, a, b, M_offset_10, 17, T[10]);
3781 b = FF(b, c, d, a, M_offset_11, 22, T[11]);
3782 a = FF(a, b, c, d, M_offset_12, 7, T[12]);
3783 d = FF(d, a, b, c, M_offset_13, 12, T[13]);
3784 c = FF(c, d, a, b, M_offset_14, 17, T[14]);
3785 b = FF(b, c, d, a, M_offset_15, 22, T[15]);
3786
3787 a = GG(a, b, c, d, M_offset_1, 5, T[16]);
3788 d = GG(d, a, b, c, M_offset_6, 9, T[17]);
3789 c = GG(c, d, a, b, M_offset_11, 14, T[18]);
3790 b = GG(b, c, d, a, M_offset_0, 20, T[19]);
3791 a = GG(a, b, c, d, M_offset_5, 5, T[20]);
3792 d = GG(d, a, b, c, M_offset_10, 9, T[21]);
3793 c = GG(c, d, a, b, M_offset_15, 14, T[22]);
3794 b = GG(b, c, d, a, M_offset_4, 20, T[23]);
3795 a = GG(a, b, c, d, M_offset_9, 5, T[24]);
3796 d = GG(d, a, b, c, M_offset_14, 9, T[25]);
3797 c = GG(c, d, a, b, M_offset_3, 14, T[26]);
3798 b = GG(b, c, d, a, M_offset_8, 20, T[27]);
3799 a = GG(a, b, c, d, M_offset_13, 5, T[28]);
3800 d = GG(d, a, b, c, M_offset_2, 9, T[29]);
3801 c = GG(c, d, a, b, M_offset_7, 14, T[30]);
3802 b = GG(b, c, d, a, M_offset_12, 20, T[31]);
3803
3804 a = HH(a, b, c, d, M_offset_5, 4, T[32]);
3805 d = HH(d, a, b, c, M_offset_8, 11, T[33]);
3806 c = HH(c, d, a, b, M_offset_11, 16, T[34]);
3807 b = HH(b, c, d, a, M_offset_14, 23, T[35]);
3808 a = HH(a, b, c, d, M_offset_1, 4, T[36]);
3809 d = HH(d, a, b, c, M_offset_4, 11, T[37]);
3810 c = HH(c, d, a, b, M_offset_7, 16, T[38]);
3811 b = HH(b, c, d, a, M_offset_10, 23, T[39]);
3812 a = HH(a, b, c, d, M_offset_13, 4, T[40]);
3813 d = HH(d, a, b, c, M_offset_0, 11, T[41]);
3814 c = HH(c, d, a, b, M_offset_3, 16, T[42]);
3815 b = HH(b, c, d, a, M_offset_6, 23, T[43]);
3816 a = HH(a, b, c, d, M_offset_9, 4, T[44]);
3817 d = HH(d, a, b, c, M_offset_12, 11, T[45]);
3818 c = HH(c, d, a, b, M_offset_15, 16, T[46]);
3819 b = HH(b, c, d, a, M_offset_2, 23, T[47]);
3820
3821 a = II(a, b, c, d, M_offset_0, 6, T[48]);
3822 d = II(d, a, b, c, M_offset_7, 10, T[49]);
3823 c = II(c, d, a, b, M_offset_14, 15, T[50]);
3824 b = II(b, c, d, a, M_offset_5, 21, T[51]);
3825 a = II(a, b, c, d, M_offset_12, 6, T[52]);
3826 d = II(d, a, b, c, M_offset_3, 10, T[53]);
3827 c = II(c, d, a, b, M_offset_10, 15, T[54]);
3828 b = II(b, c, d, a, M_offset_1, 21, T[55]);
3829 a = II(a, b, c, d, M_offset_8, 6, T[56]);
3830 d = II(d, a, b, c, M_offset_15, 10, T[57]);
3831 c = II(c, d, a, b, M_offset_6, 15, T[58]);
3832 b = II(b, c, d, a, M_offset_13, 21, T[59]);
3833 a = II(a, b, c, d, M_offset_4, 6, T[60]);
3834 d = II(d, a, b, c, M_offset_11, 10, T[61]);
3835 c = II(c, d, a, b, M_offset_2, 15, T[62]);
3836 b = II(b, c, d, a, M_offset_9, 21, T[63]);
3837
3838 // Intermediate hash value
3839 H[0] = (H[0] + a) | 0;
3840 H[1] = (H[1] + b) | 0;
3841 H[2] = (H[2] + c) | 0;
3842 H[3] = (H[3] + d) | 0;
3843 },
3844
3845 _doFinalize: function () {
3846 // Shortcuts
3847 var data = this._data;
3848 var dataWords = data.words;
3849
3850 var nBitsTotal = this._nDataBytes * 8;
3851 var nBitsLeft = data.sigBytes * 8;
3852
3853 // Add padding
3854 dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
3855
3856 var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000);
3857 var nBitsTotalL = nBitsTotal;
3858 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = (
3859 (((nBitsTotalH << 8) | (nBitsTotalH >>> 24)) & 0x00ff00ff) |
3860 (((nBitsTotalH << 24) | (nBitsTotalH >>> 8)) & 0xff00ff00)
3861 );
3862 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
3863 (((nBitsTotalL << 8) | (nBitsTotalL >>> 24)) & 0x00ff00ff) |
3864 (((nBitsTotalL << 24) | (nBitsTotalL >>> 8)) & 0xff00ff00)
3865 );
3866
3867 data.sigBytes = (dataWords.length + 1) * 4;
3868
3869 // Hash final blocks
3870 this._process();
3871
3872 // Shortcuts
3873 var hash = this._hash;
3874 var H = hash.words;
3875
3876 // Swap endian
3877 for (var i = 0; i < 4; i++) {
3878 // Shortcut
3879 var H_i = H[i];
3880
3881 H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
3882 (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
3883 }
3884
3885 // Return final computed hash
3886 return hash;
3887 },
3888
3889 clone: function () {
3890 var clone = Hasher.clone.call(this);
3891 clone._hash = this._hash.clone();
3892
3893 return clone;
3894 }
3895 });
3896
3897 function FF(a, b, c, d, x, s, t) {
3898 var n = a + ((b & c) | (~b & d)) + x + t;
3899 return ((n << s) | (n >>> (32 - s))) + b;
3900 }
3901
3902 function GG(a, b, c, d, x, s, t) {
3903 var n = a + ((b & d) | (c & ~d)) + x + t;
3904 return ((n << s) | (n >>> (32 - s))) + b;
3905 }
3906
3907 function HH(a, b, c, d, x, s, t) {
3908 var n = a + (b ^ c ^ d) + x + t;
3909 return ((n << s) | (n >>> (32 - s))) + b;
3910 }
3911
3912 function II(a, b, c, d, x, s, t) {
3913 var n = a + (c ^ (b | ~d)) + x + t;
3914 return ((n << s) | (n >>> (32 - s))) + b;
3915 }
3916
3917 /**
3918 * Shortcut function to the hasher's object interface.
3919 *
3920 * @param {WordArray|string} message The message to hash.
3921 *
3922 * @return {WordArray} The hash.
3923 *
3924 * @static
3925 *
3926 * @example
3927 *
3928 * var hash = CryptoJS.MD5('message');
3929 * var hash = CryptoJS.MD5(wordArray);
3930 */
3931 C.MD5 = Hasher._createHelper(MD5);
3932
3933 /**
3934 * Shortcut function to the HMAC's object interface.
3935 *
3936 * @param {WordArray|string} message The message to hash.
3937 * @param {WordArray|string} key The secret key.
3938 *
3939 * @return {WordArray} The HMAC.
3940 *
3941 * @static
3942 *
3943 * @example
3944 *
3945 * var hmac = CryptoJS.HmacMD5(message, key);
3946 */
3947 C.HmacMD5 = Hasher._createHmacHelper(MD5);
3948 }(Math));
3949
3950
3951 return CryptoJS.MD5;
3952
3953}));
3954
3955/***/ }),
3956/* 17 */
3957/***/ (function(module, exports, __webpack_require__) {
3958
3959/*
3960 This file is part of web3.js.
3961
3962 web3.js is free software: you can redistribute it and/or modify
3963 it under the terms of the GNU Lesser General Public License as published by
3964 the Free Software Foundation, either version 3 of the License, or
3965 (at your option) any later version.
3966
3967 web3.js is distributed in the hope that it will be useful,
3968 but WITHOUT ANY WARRANTY; without even the implied warranty of
3969 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3970 GNU Lesser General Public License for more details.
3971
3972 You should have received a copy of the GNU Lesser General Public License
3973 along with web3.js. If not, see <http://www.gnu.org/licenses/>.
3974*/
3975/**
3976 * @file property.js
3977 * @author Fabian Vogelsteller <fabian@frozeman.de>
3978 * @author Marek Kotewicz <marek@ethdev.com>
3979 * @date 2015
3980 */
3981
3982var utils = __webpack_require__(2);
3983
3984var Property = function (options) {
3985 this.name = options.name;
3986 this.getter = options.getter;
3987 this.setter = options.setter;
3988 this.outputFormatter = options.outputFormatter;
3989 this.inputFormatter = options.inputFormatter;
3990 this.requestManager = null;
3991};
3992
3993Property.prototype.setRequestManager = function (rm) {
3994 this.requestManager = rm;
3995};
3996
3997/**
3998 * Should be called to format input args of method
3999 *
4000 * @method formatInput
4001 * @param {Array}
4002 * @return {Array}
4003 */
4004Property.prototype.formatInput = function (arg) {
4005 return this.inputFormatter ? this.inputFormatter(arg) : arg;
4006};
4007
4008/**
4009 * Should be called to format output(result) of method
4010 *
4011 * @method formatOutput
4012 * @param {Object}
4013 * @return {Object}
4014 */
4015Property.prototype.formatOutput = function (result) {
4016 return this.outputFormatter && result !== null && result !== undefined ? this.outputFormatter(result) : result;
4017};
4018
4019/**
4020 * Should be used to extract callback from array of arguments. Modifies input param
4021 *
4022 * @method extractCallback
4023 * @param {Array} arguments
4024 * @return {Function|Null} callback, if exists
4025 */
4026Property.prototype.extractCallback = function (args) {
4027 if (utils.isFunction(args[args.length - 1])) {
4028 return args.pop(); // modify the args array!
4029 }
4030};
4031
4032
4033/**
4034 * Should attach function to method
4035 *
4036 * @method attachToObject
4037 * @param {Object}
4038 * @param {Function}
4039 */
4040Property.prototype.attachToObject = function (obj) {
4041 var proto = {
4042 get: this.buildGet(),
4043 enumerable: true
4044 };
4045
4046 var names = this.name.split('.');
4047 var name = names[0];
4048 if (names.length > 1) {
4049 obj[names[0]] = obj[names[0]] || {};
4050 obj = obj[names[0]];
4051 name = names[1];
4052 }
4053
4054 Object.defineProperty(obj, name, proto);
4055 obj[asyncGetterName(name)] = this.buildAsyncGet();
4056};
4057
4058var asyncGetterName = function (name) {
4059 return 'get' + name.charAt(0).toUpperCase() + name.slice(1);
4060};
4061
4062Property.prototype.buildGet = function () {
4063 var property = this;
4064 return function get() {
4065 return property.formatOutput(property.requestManager.send({
4066 method: property.getter
4067 }));
4068 };
4069};
4070
4071Property.prototype.buildAsyncGet = function () {
4072 var property = this;
4073 var get = function (callback) {
4074 property.requestManager.sendAsync({
4075 method: property.getter
4076 }, function (err, result) {
4077 callback(err, property.formatOutput(result));
4078 });
4079 };
4080 get.request = this.request.bind(this);
4081 return get;
4082};
4083
4084/**
4085 * Should be called to create pure JSONRPC request which can be used in batch request
4086 *
4087 * @method request
4088 * @param {...} params
4089 * @return {Object} jsonrpc request
4090 */
4091Property.prototype.request = function () {
4092 var payload = {
4093 method: this.getter,
4094 params: [],
4095 callback: this.extractCallback(Array.prototype.slice.call(arguments))
4096 };
4097 payload.format = this.formatOutput.bind(this);
4098 return payload;
4099};
4100
4101module.exports = Property;
4102
4103
4104
4105/***/ }),
4106/* 18 */
4107/***/ (function(module, exports, __webpack_require__) {
4108
4109var __WEBPACK_AMD_DEFINE_RESULT__;/*! bignumber.js v2.0.7 https://github.com/MikeMcl/bignumber.js/LICENCE */
4110
4111;(function (global) {
4112 'use strict';
4113
4114 /*
4115 bignumber.js v2.0.7
4116 A JavaScript library for arbitrary-precision arithmetic.
4117 https://github.com/MikeMcl/bignumber.js
4118 Copyright (c) 2015 Michael Mclaughlin <M8ch88l@gmail.com>
4119 MIT Expat Licence
4120 */
4121
4122
4123 var BigNumber, crypto, parseNumeric,
4124 isNumeric = /^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,
4125 mathceil = Math.ceil,
4126 mathfloor = Math.floor,
4127 notBool = ' not a boolean or binary digit',
4128 roundingMode = 'rounding mode',
4129 tooManyDigits = 'number type has more than 15 significant digits',
4130 ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_',
4131 BASE = 1e14,
4132 LOG_BASE = 14,
4133 MAX_SAFE_INTEGER = 0x1fffffffffffff, // 2^53 - 1
4134 // MAX_INT32 = 0x7fffffff, // 2^31 - 1
4135 POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13],
4136 SQRT_BASE = 1e7,
4137
4138 /*
4139 * The limit on the value of DECIMAL_PLACES, TO_EXP_NEG, TO_EXP_POS, MIN_EXP, MAX_EXP, and
4140 * the arguments to toExponential, toFixed, toFormat, and toPrecision, beyond which an
4141 * exception is thrown (if ERRORS is true).
4142 */
4143 MAX = 1E9; // 0 to MAX_INT32
4144
4145
4146 /*
4147 * Create and return a BigNumber constructor.
4148 */
4149 function another(configObj) {
4150 var div,
4151
4152 // id tracks the caller function, so its name can be included in error messages.
4153 id = 0,
4154 P = BigNumber.prototype,
4155 ONE = new BigNumber(1),
4156
4157
4158 /********************************* EDITABLE DEFAULTS **********************************/
4159
4160
4161 /*
4162 * The default values below must be integers within the inclusive ranges stated.
4163 * The values can also be changed at run-time using BigNumber.config.
4164 */
4165
4166 // The maximum number of decimal places for operations involving division.
4167 DECIMAL_PLACES = 20, // 0 to MAX
4168
4169 /*
4170 * The rounding mode used when rounding to the above decimal places, and when using
4171 * toExponential, toFixed, toFormat and toPrecision, and round (default value).
4172 * UP 0 Away from zero.
4173 * DOWN 1 Towards zero.
4174 * CEIL 2 Towards +Infinity.
4175 * FLOOR 3 Towards -Infinity.
4176 * HALF_UP 4 Towards nearest neighbour. If equidistant, up.
4177 * HALF_DOWN 5 Towards nearest neighbour. If equidistant, down.
4178 * HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour.
4179 * HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity.
4180 * HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity.
4181 */
4182 ROUNDING_MODE = 4, // 0 to 8
4183
4184 // EXPONENTIAL_AT : [TO_EXP_NEG , TO_EXP_POS]
4185
4186 // The exponent value at and beneath which toString returns exponential notation.
4187 // Number type: -7
4188 TO_EXP_NEG = -7, // 0 to -MAX
4189
4190 // The exponent value at and above which toString returns exponential notation.
4191 // Number type: 21
4192 TO_EXP_POS = 21, // 0 to MAX
4193
4194 // RANGE : [MIN_EXP, MAX_EXP]
4195
4196 // The minimum exponent value, beneath which underflow to zero occurs.
4197 // Number type: -324 (5e-324)
4198 MIN_EXP = -1e7, // -1 to -MAX
4199
4200 // The maximum exponent value, above which overflow to Infinity occurs.
4201 // Number type: 308 (1.7976931348623157e+308)
4202 // For MAX_EXP > 1e7, e.g. new BigNumber('1e100000000').plus(1) may be slow.
4203 MAX_EXP = 1e7, // 1 to MAX
4204
4205 // Whether BigNumber Errors are ever thrown.
4206 ERRORS = true, // true or false
4207
4208 // Change to intValidatorNoErrors if ERRORS is false.
4209 isValidInt = intValidatorWithErrors, // intValidatorWithErrors/intValidatorNoErrors
4210
4211 // Whether to use cryptographically-secure random number generation, if available.
4212 CRYPTO = false, // true or false
4213
4214 /*
4215 * The modulo mode used when calculating the modulus: a mod n.
4216 * The quotient (q = a / n) is calculated according to the corresponding rounding mode.
4217 * The remainder (r) is calculated as: r = a - n * q.
4218 *
4219 * UP 0 The remainder is positive if the dividend is negative, else is negative.
4220 * DOWN 1 The remainder has the same sign as the dividend.
4221 * This modulo mode is commonly known as 'truncated division' and is
4222 * equivalent to (a % n) in JavaScript.
4223 * FLOOR 3 The remainder has the same sign as the divisor (Python %).
4224 * HALF_EVEN 6 This modulo mode implements the IEEE 754 remainder function.
4225 * EUCLID 9 Euclidian division. q = sign(n) * floor(a / abs(n)).
4226 * The remainder is always positive.
4227 *
4228 * The truncated division, floored division, Euclidian division and IEEE 754 remainder
4229 * modes are commonly used for the modulus operation.
4230 * Although the other rounding modes can also be used, they may not give useful results.
4231 */
4232 MODULO_MODE = 1, // 0 to 9
4233
4234 // The maximum number of significant digits of the result of the toPower operation.
4235 // If POW_PRECISION is 0, there will be unlimited significant digits.
4236 POW_PRECISION = 100, // 0 to MAX
4237
4238 // The format specification used by the BigNumber.prototype.toFormat method.
4239 FORMAT = {
4240 decimalSeparator: '.',
4241 groupSeparator: ',',
4242 groupSize: 3,
4243 secondaryGroupSize: 0,
4244 fractionGroupSeparator: '\xA0', // non-breaking space
4245 fractionGroupSize: 0
4246 };
4247
4248
4249 /******************************************************************************************/
4250
4251
4252 // CONSTRUCTOR
4253
4254
4255 /*
4256 * The BigNumber constructor and exported function.
4257 * Create and return a new instance of a BigNumber object.
4258 *
4259 * n {number|string|BigNumber} A numeric value.
4260 * [b] {number} The base of n. Integer, 2 to 64 inclusive.
4261 */
4262 function BigNumber( n, b ) {
4263 var c, e, i, num, len, str,
4264 x = this;
4265
4266 // Enable constructor usage without new.
4267 if ( !( x instanceof BigNumber ) ) {
4268
4269 // 'BigNumber() constructor call without new: {n}'
4270 if (ERRORS) raise( 26, 'constructor call without new', n );
4271 return new BigNumber( n, b );
4272 }
4273
4274 // 'new BigNumber() base not an integer: {b}'
4275 // 'new BigNumber() base out of range: {b}'
4276 if ( b == null || !isValidInt( b, 2, 64, id, 'base' ) ) {
4277
4278 // Duplicate.
4279 if ( n instanceof BigNumber ) {
4280 x.s = n.s;
4281 x.e = n.e;
4282 x.c = ( n = n.c ) ? n.slice() : n;
4283 id = 0;
4284 return;
4285 }
4286
4287 if ( ( num = typeof n == 'number' ) && n * 0 == 0 ) {
4288 x.s = 1 / n < 0 ? ( n = -n, -1 ) : 1;
4289
4290 // Fast path for integers.
4291 if ( n === ~~n ) {
4292 for ( e = 0, i = n; i >= 10; i /= 10, e++ );
4293 x.e = e;
4294 x.c = [n];
4295 id = 0;
4296 return;
4297 }
4298
4299 str = n + '';
4300 } else {
4301 if ( !isNumeric.test( str = n + '' ) ) return parseNumeric( x, str, num );
4302 x.s = str.charCodeAt(0) === 45 ? ( str = str.slice(1), -1 ) : 1;
4303 }
4304 } else {
4305 b = b | 0;
4306 str = n + '';
4307
4308 // Ensure return value is rounded to DECIMAL_PLACES as with other bases.
4309 // Allow exponential notation to be used with base 10 argument.
4310 if ( b == 10 ) {
4311 x = new BigNumber( n instanceof BigNumber ? n : str );
4312 return round( x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE );
4313 }
4314
4315 // Avoid potential interpretation of Infinity and NaN as base 44+ values.
4316 // Any number in exponential form will fail due to the [Ee][+-].
4317 if ( ( num = typeof n == 'number' ) && n * 0 != 0 ||
4318 !( new RegExp( '^-?' + ( c = '[' + ALPHABET.slice( 0, b ) + ']+' ) +
4319 '(?:\\.' + c + ')?$',b < 37 ? 'i' : '' ) ).test(str) ) {
4320 return parseNumeric( x, str, num, b );
4321 }
4322
4323 if (num) {
4324 x.s = 1 / n < 0 ? ( str = str.slice(1), -1 ) : 1;
4325
4326 if ( ERRORS && str.replace( /^0\.0*|\./, '' ).length > 15 ) {
4327
4328 // 'new BigNumber() number type has more than 15 significant digits: {n}'
4329 raise( id, tooManyDigits, n );
4330 }
4331
4332 // Prevent later check for length on converted number.
4333 num = false;
4334 } else {
4335 x.s = str.charCodeAt(0) === 45 ? ( str = str.slice(1), -1 ) : 1;
4336 }
4337
4338 str = convertBase( str, 10, b, x.s );
4339 }
4340
4341 // Decimal point?
4342 if ( ( e = str.indexOf('.') ) > -1 ) str = str.replace( '.', '' );
4343
4344 // Exponential form?
4345 if ( ( i = str.search( /e/i ) ) > 0 ) {
4346
4347 // Determine exponent.
4348 if ( e < 0 ) e = i;
4349 e += +str.slice( i + 1 );
4350 str = str.substring( 0, i );
4351 } else if ( e < 0 ) {
4352
4353 // Integer.
4354 e = str.length;
4355 }
4356
4357 // Determine leading zeros.
4358 for ( i = 0; str.charCodeAt(i) === 48; i++ );
4359
4360 // Determine trailing zeros.
4361 for ( len = str.length; str.charCodeAt(--len) === 48; );
4362 str = str.slice( i, len + 1 );
4363
4364 if (str) {
4365 len = str.length;
4366
4367 // Disallow numbers with over 15 significant digits if number type.
4368 // 'new BigNumber() number type has more than 15 significant digits: {n}'
4369 if ( num && ERRORS && len > 15 ) raise( id, tooManyDigits, x.s * n );
4370
4371 e = e - i - 1;
4372
4373 // Overflow?
4374 if ( e > MAX_EXP ) {
4375
4376 // Infinity.
4377 x.c = x.e = null;
4378
4379 // Underflow?
4380 } else if ( e < MIN_EXP ) {
4381
4382 // Zero.
4383 x.c = [ x.e = 0 ];
4384 } else {
4385 x.e = e;
4386 x.c = [];
4387
4388 // Transform base
4389
4390 // e is the base 10 exponent.
4391 // i is where to slice str to get the first element of the coefficient array.
4392 i = ( e + 1 ) % LOG_BASE;
4393 if ( e < 0 ) i += LOG_BASE;
4394
4395 if ( i < len ) {
4396 if (i) x.c.push( +str.slice( 0, i ) );
4397
4398 for ( len -= LOG_BASE; i < len; ) {
4399 x.c.push( +str.slice( i, i += LOG_BASE ) );
4400 }
4401
4402 str = str.slice(i);
4403 i = LOG_BASE - str.length;
4404 } else {
4405 i -= len;
4406 }
4407
4408 for ( ; i--; str += '0' );
4409 x.c.push( +str );
4410 }
4411 } else {
4412
4413 // Zero.
4414 x.c = [ x.e = 0 ];
4415 }
4416
4417 id = 0;
4418 }
4419
4420
4421 // CONSTRUCTOR PROPERTIES
4422
4423
4424 BigNumber.another = another;
4425
4426 BigNumber.ROUND_UP = 0;
4427 BigNumber.ROUND_DOWN = 1;
4428 BigNumber.ROUND_CEIL = 2;
4429 BigNumber.ROUND_FLOOR = 3;
4430 BigNumber.ROUND_HALF_UP = 4;
4431 BigNumber.ROUND_HALF_DOWN = 5;
4432 BigNumber.ROUND_HALF_EVEN = 6;
4433 BigNumber.ROUND_HALF_CEIL = 7;
4434 BigNumber.ROUND_HALF_FLOOR = 8;
4435 BigNumber.EUCLID = 9;
4436
4437
4438 /*
4439 * Configure infrequently-changing library-wide settings.
4440 *
4441 * Accept an object or an argument list, with one or many of the following properties or
4442 * parameters respectively:
4443 *
4444 * DECIMAL_PLACES {number} Integer, 0 to MAX inclusive
4445 * ROUNDING_MODE {number} Integer, 0 to 8 inclusive
4446 * EXPONENTIAL_AT {number|number[]} Integer, -MAX to MAX inclusive or
4447 * [integer -MAX to 0 incl., 0 to MAX incl.]
4448 * RANGE {number|number[]} Non-zero integer, -MAX to MAX inclusive or
4449 * [integer -MAX to -1 incl., integer 1 to MAX incl.]
4450 * ERRORS {boolean|number} true, false, 1 or 0
4451 * CRYPTO {boolean|number} true, false, 1 or 0
4452 * MODULO_MODE {number} 0 to 9 inclusive
4453 * POW_PRECISION {number} 0 to MAX inclusive
4454 * FORMAT {object} See BigNumber.prototype.toFormat
4455 * decimalSeparator {string}
4456 * groupSeparator {string}
4457 * groupSize {number}
4458 * secondaryGroupSize {number}
4459 * fractionGroupSeparator {string}
4460 * fractionGroupSize {number}
4461 *
4462 * (The values assigned to the above FORMAT object properties are not checked for validity.)
4463 *
4464 * E.g.
4465 * BigNumber.config(20, 4) is equivalent to
4466 * BigNumber.config({ DECIMAL_PLACES : 20, ROUNDING_MODE : 4 })
4467 *
4468 * Ignore properties/parameters set to null or undefined.
4469 * Return an object with the properties current values.
4470 */
4471 BigNumber.config = function () {
4472 var v, p,
4473 i = 0,
4474 r = {},
4475 a = arguments,
4476 o = a[0],
4477 has = o && typeof o == 'object'
4478 ? function () { if ( o.hasOwnProperty(p) ) return ( v = o[p] ) != null; }
4479 : function () { if ( a.length > i ) return ( v = a[i++] ) != null; };
4480
4481 // DECIMAL_PLACES {number} Integer, 0 to MAX inclusive.
4482 // 'config() DECIMAL_PLACES not an integer: {v}'
4483 // 'config() DECIMAL_PLACES out of range: {v}'
4484 if ( has( p = 'DECIMAL_PLACES' ) && isValidInt( v, 0, MAX, 2, p ) ) {
4485 DECIMAL_PLACES = v | 0;
4486 }
4487 r[p] = DECIMAL_PLACES;
4488
4489 // ROUNDING_MODE {number} Integer, 0 to 8 inclusive.
4490 // 'config() ROUNDING_MODE not an integer: {v}'
4491 // 'config() ROUNDING_MODE out of range: {v}'
4492 if ( has( p = 'ROUNDING_MODE' ) && isValidInt( v, 0, 8, 2, p ) ) {
4493 ROUNDING_MODE = v | 0;
4494 }
4495 r[p] = ROUNDING_MODE;
4496
4497 // EXPONENTIAL_AT {number|number[]}
4498 // Integer, -MAX to MAX inclusive or [integer -MAX to 0 inclusive, 0 to MAX inclusive].
4499 // 'config() EXPONENTIAL_AT not an integer: {v}'
4500 // 'config() EXPONENTIAL_AT out of range: {v}'
4501 if ( has( p = 'EXPONENTIAL_AT' ) ) {
4502
4503 if ( isArray(v) ) {
4504 if ( isValidInt( v[0], -MAX, 0, 2, p ) && isValidInt( v[1], 0, MAX, 2, p ) ) {
4505 TO_EXP_NEG = v[0] | 0;
4506 TO_EXP_POS = v[1] | 0;
4507 }
4508 } else if ( isValidInt( v, -MAX, MAX, 2, p ) ) {
4509 TO_EXP_NEG = -( TO_EXP_POS = ( v < 0 ? -v : v ) | 0 );
4510 }
4511 }
4512 r[p] = [ TO_EXP_NEG, TO_EXP_POS ];
4513
4514 // RANGE {number|number[]} Non-zero integer, -MAX to MAX inclusive or
4515 // [integer -MAX to -1 inclusive, integer 1 to MAX inclusive].
4516 // 'config() RANGE not an integer: {v}'
4517 // 'config() RANGE cannot be zero: {v}'
4518 // 'config() RANGE out of range: {v}'
4519 if ( has( p = 'RANGE' ) ) {
4520
4521 if ( isArray(v) ) {
4522 if ( isValidInt( v[0], -MAX, -1, 2, p ) && isValidInt( v[1], 1, MAX, 2, p ) ) {
4523 MIN_EXP = v[0] | 0;
4524 MAX_EXP = v[1] | 0;
4525 }
4526 } else if ( isValidInt( v, -MAX, MAX, 2, p ) ) {
4527 if ( v | 0 ) MIN_EXP = -( MAX_EXP = ( v < 0 ? -v : v ) | 0 );
4528 else if (ERRORS) raise( 2, p + ' cannot be zero', v );
4529 }
4530 }
4531 r[p] = [ MIN_EXP, MAX_EXP ];
4532
4533 // ERRORS {boolean|number} true, false, 1 or 0.
4534 // 'config() ERRORS not a boolean or binary digit: {v}'
4535 if ( has( p = 'ERRORS' ) ) {
4536
4537 if ( v === !!v || v === 1 || v === 0 ) {
4538 id = 0;
4539 isValidInt = ( ERRORS = !!v ) ? intValidatorWithErrors : intValidatorNoErrors;
4540 } else if (ERRORS) {
4541 raise( 2, p + notBool, v );
4542 }
4543 }
4544 r[p] = ERRORS;
4545
4546 // CRYPTO {boolean|number} true, false, 1 or 0.
4547 // 'config() CRYPTO not a boolean or binary digit: {v}'
4548 // 'config() crypto unavailable: {crypto}'
4549 if ( has( p = 'CRYPTO' ) ) {
4550
4551 if ( v === !!v || v === 1 || v === 0 ) {
4552 CRYPTO = !!( v && crypto && typeof crypto == 'object' );
4553 if ( v && !CRYPTO && ERRORS ) raise( 2, 'crypto unavailable', crypto );
4554 } else if (ERRORS) {
4555 raise( 2, p + notBool, v );
4556 }
4557 }
4558 r[p] = CRYPTO;
4559
4560 // MODULO_MODE {number} Integer, 0 to 9 inclusive.
4561 // 'config() MODULO_MODE not an integer: {v}'
4562 // 'config() MODULO_MODE out of range: {v}'
4563 if ( has( p = 'MODULO_MODE' ) && isValidInt( v, 0, 9, 2, p ) ) {
4564 MODULO_MODE = v | 0;
4565 }
4566 r[p] = MODULO_MODE;
4567
4568 // POW_PRECISION {number} Integer, 0 to MAX inclusive.
4569 // 'config() POW_PRECISION not an integer: {v}'
4570 // 'config() POW_PRECISION out of range: {v}'
4571 if ( has( p = 'POW_PRECISION' ) && isValidInt( v, 0, MAX, 2, p ) ) {
4572 POW_PRECISION = v | 0;
4573 }
4574 r[p] = POW_PRECISION;
4575
4576 // FORMAT {object}
4577 // 'config() FORMAT not an object: {v}'
4578 if ( has( p = 'FORMAT' ) ) {
4579
4580 if ( typeof v == 'object' ) {
4581 FORMAT = v;
4582 } else if (ERRORS) {
4583 raise( 2, p + ' not an object', v );
4584 }
4585 }
4586 r[p] = FORMAT;
4587
4588 return r;
4589 };
4590
4591
4592 /*
4593 * Return a new BigNumber whose value is the maximum of the arguments.
4594 *
4595 * arguments {number|string|BigNumber}
4596 */
4597 BigNumber.max = function () { return maxOrMin( arguments, P.lt ); };
4598
4599
4600 /*
4601 * Return a new BigNumber whose value is the minimum of the arguments.
4602 *
4603 * arguments {number|string|BigNumber}
4604 */
4605 BigNumber.min = function () { return maxOrMin( arguments, P.gt ); };
4606
4607
4608 /*
4609 * Return a new BigNumber with a random value equal to or greater than 0 and less than 1,
4610 * and with dp, or DECIMAL_PLACES if dp is omitted, decimal places (or less if trailing
4611 * zeros are produced).
4612 *
4613 * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
4614 *
4615 * 'random() decimal places not an integer: {dp}'
4616 * 'random() decimal places out of range: {dp}'
4617 * 'random() crypto unavailable: {crypto}'
4618 */
4619 BigNumber.random = (function () {
4620 var pow2_53 = 0x20000000000000;
4621
4622 // Return a 53 bit integer n, where 0 <= n < 9007199254740992.
4623 // Check if Math.random() produces more than 32 bits of randomness.
4624 // If it does, assume at least 53 bits are produced, otherwise assume at least 30 bits.
4625 // 0x40000000 is 2^30, 0x800000 is 2^23, 0x1fffff is 2^21 - 1.
4626 var random53bitInt = (Math.random() * pow2_53) & 0x1fffff
4627 ? function () { return mathfloor( Math.random() * pow2_53 ); }
4628 : function () { return ((Math.random() * 0x40000000 | 0) * 0x800000) +
4629 (Math.random() * 0x800000 | 0); };
4630
4631 return function (dp) {
4632 var a, b, e, k, v,
4633 i = 0,
4634 c = [],
4635 rand = new BigNumber(ONE);
4636
4637 dp = dp == null || !isValidInt( dp, 0, MAX, 14 ) ? DECIMAL_PLACES : dp | 0;
4638 k = mathceil( dp / LOG_BASE );
4639
4640 if (CRYPTO) {
4641
4642 // Browsers supporting crypto.getRandomValues.
4643 if ( crypto && crypto.getRandomValues ) {
4644
4645 a = crypto.getRandomValues( new Uint32Array( k *= 2 ) );
4646
4647 for ( ; i < k; ) {
4648
4649 // 53 bits:
4650 // ((Math.pow(2, 32) - 1) * Math.pow(2, 21)).toString(2)
4651 // 11111 11111111 11111111 11111111 11100000 00000000 00000000
4652 // ((Math.pow(2, 32) - 1) >>> 11).toString(2)
4653 // 11111 11111111 11111111
4654 // 0x20000 is 2^21.
4655 v = a[i] * 0x20000 + (a[i + 1] >>> 11);
4656
4657 // Rejection sampling:
4658 // 0 <= v < 9007199254740992
4659 // Probability that v >= 9e15, is
4660 // 7199254740992 / 9007199254740992 ~= 0.0008, i.e. 1 in 1251
4661 if ( v >= 9e15 ) {
4662 b = crypto.getRandomValues( new Uint32Array(2) );
4663 a[i] = b[0];
4664 a[i + 1] = b[1];
4665 } else {
4666
4667 // 0 <= v <= 8999999999999999
4668 // 0 <= (v % 1e14) <= 99999999999999
4669 c.push( v % 1e14 );
4670 i += 2;
4671 }
4672 }
4673 i = k / 2;
4674
4675 // Node.js supporting crypto.randomBytes.
4676 } else if ( crypto && crypto.randomBytes ) {
4677
4678 // buffer
4679 a = crypto.randomBytes( k *= 7 );
4680
4681 for ( ; i < k; ) {
4682
4683 // 0x1000000000000 is 2^48, 0x10000000000 is 2^40
4684 // 0x100000000 is 2^32, 0x1000000 is 2^24
4685 // 11111 11111111 11111111 11111111 11111111 11111111 11111111
4686 // 0 <= v < 9007199254740992
4687 v = ( ( a[i] & 31 ) * 0x1000000000000 ) + ( a[i + 1] * 0x10000000000 ) +
4688 ( a[i + 2] * 0x100000000 ) + ( a[i + 3] * 0x1000000 ) +
4689 ( a[i + 4] << 16 ) + ( a[i + 5] << 8 ) + a[i + 6];
4690
4691 if ( v >= 9e15 ) {
4692 crypto.randomBytes(7).copy( a, i );
4693 } else {
4694
4695 // 0 <= (v % 1e14) <= 99999999999999
4696 c.push( v % 1e14 );
4697 i += 7;
4698 }
4699 }
4700 i = k / 7;
4701 } else if (ERRORS) {
4702 raise( 14, 'crypto unavailable', crypto );
4703 }
4704 }
4705
4706 // Use Math.random: CRYPTO is false or crypto is unavailable and ERRORS is false.
4707 if (!i) {
4708
4709 for ( ; i < k; ) {
4710 v = random53bitInt();
4711 if ( v < 9e15 ) c[i++] = v % 1e14;
4712 }
4713 }
4714
4715 k = c[--i];
4716 dp %= LOG_BASE;
4717
4718 // Convert trailing digits to zeros according to dp.
4719 if ( k && dp ) {
4720 v = POWS_TEN[LOG_BASE - dp];
4721 c[i] = mathfloor( k / v ) * v;
4722 }
4723
4724 // Remove trailing elements which are zero.
4725 for ( ; c[i] === 0; c.pop(), i-- );
4726
4727 // Zero?
4728 if ( i < 0 ) {
4729 c = [ e = 0 ];
4730 } else {
4731
4732 // Remove leading elements which are zero and adjust exponent accordingly.
4733 for ( e = -1 ; c[0] === 0; c.shift(), e -= LOG_BASE);
4734
4735 // Count the digits of the first element of c to determine leading zeros, and...
4736 for ( i = 1, v = c[0]; v >= 10; v /= 10, i++);
4737
4738 // adjust the exponent accordingly.
4739 if ( i < LOG_BASE ) e -= LOG_BASE - i;
4740 }
4741
4742 rand.e = e;
4743 rand.c = c;
4744 return rand;
4745 };
4746 })();
4747
4748
4749 // PRIVATE FUNCTIONS
4750
4751
4752 // Convert a numeric string of baseIn to a numeric string of baseOut.
4753 function convertBase( str, baseOut, baseIn, sign ) {
4754 var d, e, k, r, x, xc, y,
4755 i = str.indexOf( '.' ),
4756 dp = DECIMAL_PLACES,
4757 rm = ROUNDING_MODE;
4758
4759 if ( baseIn < 37 ) str = str.toLowerCase();
4760
4761 // Non-integer.
4762 if ( i >= 0 ) {
4763 k = POW_PRECISION;
4764
4765 // Unlimited precision.
4766 POW_PRECISION = 0;
4767 str = str.replace( '.', '' );
4768 y = new BigNumber(baseIn);
4769 x = y.pow( str.length - i );
4770 POW_PRECISION = k;
4771
4772 // Convert str as if an integer, then restore the fraction part by dividing the
4773 // result by its base raised to a power.
4774 y.c = toBaseOut( toFixedPoint( coeffToString( x.c ), x.e ), 10, baseOut );
4775 y.e = y.c.length;
4776 }
4777
4778 // Convert the number as integer.
4779 xc = toBaseOut( str, baseIn, baseOut );
4780 e = k = xc.length;
4781
4782 // Remove trailing zeros.
4783 for ( ; xc[--k] == 0; xc.pop() );
4784 if ( !xc[0] ) return '0';
4785
4786 if ( i < 0 ) {
4787 --e;
4788 } else {
4789 x.c = xc;
4790 x.e = e;
4791
4792 // sign is needed for correct rounding.
4793 x.s = sign;
4794 x = div( x, y, dp, rm, baseOut );
4795 xc = x.c;
4796 r = x.r;
4797 e = x.e;
4798 }
4799
4800 d = e + dp + 1;
4801
4802 // The rounding digit, i.e. the digit to the right of the digit that may be rounded up.
4803 i = xc[d];
4804 k = baseOut / 2;
4805 r = r || d < 0 || xc[d + 1] != null;
4806
4807 r = rm < 4 ? ( i != null || r ) && ( rm == 0 || rm == ( x.s < 0 ? 3 : 2 ) )
4808 : i > k || i == k &&( rm == 4 || r || rm == 6 && xc[d - 1] & 1 ||
4809 rm == ( x.s < 0 ? 8 : 7 ) );
4810
4811 if ( d < 1 || !xc[0] ) {
4812
4813 // 1^-dp or 0.
4814 str = r ? toFixedPoint( '1', -dp ) : '0';
4815 } else {
4816 xc.length = d;
4817
4818 if (r) {
4819
4820 // Rounding up may mean the previous digit has to be rounded up and so on.
4821 for ( --baseOut; ++xc[--d] > baseOut; ) {
4822 xc[d] = 0;
4823
4824 if ( !d ) {
4825 ++e;
4826 xc.unshift(1);
4827 }
4828 }
4829 }
4830
4831 // Determine trailing zeros.
4832 for ( k = xc.length; !xc[--k]; );
4833
4834 // E.g. [4, 11, 15] becomes 4bf.
4835 for ( i = 0, str = ''; i <= k; str += ALPHABET.charAt( xc[i++] ) );
4836 str = toFixedPoint( str, e );
4837 }
4838
4839 // The caller will add the sign.
4840 return str;
4841 }
4842
4843
4844 // Perform division in the specified base. Called by div and convertBase.
4845 div = (function () {
4846
4847 // Assume non-zero x and k.
4848 function multiply( x, k, base ) {
4849 var m, temp, xlo, xhi,
4850 carry = 0,
4851 i = x.length,
4852 klo = k % SQRT_BASE,
4853 khi = k / SQRT_BASE | 0;
4854
4855 for ( x = x.slice(); i--; ) {
4856 xlo = x[i] % SQRT_BASE;
4857 xhi = x[i] / SQRT_BASE | 0;
4858 m = khi * xlo + xhi * klo;
4859 temp = klo * xlo + ( ( m % SQRT_BASE ) * SQRT_BASE ) + carry;
4860 carry = ( temp / base | 0 ) + ( m / SQRT_BASE | 0 ) + khi * xhi;
4861 x[i] = temp % base;
4862 }
4863
4864 if (carry) x.unshift(carry);
4865
4866 return x;
4867 }
4868
4869 function compare( a, b, aL, bL ) {
4870 var i, cmp;
4871
4872 if ( aL != bL ) {
4873 cmp = aL > bL ? 1 : -1;
4874 } else {
4875
4876 for ( i = cmp = 0; i < aL; i++ ) {
4877
4878 if ( a[i] != b[i] ) {
4879 cmp = a[i] > b[i] ? 1 : -1;
4880 break;
4881 }
4882 }
4883 }
4884 return cmp;
4885 }
4886
4887 function subtract( a, b, aL, base ) {
4888 var i = 0;
4889
4890 // Subtract b from a.
4891 for ( ; aL--; ) {
4892 a[aL] -= i;
4893 i = a[aL] < b[aL] ? 1 : 0;
4894 a[aL] = i * base + a[aL] - b[aL];
4895 }
4896
4897 // Remove leading zeros.
4898 for ( ; !a[0] && a.length > 1; a.shift() );
4899 }
4900
4901 // x: dividend, y: divisor.
4902 return function ( x, y, dp, rm, base ) {
4903 var cmp, e, i, more, n, prod, prodL, q, qc, rem, remL, rem0, xi, xL, yc0,
4904 yL, yz,
4905 s = x.s == y.s ? 1 : -1,
4906 xc = x.c,
4907 yc = y.c;
4908
4909 // Either NaN, Infinity or 0?
4910 if ( !xc || !xc[0] || !yc || !yc[0] ) {
4911
4912 return new BigNumber(
4913
4914 // Return NaN if either NaN, or both Infinity or 0.
4915 !x.s || !y.s || ( xc ? yc && xc[0] == yc[0] : !yc ) ? NaN :
4916
4917 // Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0.
4918 xc && xc[0] == 0 || !yc ? s * 0 : s / 0
4919 );
4920 }
4921
4922 q = new BigNumber(s);
4923 qc = q.c = [];
4924 e = x.e - y.e;
4925 s = dp + e + 1;
4926
4927 if ( !base ) {
4928 base = BASE;
4929 e = bitFloor( x.e / LOG_BASE ) - bitFloor( y.e / LOG_BASE );
4930 s = s / LOG_BASE | 0;
4931 }
4932
4933 // Result exponent may be one less then the current value of e.
4934 // The coefficients of the BigNumbers from convertBase may have trailing zeros.
4935 for ( i = 0; yc[i] == ( xc[i] || 0 ); i++ );
4936 if ( yc[i] > ( xc[i] || 0 ) ) e--;
4937
4938 if ( s < 0 ) {
4939 qc.push(1);
4940 more = true;
4941 } else {
4942 xL = xc.length;
4943 yL = yc.length;
4944 i = 0;
4945 s += 2;
4946
4947 // Normalise xc and yc so highest order digit of yc is >= base / 2.
4948
4949 n = mathfloor( base / ( yc[0] + 1 ) );
4950
4951 // Not necessary, but to handle odd bases where yc[0] == ( base / 2 ) - 1.
4952 // if ( n > 1 || n++ == 1 && yc[0] < base / 2 ) {
4953 if ( n > 1 ) {
4954 yc = multiply( yc, n, base );
4955 xc = multiply( xc, n, base );
4956 yL = yc.length;
4957 xL = xc.length;
4958 }
4959
4960 xi = yL;
4961 rem = xc.slice( 0, yL );
4962 remL = rem.length;
4963
4964 // Add zeros to make remainder as long as divisor.
4965 for ( ; remL < yL; rem[remL++] = 0 );
4966 yz = yc.slice();
4967 yz.unshift(0);
4968 yc0 = yc[0];
4969 if ( yc[1] >= base / 2 ) yc0++;
4970 // Not necessary, but to prevent trial digit n > base, when using base 3.
4971 // else if ( base == 3 && yc0 == 1 ) yc0 = 1 + 1e-15;
4972
4973 do {
4974 n = 0;
4975
4976 // Compare divisor and remainder.
4977 cmp = compare( yc, rem, yL, remL );
4978
4979 // If divisor < remainder.
4980 if ( cmp < 0 ) {
4981
4982 // Calculate trial digit, n.
4983
4984 rem0 = rem[0];
4985 if ( yL != remL ) rem0 = rem0 * base + ( rem[1] || 0 );
4986
4987 // n is how many times the divisor goes into the current remainder.
4988 n = mathfloor( rem0 / yc0 );
4989
4990 // Algorithm:
4991 // 1. product = divisor * trial digit (n)
4992 // 2. if product > remainder: product -= divisor, n--
4993 // 3. remainder -= product
4994 // 4. if product was < remainder at 2:
4995 // 5. compare new remainder and divisor
4996 // 6. If remainder > divisor: remainder -= divisor, n++
4997
4998 if ( n > 1 ) {
4999
5000 // n may be > base only when base is 3.
5001 if (n >= base) n = base - 1;
5002
5003 // product = divisor * trial digit.
5004 prod = multiply( yc, n, base );
5005 prodL = prod.length;
5006 remL = rem.length;
5007
5008 // Compare product and remainder.
5009 // If product > remainder.
5010 // Trial digit n too high.
5011 // n is 1 too high about 5% of the time, and is not known to have
5012 // ever been more than 1 too high.
5013 while ( compare( prod, rem, prodL, remL ) == 1 ) {
5014 n--;
5015
5016 // Subtract divisor from product.
5017 subtract( prod, yL < prodL ? yz : yc, prodL, base );
5018 prodL = prod.length;
5019 cmp = 1;
5020 }
5021 } else {
5022
5023 // n is 0 or 1, cmp is -1.
5024 // If n is 0, there is no need to compare yc and rem again below,
5025 // so change cmp to 1 to avoid it.
5026 // If n is 1, leave cmp as -1, so yc and rem are compared again.
5027 if ( n == 0 ) {
5028
5029 // divisor < remainder, so n must be at least 1.
5030 cmp = n = 1;
5031 }
5032
5033 // product = divisor
5034 prod = yc.slice();
5035 prodL = prod.length;
5036 }
5037
5038 if ( prodL < remL ) prod.unshift(0);
5039
5040 // Subtract product from remainder.
5041 subtract( rem, prod, remL, base );
5042 remL = rem.length;
5043
5044 // If product was < remainder.
5045 if ( cmp == -1 ) {
5046
5047 // Compare divisor and new remainder.
5048 // If divisor < new remainder, subtract divisor from remainder.
5049 // Trial digit n too low.
5050 // n is 1 too low about 5% of the time, and very rarely 2 too low.
5051 while ( compare( yc, rem, yL, remL ) < 1 ) {
5052 n++;
5053
5054 // Subtract divisor from remainder.
5055 subtract( rem, yL < remL ? yz : yc, remL, base );
5056 remL = rem.length;
5057 }
5058 }
5059 } else if ( cmp === 0 ) {
5060 n++;
5061 rem = [0];
5062 } // else cmp === 1 and n will be 0
5063
5064 // Add the next digit, n, to the result array.
5065 qc[i++] = n;
5066
5067 // Update the remainder.
5068 if ( rem[0] ) {
5069 rem[remL++] = xc[xi] || 0;
5070 } else {
5071 rem = [ xc[xi] ];
5072 remL = 1;
5073 }
5074 } while ( ( xi++ < xL || rem[0] != null ) && s-- );
5075
5076 more = rem[0] != null;
5077
5078 // Leading zero?
5079 if ( !qc[0] ) qc.shift();
5080 }
5081
5082 if ( base == BASE ) {
5083
5084 // To calculate q.e, first get the number of digits of qc[0].
5085 for ( i = 1, s = qc[0]; s >= 10; s /= 10, i++ );
5086 round( q, dp + ( q.e = i + e * LOG_BASE - 1 ) + 1, rm, more );
5087
5088 // Caller is convertBase.
5089 } else {
5090 q.e = e;
5091 q.r = +more;
5092 }
5093
5094 return q;
5095 };
5096 })();
5097
5098
5099 /*
5100 * Return a string representing the value of BigNumber n in fixed-point or exponential
5101 * notation rounded to the specified decimal places or significant digits.
5102 *
5103 * n is a BigNumber.
5104 * i is the index of the last digit required (i.e. the digit that may be rounded up).
5105 * rm is the rounding mode.
5106 * caller is caller id: toExponential 19, toFixed 20, toFormat 21, toPrecision 24.
5107 */
5108 function format( n, i, rm, caller ) {
5109 var c0, e, ne, len, str;
5110
5111 rm = rm != null && isValidInt( rm, 0, 8, caller, roundingMode )
5112 ? rm | 0 : ROUNDING_MODE;
5113
5114 if ( !n.c ) return n.toString();
5115 c0 = n.c[0];
5116 ne = n.e;
5117
5118 if ( i == null ) {
5119 str = coeffToString( n.c );
5120 str = caller == 19 || caller == 24 && ne <= TO_EXP_NEG
5121 ? toExponential( str, ne )
5122 : toFixedPoint( str, ne );
5123 } else {
5124 n = round( new BigNumber(n), i, rm );
5125
5126 // n.e may have changed if the value was rounded up.
5127 e = n.e;
5128
5129 str = coeffToString( n.c );
5130 len = str.length;
5131
5132 // toPrecision returns exponential notation if the number of significant digits
5133 // specified is less than the number of digits necessary to represent the integer
5134 // part of the value in fixed-point notation.
5135
5136 // Exponential notation.
5137 if ( caller == 19 || caller == 24 && ( i <= e || e <= TO_EXP_NEG ) ) {
5138
5139 // Append zeros?
5140 for ( ; len < i; str += '0', len++ );
5141 str = toExponential( str, e );
5142
5143 // Fixed-point notation.
5144 } else {
5145 i -= ne;
5146 str = toFixedPoint( str, e );
5147
5148 // Append zeros?
5149 if ( e + 1 > len ) {
5150 if ( --i > 0 ) for ( str += '.'; i--; str += '0' );
5151 } else {
5152 i += e - len;
5153 if ( i > 0 ) {
5154 if ( e + 1 == len ) str += '.';
5155 for ( ; i--; str += '0' );
5156 }
5157 }
5158 }
5159 }
5160
5161 return n.s < 0 && c0 ? '-' + str : str;
5162 }
5163
5164
5165 // Handle BigNumber.max and BigNumber.min.
5166 function maxOrMin( args, method ) {
5167 var m, n,
5168 i = 0;
5169
5170 if ( isArray( args[0] ) ) args = args[0];
5171 m = new BigNumber( args[0] );
5172
5173 for ( ; ++i < args.length; ) {
5174 n = new BigNumber( args[i] );
5175
5176 // If any number is NaN, return NaN.
5177 if ( !n.s ) {
5178 m = n;
5179 break;
5180 } else if ( method.call( m, n ) ) {
5181 m = n;
5182 }
5183 }
5184
5185 return m;
5186 }
5187
5188
5189 /*
5190 * Return true if n is an integer in range, otherwise throw.
5191 * Use for argument validation when ERRORS is true.
5192 */
5193 function intValidatorWithErrors( n, min, max, caller, name ) {
5194 if ( n < min || n > max || n != truncate(n) ) {
5195 raise( caller, ( name || 'decimal places' ) +
5196 ( n < min || n > max ? ' out of range' : ' not an integer' ), n );
5197 }
5198
5199 return true;
5200 }
5201
5202
5203 /*
5204 * Strip trailing zeros, calculate base 10 exponent and check against MIN_EXP and MAX_EXP.
5205 * Called by minus, plus and times.
5206 */
5207 function normalise( n, c, e ) {
5208 var i = 1,
5209 j = c.length;
5210
5211 // Remove trailing zeros.
5212 for ( ; !c[--j]; c.pop() );
5213
5214 // Calculate the base 10 exponent. First get the number of digits of c[0].
5215 for ( j = c[0]; j >= 10; j /= 10, i++ );
5216
5217 // Overflow?
5218 if ( ( e = i + e * LOG_BASE - 1 ) > MAX_EXP ) {
5219
5220 // Infinity.
5221 n.c = n.e = null;
5222
5223 // Underflow?
5224 } else if ( e < MIN_EXP ) {
5225
5226 // Zero.
5227 n.c = [ n.e = 0 ];
5228 } else {
5229 n.e = e;
5230 n.c = c;
5231 }
5232
5233 return n;
5234 }
5235
5236
5237 // Handle values that fail the validity test in BigNumber.
5238 parseNumeric = (function () {
5239 var basePrefix = /^(-?)0([xbo])/i,
5240 dotAfter = /^([^.]+)\.$/,
5241 dotBefore = /^\.([^.]+)$/,
5242 isInfinityOrNaN = /^-?(Infinity|NaN)$/,
5243 whitespaceOrPlus = /^\s*\+|^\s+|\s+$/g;
5244
5245 return function ( x, str, num, b ) {
5246 var base,
5247 s = num ? str : str.replace( whitespaceOrPlus, '' );
5248
5249 // No exception on ±Infinity or NaN.
5250 if ( isInfinityOrNaN.test(s) ) {
5251 x.s = isNaN(s) ? null : s < 0 ? -1 : 1;
5252 } else {
5253 if ( !num ) {
5254
5255 // basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i
5256 s = s.replace( basePrefix, function ( m, p1, p2 ) {
5257 base = ( p2 = p2.toLowerCase() ) == 'x' ? 16 : p2 == 'b' ? 2 : 8;
5258 return !b || b == base ? p1 : m;
5259 });
5260
5261 if (b) {
5262 base = b;
5263
5264 // E.g. '1.' to '1', '.1' to '0.1'
5265 s = s.replace( dotAfter, '$1' ).replace( dotBefore, '0.$1' );
5266 }
5267
5268 if ( str != s ) return new BigNumber( s, base );
5269 }
5270
5271 // 'new BigNumber() not a number: {n}'
5272 // 'new BigNumber() not a base {b} number: {n}'
5273 if (ERRORS) raise( id, 'not a' + ( b ? ' base ' + b : '' ) + ' number', str );
5274 x.s = null;
5275 }
5276
5277 x.c = x.e = null;
5278 id = 0;
5279 }
5280 })();
5281
5282
5283 // Throw a BigNumber Error.
5284 function raise( caller, msg, val ) {
5285 var error = new Error( [
5286 'new BigNumber', // 0
5287 'cmp', // 1
5288 'config', // 2
5289 'div', // 3
5290 'divToInt', // 4
5291 'eq', // 5
5292 'gt', // 6
5293 'gte', // 7
5294 'lt', // 8
5295 'lte', // 9
5296 'minus', // 10
5297 'mod', // 11
5298 'plus', // 12
5299 'precision', // 13
5300 'random', // 14
5301 'round', // 15
5302 'shift', // 16
5303 'times', // 17
5304 'toDigits', // 18
5305 'toExponential', // 19
5306 'toFixed', // 20
5307 'toFormat', // 21
5308 'toFraction', // 22
5309 'pow', // 23
5310 'toPrecision', // 24
5311 'toString', // 25
5312 'BigNumber' // 26
5313 ][caller] + '() ' + msg + ': ' + val );
5314
5315 error.name = 'BigNumber Error';
5316 id = 0;
5317 throw error;
5318 }
5319
5320
5321 /*
5322 * Round x to sd significant digits using rounding mode rm. Check for over/under-flow.
5323 * If r is truthy, it is known that there are more digits after the rounding digit.
5324 */
5325 function round( x, sd, rm, r ) {
5326 var d, i, j, k, n, ni, rd,
5327 xc = x.c,
5328 pows10 = POWS_TEN;
5329
5330 // if x is not Infinity or NaN...
5331 if (xc) {
5332
5333 // rd is the rounding digit, i.e. the digit after the digit that may be rounded up.
5334 // n is a base 1e14 number, the value of the element of array x.c containing rd.
5335 // ni is the index of n within x.c.
5336 // d is the number of digits of n.
5337 // i is the index of rd within n including leading zeros.
5338 // j is the actual index of rd within n (if < 0, rd is a leading zero).
5339 out: {
5340
5341 // Get the number of digits of the first element of xc.
5342 for ( d = 1, k = xc[0]; k >= 10; k /= 10, d++ );
5343 i = sd - d;
5344
5345 // If the rounding digit is in the first element of xc...
5346 if ( i < 0 ) {
5347 i += LOG_BASE;
5348 j = sd;
5349 n = xc[ ni = 0 ];
5350
5351 // Get the rounding digit at index j of n.
5352 rd = n / pows10[ d - j - 1 ] % 10 | 0;
5353 } else {
5354 ni = mathceil( ( i + 1 ) / LOG_BASE );
5355
5356 if ( ni >= xc.length ) {
5357
5358 if (r) {
5359
5360 // Needed by sqrt.
5361 for ( ; xc.length <= ni; xc.push(0) );
5362 n = rd = 0;
5363 d = 1;
5364 i %= LOG_BASE;
5365 j = i - LOG_BASE + 1;
5366 } else {
5367 break out;
5368 }
5369 } else {
5370 n = k = xc[ni];
5371
5372 // Get the number of digits of n.
5373 for ( d = 1; k >= 10; k /= 10, d++ );
5374
5375 // Get the index of rd within n.
5376 i %= LOG_BASE;
5377
5378 // Get the index of rd within n, adjusted for leading zeros.
5379 // The number of leading zeros of n is given by LOG_BASE - d.
5380 j = i - LOG_BASE + d;
5381
5382 // Get the rounding digit at index j of n.
5383 rd = j < 0 ? 0 : n / pows10[ d - j - 1 ] % 10 | 0;
5384 }
5385 }
5386
5387 r = r || sd < 0 ||
5388
5389 // Are there any non-zero digits after the rounding digit?
5390 // The expression n % pows10[ d - j - 1 ] returns all digits of n to the right
5391 // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714.
5392 xc[ni + 1] != null || ( j < 0 ? n : n % pows10[ d - j - 1 ] );
5393
5394 r = rm < 4
5395 ? ( rd || r ) && ( rm == 0 || rm == ( x.s < 0 ? 3 : 2 ) )
5396 : rd > 5 || rd == 5 && ( rm == 4 || r || rm == 6 &&
5397
5398 // Check whether the digit to the left of the rounding digit is odd.
5399 ( ( i > 0 ? j > 0 ? n / pows10[ d - j ] : 0 : xc[ni - 1] ) % 10 ) & 1 ||
5400 rm == ( x.s < 0 ? 8 : 7 ) );
5401
5402 if ( sd < 1 || !xc[0] ) {
5403 xc.length = 0;
5404
5405 if (r) {
5406
5407 // Convert sd to decimal places.
5408 sd -= x.e + 1;
5409
5410 // 1, 0.1, 0.01, 0.001, 0.0001 etc.
5411 xc[0] = pows10[ sd % LOG_BASE ];
5412 x.e = -sd || 0;
5413 } else {
5414
5415 // Zero.
5416 xc[0] = x.e = 0;
5417 }
5418
5419 return x;
5420 }
5421
5422 // Remove excess digits.
5423 if ( i == 0 ) {
5424 xc.length = ni;
5425 k = 1;
5426 ni--;
5427 } else {
5428 xc.length = ni + 1;
5429 k = pows10[ LOG_BASE - i ];
5430
5431 // E.g. 56700 becomes 56000 if 7 is the rounding digit.
5432 // j > 0 means i > number of leading zeros of n.
5433 xc[ni] = j > 0 ? mathfloor( n / pows10[ d - j ] % pows10[j] ) * k : 0;
5434 }
5435
5436 // Round up?
5437 if (r) {
5438
5439 for ( ; ; ) {
5440
5441 // If the digit to be rounded up is in the first element of xc...
5442 if ( ni == 0 ) {
5443
5444 // i will be the length of xc[0] before k is added.
5445 for ( i = 1, j = xc[0]; j >= 10; j /= 10, i++ );
5446 j = xc[0] += k;
5447 for ( k = 1; j >= 10; j /= 10, k++ );
5448
5449 // if i != k the length has increased.
5450 if ( i != k ) {
5451 x.e++;
5452 if ( xc[0] == BASE ) xc[0] = 1;
5453 }
5454
5455 break;
5456 } else {
5457 xc[ni] += k;
5458 if ( xc[ni] != BASE ) break;
5459 xc[ni--] = 0;
5460 k = 1;
5461 }
5462 }
5463 }
5464
5465 // Remove trailing zeros.
5466 for ( i = xc.length; xc[--i] === 0; xc.pop() );
5467 }
5468
5469 // Overflow? Infinity.
5470 if ( x.e > MAX_EXP ) {
5471 x.c = x.e = null;
5472
5473 // Underflow? Zero.
5474 } else if ( x.e < MIN_EXP ) {
5475 x.c = [ x.e = 0 ];
5476 }
5477 }
5478
5479 return x;
5480 }
5481
5482
5483 // PROTOTYPE/INSTANCE METHODS
5484
5485
5486 /*
5487 * Return a new BigNumber whose value is the absolute value of this BigNumber.
5488 */
5489 P.absoluteValue = P.abs = function () {
5490 var x = new BigNumber(this);
5491 if ( x.s < 0 ) x.s = 1;
5492 return x;
5493 };
5494
5495
5496 /*
5497 * Return a new BigNumber whose value is the value of this BigNumber rounded to a whole
5498 * number in the direction of Infinity.
5499 */
5500 P.ceil = function () {
5501 return round( new BigNumber(this), this.e + 1, 2 );
5502 };
5503
5504
5505 /*
5506 * Return
5507 * 1 if the value of this BigNumber is greater than the value of BigNumber(y, b),
5508 * -1 if the value of this BigNumber is less than the value of BigNumber(y, b),
5509 * 0 if they have the same value,
5510 * or null if the value of either is NaN.
5511 */
5512 P.comparedTo = P.cmp = function ( y, b ) {
5513 id = 1;
5514 return compare( this, new BigNumber( y, b ) );
5515 };
5516
5517
5518 /*
5519 * Return the number of decimal places of the value of this BigNumber, or null if the value
5520 * of this BigNumber is ±Infinity or NaN.
5521 */
5522 P.decimalPlaces = P.dp = function () {
5523 var n, v,
5524 c = this.c;
5525
5526 if ( !c ) return null;
5527 n = ( ( v = c.length - 1 ) - bitFloor( this.e / LOG_BASE ) ) * LOG_BASE;
5528
5529 // Subtract the number of trailing zeros of the last number.
5530 if ( v = c[v] ) for ( ; v % 10 == 0; v /= 10, n-- );
5531 if ( n < 0 ) n = 0;
5532
5533 return n;
5534 };
5535
5536
5537 /*
5538 * n / 0 = I
5539 * n / N = N
5540 * n / I = 0
5541 * 0 / n = 0
5542 * 0 / 0 = N
5543 * 0 / N = N
5544 * 0 / I = 0
5545 * N / n = N
5546 * N / 0 = N
5547 * N / N = N
5548 * N / I = N
5549 * I / n = I
5550 * I / 0 = I
5551 * I / N = N
5552 * I / I = N
5553 *
5554 * Return a new BigNumber whose value is the value of this BigNumber divided by the value of
5555 * BigNumber(y, b), rounded according to DECIMAL_PLACES and ROUNDING_MODE.
5556 */
5557 P.dividedBy = P.div = function ( y, b ) {
5558 id = 3;
5559 return div( this, new BigNumber( y, b ), DECIMAL_PLACES, ROUNDING_MODE );
5560 };
5561
5562
5563 /*
5564 * Return a new BigNumber whose value is the integer part of dividing the value of this
5565 * BigNumber by the value of BigNumber(y, b).
5566 */
5567 P.dividedToIntegerBy = P.divToInt = function ( y, b ) {
5568 id = 4;
5569 return div( this, new BigNumber( y, b ), 0, 1 );
5570 };
5571
5572
5573 /*
5574 * Return true if the value of this BigNumber is equal to the value of BigNumber(y, b),
5575 * otherwise returns false.
5576 */
5577 P.equals = P.eq = function ( y, b ) {
5578 id = 5;
5579 return compare( this, new BigNumber( y, b ) ) === 0;
5580 };
5581
5582
5583 /*
5584 * Return a new BigNumber whose value is the value of this BigNumber rounded to a whole
5585 * number in the direction of -Infinity.
5586 */
5587 P.floor = function () {
5588 return round( new BigNumber(this), this.e + 1, 3 );
5589 };
5590
5591
5592 /*
5593 * Return true if the value of this BigNumber is greater than the value of BigNumber(y, b),
5594 * otherwise returns false.
5595 */
5596 P.greaterThan = P.gt = function ( y, b ) {
5597 id = 6;
5598 return compare( this, new BigNumber( y, b ) ) > 0;
5599 };
5600
5601
5602 /*
5603 * Return true if the value of this BigNumber is greater than or equal to the value of
5604 * BigNumber(y, b), otherwise returns false.
5605 */
5606 P.greaterThanOrEqualTo = P.gte = function ( y, b ) {
5607 id = 7;
5608 return ( b = compare( this, new BigNumber( y, b ) ) ) === 1 || b === 0;
5609
5610 };
5611
5612
5613 /*
5614 * Return true if the value of this BigNumber is a finite number, otherwise returns false.
5615 */
5616 P.isFinite = function () {
5617 return !!this.c;
5618 };
5619
5620
5621 /*
5622 * Return true if the value of this BigNumber is an integer, otherwise return false.
5623 */
5624 P.isInteger = P.isInt = function () {
5625 return !!this.c && bitFloor( this.e / LOG_BASE ) > this.c.length - 2;
5626 };
5627
5628
5629 /*
5630 * Return true if the value of this BigNumber is NaN, otherwise returns false.
5631 */
5632 P.isNaN = function () {
5633 return !this.s;
5634 };
5635
5636
5637 /*
5638 * Return true if the value of this BigNumber is negative, otherwise returns false.
5639 */
5640 P.isNegative = P.isNeg = function () {
5641 return this.s < 0;
5642 };
5643
5644
5645 /*
5646 * Return true if the value of this BigNumber is 0 or -0, otherwise returns false.
5647 */
5648 P.isZero = function () {
5649 return !!this.c && this.c[0] == 0;
5650 };
5651
5652
5653 /*
5654 * Return true if the value of this BigNumber is less than the value of BigNumber(y, b),
5655 * otherwise returns false.
5656 */
5657 P.lessThan = P.lt = function ( y, b ) {
5658 id = 8;
5659 return compare( this, new BigNumber( y, b ) ) < 0;
5660 };
5661
5662
5663 /*
5664 * Return true if the value of this BigNumber is less than or equal to the value of
5665 * BigNumber(y, b), otherwise returns false.
5666 */
5667 P.lessThanOrEqualTo = P.lte = function ( y, b ) {
5668 id = 9;
5669 return ( b = compare( this, new BigNumber( y, b ) ) ) === -1 || b === 0;
5670 };
5671
5672
5673 /*
5674 * n - 0 = n
5675 * n - N = N
5676 * n - I = -I
5677 * 0 - n = -n
5678 * 0 - 0 = 0
5679 * 0 - N = N
5680 * 0 - I = -I
5681 * N - n = N
5682 * N - 0 = N
5683 * N - N = N
5684 * N - I = N
5685 * I - n = I
5686 * I - 0 = I
5687 * I - N = N
5688 * I - I = N
5689 *
5690 * Return a new BigNumber whose value is the value of this BigNumber minus the value of
5691 * BigNumber(y, b).
5692 */
5693 P.minus = P.sub = function ( y, b ) {
5694 var i, j, t, xLTy,
5695 x = this,
5696 a = x.s;
5697
5698 id = 10;
5699 y = new BigNumber( y, b );
5700 b = y.s;
5701
5702 // Either NaN?
5703 if ( !a || !b ) return new BigNumber(NaN);
5704
5705 // Signs differ?
5706 if ( a != b ) {
5707 y.s = -b;
5708 return x.plus(y);
5709 }
5710
5711 var xe = x.e / LOG_BASE,
5712 ye = y.e / LOG_BASE,
5713 xc = x.c,
5714 yc = y.c;
5715
5716 if ( !xe || !ye ) {
5717
5718 // Either Infinity?
5719 if ( !xc || !yc ) return xc ? ( y.s = -b, y ) : new BigNumber( yc ? x : NaN );
5720
5721 // Either zero?
5722 if ( !xc[0] || !yc[0] ) {
5723
5724 // Return y if y is non-zero, x if x is non-zero, or zero if both are zero.
5725 return yc[0] ? ( y.s = -b, y ) : new BigNumber( xc[0] ? x :
5726
5727 // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity
5728 ROUNDING_MODE == 3 ? -0 : 0 );
5729 }
5730 }
5731
5732 xe = bitFloor(xe);
5733 ye = bitFloor(ye);
5734 xc = xc.slice();
5735
5736 // Determine which is the bigger number.
5737 if ( a = xe - ye ) {
5738
5739 if ( xLTy = a < 0 ) {
5740 a = -a;
5741 t = xc;
5742 } else {
5743 ye = xe;
5744 t = yc;
5745 }
5746
5747 t.reverse();
5748
5749 // Prepend zeros to equalise exponents.
5750 for ( b = a; b--; t.push(0) );
5751 t.reverse();
5752 } else {
5753
5754 // Exponents equal. Check digit by digit.
5755 j = ( xLTy = ( a = xc.length ) < ( b = yc.length ) ) ? a : b;
5756
5757 for ( a = b = 0; b < j; b++ ) {
5758
5759 if ( xc[b] != yc[b] ) {
5760 xLTy = xc[b] < yc[b];
5761 break;
5762 }
5763 }
5764 }
5765
5766 // x < y? Point xc to the array of the bigger number.
5767 if (xLTy) t = xc, xc = yc, yc = t, y.s = -y.s;
5768
5769 b = ( j = yc.length ) - ( i = xc.length );
5770
5771 // Append zeros to xc if shorter.
5772 // No need to add zeros to yc if shorter as subtract only needs to start at yc.length.
5773 if ( b > 0 ) for ( ; b--; xc[i++] = 0 );
5774 b = BASE - 1;
5775
5776 // Subtract yc from xc.
5777 for ( ; j > a; ) {
5778
5779 if ( xc[--j] < yc[j] ) {
5780 for ( i = j; i && !xc[--i]; xc[i] = b );
5781 --xc[i];
5782 xc[j] += BASE;
5783 }
5784
5785 xc[j] -= yc[j];
5786 }
5787
5788 // Remove leading zeros and adjust exponent accordingly.
5789 for ( ; xc[0] == 0; xc.shift(), --ye );
5790
5791 // Zero?
5792 if ( !xc[0] ) {
5793
5794 // Following IEEE 754 (2008) 6.3,
5795 // n - n = +0 but n - n = -0 when rounding towards -Infinity.
5796 y.s = ROUNDING_MODE == 3 ? -1 : 1;
5797 y.c = [ y.e = 0 ];
5798 return y;
5799 }
5800
5801 // No need to check for Infinity as +x - +y != Infinity && -x - -y != Infinity
5802 // for finite x and y.
5803 return normalise( y, xc, ye );
5804 };
5805
5806
5807 /*
5808 * n % 0 = N
5809 * n % N = N
5810 * n % I = n
5811 * 0 % n = 0
5812 * -0 % n = -0
5813 * 0 % 0 = N
5814 * 0 % N = N
5815 * 0 % I = 0
5816 * N % n = N
5817 * N % 0 = N
5818 * N % N = N
5819 * N % I = N
5820 * I % n = N
5821 * I % 0 = N
5822 * I % N = N
5823 * I % I = N
5824 *
5825 * Return a new BigNumber whose value is the value of this BigNumber modulo the value of
5826 * BigNumber(y, b). The result depends on the value of MODULO_MODE.
5827 */
5828 P.modulo = P.mod = function ( y, b ) {
5829 var q, s,
5830 x = this;
5831
5832 id = 11;
5833 y = new BigNumber( y, b );
5834
5835 // Return NaN if x is Infinity or NaN, or y is NaN or zero.
5836 if ( !x.c || !y.s || y.c && !y.c[0] ) {
5837 return new BigNumber(NaN);
5838
5839 // Return x if y is Infinity or x is zero.
5840 } else if ( !y.c || x.c && !x.c[0] ) {
5841 return new BigNumber(x);
5842 }
5843
5844 if ( MODULO_MODE == 9 ) {
5845
5846 // Euclidian division: q = sign(y) * floor(x / abs(y))
5847 // r = x - qy where 0 <= r < abs(y)
5848 s = y.s;
5849 y.s = 1;
5850 q = div( x, y, 0, 3 );
5851 y.s = s;
5852 q.s *= s;
5853 } else {
5854 q = div( x, y, 0, MODULO_MODE );
5855 }
5856
5857 return x.minus( q.times(y) );
5858 };
5859
5860
5861 /*
5862 * Return a new BigNumber whose value is the value of this BigNumber negated,
5863 * i.e. multiplied by -1.
5864 */
5865 P.negated = P.neg = function () {
5866 var x = new BigNumber(this);
5867 x.s = -x.s || null;
5868 return x;
5869 };
5870
5871
5872 /*
5873 * n + 0 = n
5874 * n + N = N
5875 * n + I = I
5876 * 0 + n = n
5877 * 0 + 0 = 0
5878 * 0 + N = N
5879 * 0 + I = I
5880 * N + n = N
5881 * N + 0 = N
5882 * N + N = N
5883 * N + I = N
5884 * I + n = I
5885 * I + 0 = I
5886 * I + N = N
5887 * I + I = I
5888 *
5889 * Return a new BigNumber whose value is the value of this BigNumber plus the value of
5890 * BigNumber(y, b).
5891 */
5892 P.plus = P.add = function ( y, b ) {
5893 var t,
5894 x = this,
5895 a = x.s;
5896
5897 id = 12;
5898 y = new BigNumber( y, b );
5899 b = y.s;
5900
5901 // Either NaN?
5902 if ( !a || !b ) return new BigNumber(NaN);
5903
5904 // Signs differ?
5905 if ( a != b ) {
5906 y.s = -b;
5907 return x.minus(y);
5908 }
5909
5910 var xe = x.e / LOG_BASE,
5911 ye = y.e / LOG_BASE,
5912 xc = x.c,
5913 yc = y.c;
5914
5915 if ( !xe || !ye ) {
5916
5917 // Return ±Infinity if either ±Infinity.
5918 if ( !xc || !yc ) return new BigNumber( a / 0 );
5919
5920 // Either zero?
5921 // Return y if y is non-zero, x if x is non-zero, or zero if both are zero.
5922 if ( !xc[0] || !yc[0] ) return yc[0] ? y : new BigNumber( xc[0] ? x : a * 0 );
5923 }
5924
5925 xe = bitFloor(xe);
5926 ye = bitFloor(ye);
5927 xc = xc.slice();
5928
5929 // Prepend zeros to equalise exponents. Faster to use reverse then do unshifts.
5930 if ( a = xe - ye ) {
5931 if ( a > 0 ) {
5932 ye = xe;
5933 t = yc;
5934 } else {
5935 a = -a;
5936 t = xc;
5937 }
5938
5939 t.reverse();
5940 for ( ; a--; t.push(0) );
5941 t.reverse();
5942 }
5943
5944 a = xc.length;
5945 b = yc.length;
5946
5947 // Point xc to the longer array, and b to the shorter length.
5948 if ( a - b < 0 ) t = yc, yc = xc, xc = t, b = a;
5949
5950 // Only start adding at yc.length - 1 as the further digits of xc can be ignored.
5951 for ( a = 0; b; ) {
5952 a = ( xc[--b] = xc[b] + yc[b] + a ) / BASE | 0;
5953 xc[b] %= BASE;
5954 }
5955
5956 if (a) {
5957 xc.unshift(a);
5958 ++ye;
5959 }
5960
5961 // No need to check for zero, as +x + +y != 0 && -x + -y != 0
5962 // ye = MAX_EXP + 1 possible
5963 return normalise( y, xc, ye );
5964 };
5965
5966
5967 /*
5968 * Return the number of significant digits of the value of this BigNumber.
5969 *
5970 * [z] {boolean|number} Whether to count integer-part trailing zeros: true, false, 1 or 0.
5971 */
5972 P.precision = P.sd = function (z) {
5973 var n, v,
5974 x = this,
5975 c = x.c;
5976
5977 // 'precision() argument not a boolean or binary digit: {z}'
5978 if ( z != null && z !== !!z && z !== 1 && z !== 0 ) {
5979 if (ERRORS) raise( 13, 'argument' + notBool, z );
5980 if ( z != !!z ) z = null;
5981 }
5982
5983 if ( !c ) return null;
5984 v = c.length - 1;
5985 n = v * LOG_BASE + 1;
5986
5987 if ( v = c[v] ) {
5988
5989 // Subtract the number of trailing zeros of the last element.
5990 for ( ; v % 10 == 0; v /= 10, n-- );
5991
5992 // Add the number of digits of the first element.
5993 for ( v = c[0]; v >= 10; v /= 10, n++ );
5994 }
5995
5996 if ( z && x.e + 1 > n ) n = x.e + 1;
5997
5998 return n;
5999 };
6000
6001
6002 /*
6003 * Return a new BigNumber whose value is the value of this BigNumber rounded to a maximum of
6004 * dp decimal places using rounding mode rm, or to 0 and ROUNDING_MODE respectively if
6005 * omitted.
6006 *
6007 * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
6008 * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
6009 *
6010 * 'round() decimal places out of range: {dp}'
6011 * 'round() decimal places not an integer: {dp}'
6012 * 'round() rounding mode not an integer: {rm}'
6013 * 'round() rounding mode out of range: {rm}'
6014 */
6015 P.round = function ( dp, rm ) {
6016 var n = new BigNumber(this);
6017
6018 if ( dp == null || isValidInt( dp, 0, MAX, 15 ) ) {
6019 round( n, ~~dp + this.e + 1, rm == null ||
6020 !isValidInt( rm, 0, 8, 15, roundingMode ) ? ROUNDING_MODE : rm | 0 );
6021 }
6022
6023 return n;
6024 };
6025
6026
6027 /*
6028 * Return a new BigNumber whose value is the value of this BigNumber shifted by k places
6029 * (powers of 10). Shift to the right if n > 0, and to the left if n < 0.
6030 *
6031 * k {number} Integer, -MAX_SAFE_INTEGER to MAX_SAFE_INTEGER inclusive.
6032 *
6033 * If k is out of range and ERRORS is false, the result will be ±0 if k < 0, or ±Infinity
6034 * otherwise.
6035 *
6036 * 'shift() argument not an integer: {k}'
6037 * 'shift() argument out of range: {k}'
6038 */
6039 P.shift = function (k) {
6040 var n = this;
6041 return isValidInt( k, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER, 16, 'argument' )
6042
6043 // k < 1e+21, or truncate(k) will produce exponential notation.
6044 ? n.times( '1e' + truncate(k) )
6045 : new BigNumber( n.c && n.c[0] && ( k < -MAX_SAFE_INTEGER || k > MAX_SAFE_INTEGER )
6046 ? n.s * ( k < 0 ? 0 : 1 / 0 )
6047 : n );
6048 };
6049
6050
6051 /*
6052 * sqrt(-n) = N
6053 * sqrt( N) = N
6054 * sqrt(-I) = N
6055 * sqrt( I) = I
6056 * sqrt( 0) = 0
6057 * sqrt(-0) = -0
6058 *
6059 * Return a new BigNumber whose value is the square root of the value of this BigNumber,
6060 * rounded according to DECIMAL_PLACES and ROUNDING_MODE.
6061 */
6062 P.squareRoot = P.sqrt = function () {
6063 var m, n, r, rep, t,
6064 x = this,
6065 c = x.c,
6066 s = x.s,
6067 e = x.e,
6068 dp = DECIMAL_PLACES + 4,
6069 half = new BigNumber('0.5');
6070
6071 // Negative/NaN/Infinity/zero?
6072 if ( s !== 1 || !c || !c[0] ) {
6073 return new BigNumber( !s || s < 0 && ( !c || c[0] ) ? NaN : c ? x : 1 / 0 );
6074 }
6075
6076 // Initial estimate.
6077 s = Math.sqrt( +x );
6078
6079 // Math.sqrt underflow/overflow?
6080 // Pass x to Math.sqrt as integer, then adjust the exponent of the result.
6081 if ( s == 0 || s == 1 / 0 ) {
6082 n = coeffToString(c);
6083 if ( ( n.length + e ) % 2 == 0 ) n += '0';
6084 s = Math.sqrt(n);
6085 e = bitFloor( ( e + 1 ) / 2 ) - ( e < 0 || e % 2 );
6086
6087 if ( s == 1 / 0 ) {
6088 n = '1e' + e;
6089 } else {
6090 n = s.toExponential();
6091 n = n.slice( 0, n.indexOf('e') + 1 ) + e;
6092 }
6093
6094 r = new BigNumber(n);
6095 } else {
6096 r = new BigNumber( s + '' );
6097 }
6098
6099 // Check for zero.
6100 // r could be zero if MIN_EXP is changed after the this value was created.
6101 // This would cause a division by zero (x/t) and hence Infinity below, which would cause
6102 // coeffToString to throw.
6103 if ( r.c[0] ) {
6104 e = r.e;
6105 s = e + dp;
6106 if ( s < 3 ) s = 0;
6107
6108 // Newton-Raphson iteration.
6109 for ( ; ; ) {
6110 t = r;
6111 r = half.times( t.plus( div( x, t, dp, 1 ) ) );
6112
6113 if ( coeffToString( t.c ).slice( 0, s ) === ( n =
6114 coeffToString( r.c ) ).slice( 0, s ) ) {
6115
6116 // The exponent of r may here be one less than the final result exponent,
6117 // e.g 0.0009999 (e-4) --> 0.001 (e-3), so adjust s so the rounding digits
6118 // are indexed correctly.
6119 if ( r.e < e ) --s;
6120 n = n.slice( s - 3, s + 1 );
6121
6122 // The 4th rounding digit may be in error by -1 so if the 4 rounding digits
6123 // are 9999 or 4999 (i.e. approaching a rounding boundary) continue the
6124 // iteration.
6125 if ( n == '9999' || !rep && n == '4999' ) {
6126
6127 // On the first iteration only, check to see if rounding up gives the
6128 // exact result as the nines may infinitely repeat.
6129 if ( !rep ) {
6130 round( t, t.e + DECIMAL_PLACES + 2, 0 );
6131
6132 if ( t.times(t).eq(x) ) {
6133 r = t;
6134 break;
6135 }
6136 }
6137
6138 dp += 4;
6139 s += 4;
6140 rep = 1;
6141 } else {
6142
6143 // If rounding digits are null, 0{0,4} or 50{0,3}, check for exact
6144 // result. If not, then there are further digits and m will be truthy.
6145 if ( !+n || !+n.slice(1) && n.charAt(0) == '5' ) {
6146
6147 // Truncate to the first rounding digit.
6148 round( r, r.e + DECIMAL_PLACES + 2, 1 );
6149 m = !r.times(r).eq(x);
6150 }
6151
6152 break;
6153 }
6154 }
6155 }
6156 }
6157
6158 return round( r, r.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m );
6159 };
6160
6161
6162 /*
6163 * n * 0 = 0
6164 * n * N = N
6165 * n * I = I
6166 * 0 * n = 0
6167 * 0 * 0 = 0
6168 * 0 * N = N
6169 * 0 * I = N
6170 * N * n = N
6171 * N * 0 = N
6172 * N * N = N
6173 * N * I = N
6174 * I * n = I
6175 * I * 0 = N
6176 * I * N = N
6177 * I * I = I
6178 *
6179 * Return a new BigNumber whose value is the value of this BigNumber times the value of
6180 * BigNumber(y, b).
6181 */
6182 P.times = P.mul = function ( y, b ) {
6183 var c, e, i, j, k, m, xcL, xlo, xhi, ycL, ylo, yhi, zc,
6184 base, sqrtBase,
6185 x = this,
6186 xc = x.c,
6187 yc = ( id = 17, y = new BigNumber( y, b ) ).c;
6188
6189 // Either NaN, ±Infinity or ±0?
6190 if ( !xc || !yc || !xc[0] || !yc[0] ) {
6191
6192 // Return NaN if either is NaN, or one is 0 and the other is Infinity.
6193 if ( !x.s || !y.s || xc && !xc[0] && !yc || yc && !yc[0] && !xc ) {
6194 y.c = y.e = y.s = null;
6195 } else {
6196 y.s *= x.s;
6197
6198 // Return ±Infinity if either is ±Infinity.
6199 if ( !xc || !yc ) {
6200 y.c = y.e = null;
6201
6202 // Return ±0 if either is ±0.
6203 } else {
6204 y.c = [0];
6205 y.e = 0;
6206 }
6207 }
6208
6209 return y;
6210 }
6211
6212 e = bitFloor( x.e / LOG_BASE ) + bitFloor( y.e / LOG_BASE );
6213 y.s *= x.s;
6214 xcL = xc.length;
6215 ycL = yc.length;
6216
6217 // Ensure xc points to longer array and xcL to its length.
6218 if ( xcL < ycL ) zc = xc, xc = yc, yc = zc, i = xcL, xcL = ycL, ycL = i;
6219
6220 // Initialise the result array with zeros.
6221 for ( i = xcL + ycL, zc = []; i--; zc.push(0) );
6222
6223 base = BASE;
6224 sqrtBase = SQRT_BASE;
6225
6226 for ( i = ycL; --i >= 0; ) {
6227 c = 0;
6228 ylo = yc[i] % sqrtBase;
6229 yhi = yc[i] / sqrtBase | 0;
6230
6231 for ( k = xcL, j = i + k; j > i; ) {
6232 xlo = xc[--k] % sqrtBase;
6233 xhi = xc[k] / sqrtBase | 0;
6234 m = yhi * xlo + xhi * ylo;
6235 xlo = ylo * xlo + ( ( m % sqrtBase ) * sqrtBase ) + zc[j] + c;
6236 c = ( xlo / base | 0 ) + ( m / sqrtBase | 0 ) + yhi * xhi;
6237 zc[j--] = xlo % base;
6238 }
6239
6240 zc[j] = c;
6241 }
6242
6243 if (c) {
6244 ++e;
6245 } else {
6246 zc.shift();
6247 }
6248
6249 return normalise( y, zc, e );
6250 };
6251
6252
6253 /*
6254 * Return a new BigNumber whose value is the value of this BigNumber rounded to a maximum of
6255 * sd significant digits using rounding mode rm, or ROUNDING_MODE if rm is omitted.
6256 *
6257 * [sd] {number} Significant digits. Integer, 1 to MAX inclusive.
6258 * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
6259 *
6260 * 'toDigits() precision out of range: {sd}'
6261 * 'toDigits() precision not an integer: {sd}'
6262 * 'toDigits() rounding mode not an integer: {rm}'
6263 * 'toDigits() rounding mode out of range: {rm}'
6264 */
6265 P.toDigits = function ( sd, rm ) {
6266 var n = new BigNumber(this);
6267 sd = sd == null || !isValidInt( sd, 1, MAX, 18, 'precision' ) ? null : sd | 0;
6268 rm = rm == null || !isValidInt( rm, 0, 8, 18, roundingMode ) ? ROUNDING_MODE : rm | 0;
6269 return sd ? round( n, sd, rm ) : n;
6270 };
6271
6272
6273 /*
6274 * Return a string representing the value of this BigNumber in exponential notation and
6275 * rounded using ROUNDING_MODE to dp fixed decimal places.
6276 *
6277 * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
6278 * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
6279 *
6280 * 'toExponential() decimal places not an integer: {dp}'
6281 * 'toExponential() decimal places out of range: {dp}'
6282 * 'toExponential() rounding mode not an integer: {rm}'
6283 * 'toExponential() rounding mode out of range: {rm}'
6284 */
6285 P.toExponential = function ( dp, rm ) {
6286 return format( this,
6287 dp != null && isValidInt( dp, 0, MAX, 19 ) ? ~~dp + 1 : null, rm, 19 );
6288 };
6289
6290
6291 /*
6292 * Return a string representing the value of this BigNumber in fixed-point notation rounding
6293 * to dp fixed decimal places using rounding mode rm, or ROUNDING_MODE if rm is omitted.
6294 *
6295 * Note: as with JavaScript's number type, (-0).toFixed(0) is '0',
6296 * but e.g. (-0.00001).toFixed(0) is '-0'.
6297 *
6298 * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
6299 * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
6300 *
6301 * 'toFixed() decimal places not an integer: {dp}'
6302 * 'toFixed() decimal places out of range: {dp}'
6303 * 'toFixed() rounding mode not an integer: {rm}'
6304 * 'toFixed() rounding mode out of range: {rm}'
6305 */
6306 P.toFixed = function ( dp, rm ) {
6307 return format( this, dp != null && isValidInt( dp, 0, MAX, 20 )
6308 ? ~~dp + this.e + 1 : null, rm, 20 );
6309 };
6310
6311
6312 /*
6313 * Return a string representing the value of this BigNumber in fixed-point notation rounded
6314 * using rm or ROUNDING_MODE to dp decimal places, and formatted according to the properties
6315 * of the FORMAT object (see BigNumber.config).
6316 *
6317 * FORMAT = {
6318 * decimalSeparator : '.',
6319 * groupSeparator : ',',
6320 * groupSize : 3,
6321 * secondaryGroupSize : 0,
6322 * fractionGroupSeparator : '\xA0', // non-breaking space
6323 * fractionGroupSize : 0
6324 * };
6325 *
6326 * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
6327 * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
6328 *
6329 * 'toFormat() decimal places not an integer: {dp}'
6330 * 'toFormat() decimal places out of range: {dp}'
6331 * 'toFormat() rounding mode not an integer: {rm}'
6332 * 'toFormat() rounding mode out of range: {rm}'
6333 */
6334 P.toFormat = function ( dp, rm ) {
6335 var str = format( this, dp != null && isValidInt( dp, 0, MAX, 21 )
6336 ? ~~dp + this.e + 1 : null, rm, 21 );
6337
6338 if ( this.c ) {
6339 var i,
6340 arr = str.split('.'),
6341 g1 = +FORMAT.groupSize,
6342 g2 = +FORMAT.secondaryGroupSize,
6343 groupSeparator = FORMAT.groupSeparator,
6344 intPart = arr[0],
6345 fractionPart = arr[1],
6346 isNeg = this.s < 0,
6347 intDigits = isNeg ? intPart.slice(1) : intPart,
6348 len = intDigits.length;
6349
6350 if (g2) i = g1, g1 = g2, g2 = i, len -= i;
6351
6352 if ( g1 > 0 && len > 0 ) {
6353 i = len % g1 || g1;
6354 intPart = intDigits.substr( 0, i );
6355
6356 for ( ; i < len; i += g1 ) {
6357 intPart += groupSeparator + intDigits.substr( i, g1 );
6358 }
6359
6360 if ( g2 > 0 ) intPart += groupSeparator + intDigits.slice(i);
6361 if (isNeg) intPart = '-' + intPart;
6362 }
6363
6364 str = fractionPart
6365 ? intPart + FORMAT.decimalSeparator + ( ( g2 = +FORMAT.fractionGroupSize )
6366 ? fractionPart.replace( new RegExp( '\\d{' + g2 + '}\\B', 'g' ),
6367 '$&' + FORMAT.fractionGroupSeparator )
6368 : fractionPart )
6369 : intPart;
6370 }
6371
6372 return str;
6373 };
6374
6375
6376 /*
6377 * Return a string array representing the value of this BigNumber as a simple fraction with
6378 * an integer numerator and an integer denominator. The denominator will be a positive
6379 * non-zero value less than or equal to the specified maximum denominator. If a maximum
6380 * denominator is not specified, the denominator will be the lowest value necessary to
6381 * represent the number exactly.
6382 *
6383 * [md] {number|string|BigNumber} Integer >= 1 and < Infinity. The maximum denominator.
6384 *
6385 * 'toFraction() max denominator not an integer: {md}'
6386 * 'toFraction() max denominator out of range: {md}'
6387 */
6388 P.toFraction = function (md) {
6389 var arr, d0, d2, e, exp, n, n0, q, s,
6390 k = ERRORS,
6391 x = this,
6392 xc = x.c,
6393 d = new BigNumber(ONE),
6394 n1 = d0 = new BigNumber(ONE),
6395 d1 = n0 = new BigNumber(ONE);
6396
6397 if ( md != null ) {
6398 ERRORS = false;
6399 n = new BigNumber(md);
6400 ERRORS = k;
6401
6402 if ( !( k = n.isInt() ) || n.lt(ONE) ) {
6403
6404 if (ERRORS) {
6405 raise( 22,
6406 'max denominator ' + ( k ? 'out of range' : 'not an integer' ), md );
6407 }
6408
6409 // ERRORS is false:
6410 // If md is a finite non-integer >= 1, round it to an integer and use it.
6411 md = !k && n.c && round( n, n.e + 1, 1 ).gte(ONE) ? n : null;
6412 }
6413 }
6414
6415 if ( !xc ) return x.toString();
6416 s = coeffToString(xc);
6417
6418 // Determine initial denominator.
6419 // d is a power of 10 and the minimum max denominator that specifies the value exactly.
6420 e = d.e = s.length - x.e - 1;
6421 d.c[0] = POWS_TEN[ ( exp = e % LOG_BASE ) < 0 ? LOG_BASE + exp : exp ];
6422 md = !md || n.cmp(d) > 0 ? ( e > 0 ? d : n1 ) : n;
6423
6424 exp = MAX_EXP;
6425 MAX_EXP = 1 / 0;
6426 n = new BigNumber(s);
6427
6428 // n0 = d1 = 0
6429 n0.c[0] = 0;
6430
6431 for ( ; ; ) {
6432 q = div( n, d, 0, 1 );
6433 d2 = d0.plus( q.times(d1) );
6434 if ( d2.cmp(md) == 1 ) break;
6435 d0 = d1;
6436 d1 = d2;
6437 n1 = n0.plus( q.times( d2 = n1 ) );
6438 n0 = d2;
6439 d = n.minus( q.times( d2 = d ) );
6440 n = d2;
6441 }
6442
6443 d2 = div( md.minus(d0), d1, 0, 1 );
6444 n0 = n0.plus( d2.times(n1) );
6445 d0 = d0.plus( d2.times(d1) );
6446 n0.s = n1.s = x.s;
6447 e *= 2;
6448
6449 // Determine which fraction is closer to x, n0/d0 or n1/d1
6450 arr = div( n1, d1, e, ROUNDING_MODE ).minus(x).abs().cmp(
6451 div( n0, d0, e, ROUNDING_MODE ).minus(x).abs() ) < 1
6452 ? [ n1.toString(), d1.toString() ]
6453 : [ n0.toString(), d0.toString() ];
6454
6455 MAX_EXP = exp;
6456 return arr;
6457 };
6458
6459
6460 /*
6461 * Return the value of this BigNumber converted to a number primitive.
6462 */
6463 P.toNumber = function () {
6464 var x = this;
6465
6466 // Ensure zero has correct sign.
6467 return +x || ( x.s ? x.s * 0 : NaN );
6468 };
6469
6470
6471 /*
6472 * Return a BigNumber whose value is the value of this BigNumber raised to the power n.
6473 * If n is negative round according to DECIMAL_PLACES and ROUNDING_MODE.
6474 * If POW_PRECISION is not 0, round to POW_PRECISION using ROUNDING_MODE.
6475 *
6476 * n {number} Integer, -9007199254740992 to 9007199254740992 inclusive.
6477 * (Performs 54 loop iterations for n of 9007199254740992.)
6478 *
6479 * 'pow() exponent not an integer: {n}'
6480 * 'pow() exponent out of range: {n}'
6481 */
6482 P.toPower = P.pow = function (n) {
6483 var k, y,
6484 i = mathfloor( n < 0 ? -n : +n ),
6485 x = this;
6486
6487 // Pass ±Infinity to Math.pow if exponent is out of range.
6488 if ( !isValidInt( n, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER, 23, 'exponent' ) &&
6489 ( !isFinite(n) || i > MAX_SAFE_INTEGER && ( n /= 0 ) ||
6490 parseFloat(n) != n && !( n = NaN ) ) ) {
6491 return new BigNumber( Math.pow( +x, n ) );
6492 }
6493
6494 // Truncating each coefficient array to a length of k after each multiplication equates
6495 // to truncating significant digits to POW_PRECISION + [28, 41], i.e. there will be a
6496 // minimum of 28 guard digits retained. (Using + 1.5 would give [9, 21] guard digits.)
6497 k = POW_PRECISION ? mathceil( POW_PRECISION / LOG_BASE + 2 ) : 0;
6498 y = new BigNumber(ONE);
6499
6500 for ( ; ; ) {
6501
6502 if ( i % 2 ) {
6503 y = y.times(x);
6504 if ( !y.c ) break;
6505 if ( k && y.c.length > k ) y.c.length = k;
6506 }
6507
6508 i = mathfloor( i / 2 );
6509 if ( !i ) break;
6510
6511 x = x.times(x);
6512 if ( k && x.c && x.c.length > k ) x.c.length = k;
6513 }
6514
6515 if ( n < 0 ) y = ONE.div(y);
6516 return k ? round( y, POW_PRECISION, ROUNDING_MODE ) : y;
6517 };
6518
6519
6520 /*
6521 * Return a string representing the value of this BigNumber rounded to sd significant digits
6522 * using rounding mode rm or ROUNDING_MODE. If sd is less than the number of digits
6523 * necessary to represent the integer part of the value in fixed-point notation, then use
6524 * exponential notation.
6525 *
6526 * [sd] {number} Significant digits. Integer, 1 to MAX inclusive.
6527 * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
6528 *
6529 * 'toPrecision() precision not an integer: {sd}'
6530 * 'toPrecision() precision out of range: {sd}'
6531 * 'toPrecision() rounding mode not an integer: {rm}'
6532 * 'toPrecision() rounding mode out of range: {rm}'
6533 */
6534 P.toPrecision = function ( sd, rm ) {
6535 return format( this, sd != null && isValidInt( sd, 1, MAX, 24, 'precision' )
6536 ? sd | 0 : null, rm, 24 );
6537 };
6538
6539
6540 /*
6541 * Return a string representing the value of this BigNumber in base b, or base 10 if b is
6542 * omitted. If a base is specified, including base 10, round according to DECIMAL_PLACES and
6543 * ROUNDING_MODE. If a base is not specified, and this BigNumber has a positive exponent
6544 * that is equal to or greater than TO_EXP_POS, or a negative exponent equal to or less than
6545 * TO_EXP_NEG, return exponential notation.
6546 *
6547 * [b] {number} Integer, 2 to 64 inclusive.
6548 *
6549 * 'toString() base not an integer: {b}'
6550 * 'toString() base out of range: {b}'
6551 */
6552 P.toString = function (b) {
6553 var str,
6554 n = this,
6555 s = n.s,
6556 e = n.e;
6557
6558 // Infinity or NaN?
6559 if ( e === null ) {
6560
6561 if (s) {
6562 str = 'Infinity';
6563 if ( s < 0 ) str = '-' + str;
6564 } else {
6565 str = 'NaN';
6566 }
6567 } else {
6568 str = coeffToString( n.c );
6569
6570 if ( b == null || !isValidInt( b, 2, 64, 25, 'base' ) ) {
6571 str = e <= TO_EXP_NEG || e >= TO_EXP_POS
6572 ? toExponential( str, e )
6573 : toFixedPoint( str, e );
6574 } else {
6575 str = convertBase( toFixedPoint( str, e ), b | 0, 10, s );
6576 }
6577
6578 if ( s < 0 && n.c[0] ) str = '-' + str;
6579 }
6580
6581 return str;
6582 };
6583
6584
6585 /*
6586 * Return a new BigNumber whose value is the value of this BigNumber truncated to a whole
6587 * number.
6588 */
6589 P.truncated = P.trunc = function () {
6590 return round( new BigNumber(this), this.e + 1, 1 );
6591 };
6592
6593
6594
6595 /*
6596 * Return as toString, but do not accept a base argument.
6597 */
6598 P.valueOf = P.toJSON = function () {
6599 return this.toString();
6600 };
6601
6602
6603 // Aliases for BigDecimal methods.
6604 //P.add = P.plus; // P.add included above
6605 //P.subtract = P.minus; // P.sub included above
6606 //P.multiply = P.times; // P.mul included above
6607 //P.divide = P.div;
6608 //P.remainder = P.mod;
6609 //P.compareTo = P.cmp;
6610 //P.negate = P.neg;
6611
6612
6613 if ( configObj != null ) BigNumber.config(configObj);
6614
6615 return BigNumber;
6616 }
6617
6618
6619 // PRIVATE HELPER FUNCTIONS
6620
6621
6622 function bitFloor(n) {
6623 var i = n | 0;
6624 return n > 0 || n === i ? i : i - 1;
6625 }
6626
6627
6628 // Return a coefficient array as a string of base 10 digits.
6629 function coeffToString(a) {
6630 var s, z,
6631 i = 1,
6632 j = a.length,
6633 r = a[0] + '';
6634
6635 for ( ; i < j; ) {
6636 s = a[i++] + '';
6637 z = LOG_BASE - s.length;
6638 for ( ; z--; s = '0' + s );
6639 r += s;
6640 }
6641
6642 // Determine trailing zeros.
6643 for ( j = r.length; r.charCodeAt(--j) === 48; );
6644 return r.slice( 0, j + 1 || 1 );
6645 }
6646
6647
6648 // Compare the value of BigNumbers x and y.
6649 function compare( x, y ) {
6650 var a, b,
6651 xc = x.c,
6652 yc = y.c,
6653 i = x.s,
6654 j = y.s,
6655 k = x.e,
6656 l = y.e;
6657
6658 // Either NaN?
6659 if ( !i || !j ) return null;
6660
6661 a = xc && !xc[0];
6662 b = yc && !yc[0];
6663
6664 // Either zero?
6665 if ( a || b ) return a ? b ? 0 : -j : i;
6666
6667 // Signs differ?
6668 if ( i != j ) return i;
6669
6670 a = i < 0;
6671 b = k == l;
6672
6673 // Either Infinity?
6674 if ( !xc || !yc ) return b ? 0 : !xc ^ a ? 1 : -1;
6675
6676 // Compare exponents.
6677 if ( !b ) return k > l ^ a ? 1 : -1;
6678
6679 j = ( k = xc.length ) < ( l = yc.length ) ? k : l;
6680
6681 // Compare digit by digit.
6682 for ( i = 0; i < j; i++ ) if ( xc[i] != yc[i] ) return xc[i] > yc[i] ^ a ? 1 : -1;
6683
6684 // Compare lengths.
6685 return k == l ? 0 : k > l ^ a ? 1 : -1;
6686 }
6687
6688
6689 /*
6690 * Return true if n is a valid number in range, otherwise false.
6691 * Use for argument validation when ERRORS is false.
6692 * Note: parseInt('1e+1') == 1 but parseFloat('1e+1') == 10.
6693 */
6694 function intValidatorNoErrors( n, min, max ) {
6695 return ( n = truncate(n) ) >= min && n <= max;
6696 }
6697
6698
6699 function isArray(obj) {
6700 return Object.prototype.toString.call(obj) == '[object Array]';
6701 }
6702
6703
6704 /*
6705 * Convert string of baseIn to an array of numbers of baseOut.
6706 * Eg. convertBase('255', 10, 16) returns [15, 15].
6707 * Eg. convertBase('ff', 16, 10) returns [2, 5, 5].
6708 */
6709 function toBaseOut( str, baseIn, baseOut ) {
6710 var j,
6711 arr = [0],
6712 arrL,
6713 i = 0,
6714 len = str.length;
6715
6716 for ( ; i < len; ) {
6717 for ( arrL = arr.length; arrL--; arr[arrL] *= baseIn );
6718 arr[ j = 0 ] += ALPHABET.indexOf( str.charAt( i++ ) );
6719
6720 for ( ; j < arr.length; j++ ) {
6721
6722 if ( arr[j] > baseOut - 1 ) {
6723 if ( arr[j + 1] == null ) arr[j + 1] = 0;
6724 arr[j + 1] += arr[j] / baseOut | 0;
6725 arr[j] %= baseOut;
6726 }
6727 }
6728 }
6729
6730 return arr.reverse();
6731 }
6732
6733
6734 function toExponential( str, e ) {
6735 return ( str.length > 1 ? str.charAt(0) + '.' + str.slice(1) : str ) +
6736 ( e < 0 ? 'e' : 'e+' ) + e;
6737 }
6738
6739
6740 function toFixedPoint( str, e ) {
6741 var len, z;
6742
6743 // Negative exponent?
6744 if ( e < 0 ) {
6745
6746 // Prepend zeros.
6747 for ( z = '0.'; ++e; z += '0' );
6748 str = z + str;
6749
6750 // Positive exponent
6751 } else {
6752 len = str.length;
6753
6754 // Append zeros.
6755 if ( ++e > len ) {
6756 for ( z = '0', e -= len; --e; z += '0' );
6757 str += z;
6758 } else if ( e < len ) {
6759 str = str.slice( 0, e ) + '.' + str.slice(e);
6760 }
6761 }
6762
6763 return str;
6764 }
6765
6766
6767 function truncate(n) {
6768 n = parseFloat(n);
6769 return n < 0 ? mathceil(n) : mathfloor(n);
6770 }
6771
6772
6773 // EXPORT
6774
6775
6776 BigNumber = another();
6777
6778 // AMD.
6779 if ( true ) {
6780 !(__WEBPACK_AMD_DEFINE_RESULT__ = function () { return BigNumber; }.call(exports, __webpack_require__, exports, module),
6781 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
6782
6783 // Node and other environments that support module.exports.
6784 } else if ( typeof module != 'undefined' && module.exports ) {
6785 module.exports = BigNumber;
6786 if ( !crypto ) try { crypto = require('crypto'); } catch (e) {}
6787
6788 // Browser.
6789 } else {
6790 global.BigNumber = BigNumber;
6791 }
6792})(this);
6793
6794
6795/***/ }),
6796/* 19 */
6797/***/ (function(module, exports, __webpack_require__) {
6798
6799/*
6800 This file is part of web3.js.
6801
6802 web3.js is free software: you can redistribute it and/or modify
6803 it under the terms of the GNU Lesser General Public License as published by
6804 the Free Software Foundation, either version 3 of the License, or
6805 (at your option) any later version.
6806
6807 web3.js is distributed in the hope that it will be useful,
6808 but WITHOUT ANY WARRANTY; without even the implied warranty of
6809 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6810 GNU Lesser General Public License for more details.
6811
6812 You should have received a copy of the GNU Lesser General Public License
6813 along with web3.js. If not, see <http://www.gnu.org/licenses/>.
6814*/
6815/**
6816 * @file sha3.js
6817 * @author Marek Kotewicz <marek@ethdev.com>
6818 * @date 2015
6819 */
6820
6821var CryptoJS = __webpack_require__(100);
6822var sha3 = __webpack_require__(59);
6823
6824module.exports = function (value, options) {
6825 if (options && options.encoding === 'hex') {
6826 if (value.length > 2 && value.substr(0, 2) === '0x') {
6827 value = value.substr(2);
6828 }
6829 value = CryptoJS.enc.Hex.parse(value);
6830 }
6831
6832 return sha3(value, {
6833 outputLength: 256
6834 }).toString();
6835};
6836
6837
6838
6839/***/ }),
6840/* 20 */
6841/***/ (function(module, exports) {
6842
6843/*
6844 This file is part of web3.js.
6845
6846 web3.js is free software: you can redistribute it and/or modify
6847 it under the terms of the GNU Lesser General Public License as published by
6848 the Free Software Foundation, either version 3 of the License, or
6849 (at your option) any later version.
6850
6851 web3.js is distributed in the hope that it will be useful,
6852 but WITHOUT ANY WARRANTY; without even the implied warranty of
6853 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6854 GNU Lesser General Public License for more details.
6855
6856 You should have received a copy of the GNU Lesser General Public License
6857 along with web3.js. If not, see <http://www.gnu.org/licenses/>.
6858*/
6859/**
6860 * @file errors.js
6861 * @author Marek Kotewicz <marek@ethdev.com>
6862 * @date 2015
6863 */
6864
6865module.exports = {
6866 InvalidNumberOfParams: function () {
6867 return new Error('Invalid number of input parameters');
6868 },
6869 InvalidConnection: function (host){
6870 return new Error('CONNECTION ERROR: Couldn\'t connect to node '+ host +'.');
6871 },
6872 InvalidProvider: function () {
6873 return new Error('Provider not set or invalid');
6874 },
6875 InvalidResponse: function (result){
6876 var message = !!result && !!result.error && !!result.error.message ? result.error.message : 'Invalid JSON RPC response: ' + JSON.stringify(result);
6877 return new Error(message);
6878 },
6879 ConnectionTimeout: function (ms){
6880 return new Error('CONNECTION TIMEOUT: timeout of ' + ms + ' ms achived');
6881 }
6882};
6883
6884
6885/***/ }),
6886/* 21 */
6887/***/ (function(module, exports, __webpack_require__) {
6888
6889/*
6890 This file is part of web3.js.
6891
6892 web3.js is free software: you can redistribute it and/or modify
6893 it under the terms of the GNU Lesser General Public License as published by
6894 the Free Software Foundation, either version 3 of the License, or
6895 (at your option) any later version.
6896
6897 web3.js is distributed in the hope that it will be useful,
6898 but WITHOUT ANY WARRANTY; without even the implied warranty of
6899 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6900 GNU Lesser General Public License for more details.
6901
6902 You should have received a copy of the GNU Lesser General Public License
6903 along with web3.js. If not, see <http://www.gnu.org/licenses/>.
6904*/
6905/**
6906 * @file coder.js
6907 * @author Marek Kotewicz <marek@ethdev.com>
6908 * @date 2015
6909 */
6910
6911var f = __webpack_require__(3);
6912
6913var SolidityTypeAddress = __webpack_require__(125);
6914var SolidityTypeBool = __webpack_require__(126);
6915var SolidityTypeInt = __webpack_require__(129);
6916var SolidityTypeUInt = __webpack_require__(132);
6917var SolidityTypeDynamicBytes = __webpack_require__(128);
6918var SolidityTypeString = __webpack_require__(131);
6919var SolidityTypeReal = __webpack_require__(130);
6920var SolidityTypeUReal = __webpack_require__(133);
6921var SolidityTypeBytes = __webpack_require__(127);
6922
6923var isDynamic = function (solidityType, type) {
6924 return solidityType.isDynamicType(type) ||
6925 solidityType.isDynamicArray(type);
6926};
6927
6928/**
6929 * SolidityCoder prototype should be used to encode/decode solidity params of any type
6930 */
6931var SolidityCoder = function (types) {
6932 this._types = types;
6933};
6934
6935/**
6936 * This method should be used to transform type to SolidityType
6937 *
6938 * @method _requireType
6939 * @param {String} type
6940 * @returns {SolidityType}
6941 * @throws {Error} throws if no matching type is found
6942 */
6943SolidityCoder.prototype._requireType = function (type) {
6944 var solidityType = this._types.filter(function (t) {
6945 return t.isType(type);
6946 })[0];
6947
6948 if (!solidityType) {
6949 throw Error('invalid solidity type!: ' + type);
6950 }
6951
6952 return solidityType;
6953};
6954
6955/**
6956 * Should be used to encode plain param
6957 *
6958 * @method encodeParam
6959 * @param {String} type
6960 * @param {Object} plain param
6961 * @return {String} encoded plain param
6962 */
6963SolidityCoder.prototype.encodeParam = function (type, param) {
6964 return this.encodeParams([type], [param]);
6965};
6966
6967/**
6968 * Should be used to encode list of params
6969 *
6970 * @method encodeParams
6971 * @param {Array} types
6972 * @param {Array} params
6973 * @return {String} encoded list of params
6974 */
6975SolidityCoder.prototype.encodeParams = function (types, params) {
6976 var solidityTypes = this.getSolidityTypes(types);
6977
6978 var encodeds = solidityTypes.map(function (solidityType, index) {
6979 return solidityType.encode(params[index], types[index]);
6980 });
6981
6982 var dynamicOffset = solidityTypes.reduce(function (acc, solidityType, index) {
6983 var staticPartLength = solidityType.staticPartLength(types[index]);
6984 var roundedStaticPartLength = Math.floor((staticPartLength + 31) / 32) * 32;
6985
6986 return acc + (isDynamic(solidityTypes[index], types[index]) ?
6987 32 :
6988 roundedStaticPartLength);
6989 }, 0);
6990
6991 var result = this.encodeMultiWithOffset(types, solidityTypes, encodeds, dynamicOffset);
6992
6993 return result;
6994};
6995
6996SolidityCoder.prototype.encodeMultiWithOffset = function (types, solidityTypes, encodeds, dynamicOffset) {
6997 var result = "";
6998 var self = this;
6999
7000 types.forEach(function (type, i) {
7001 if (isDynamic(solidityTypes[i], types[i])) {
7002 result += f.formatInputInt(dynamicOffset).encode();
7003 var e = self.encodeWithOffset(types[i], solidityTypes[i], encodeds[i], dynamicOffset);
7004 dynamicOffset += e.length / 2;
7005 } else {
7006 // don't add length to dynamicOffset. it's already counted
7007 result += self.encodeWithOffset(types[i], solidityTypes[i], encodeds[i], dynamicOffset);
7008 }
7009
7010 // TODO: figure out nested arrays
7011 });
7012
7013 types.forEach(function (type, i) {
7014 if (isDynamic(solidityTypes[i], types[i])) {
7015 var e = self.encodeWithOffset(types[i], solidityTypes[i], encodeds[i], dynamicOffset);
7016 dynamicOffset += e.length / 2;
7017 result += e;
7018 }
7019 });
7020 return result;
7021};
7022
7023// TODO: refactor whole encoding!
7024SolidityCoder.prototype.encodeWithOffset = function (type, solidityType, encoded, offset) {
7025 var self = this;
7026 if (solidityType.isDynamicArray(type)) {
7027 return (function () {
7028 // offset was already set
7029 var nestedName = solidityType.nestedName(type);
7030 var nestedStaticPartLength = solidityType.staticPartLength(nestedName);
7031 var result = encoded[0];
7032
7033 (function () {
7034 var previousLength = 2; // in int
7035 if (solidityType.isDynamicArray(nestedName)) {
7036 for (var i = 1; i < encoded.length; i++) {
7037 previousLength += +(encoded[i - 1])[0] || 0;
7038 result += f.formatInputInt(offset + i * nestedStaticPartLength + previousLength * 32).encode();
7039 }
7040 }
7041 })();
7042
7043 // first element is length, skip it
7044 (function () {
7045 for (var i = 0; i < encoded.length - 1; i++) {
7046 var additionalOffset = result / 2;
7047 result += self.encodeWithOffset(nestedName, solidityType, encoded[i + 1], offset + additionalOffset);
7048 }
7049 })();
7050
7051 return result;
7052 })();
7053
7054 } else if (solidityType.isStaticArray(type)) {
7055 return (function () {
7056 var nestedName = solidityType.nestedName(type);
7057 var nestedStaticPartLength = solidityType.staticPartLength(nestedName);
7058 var result = "";
7059
7060
7061 if (solidityType.isDynamicArray(nestedName)) {
7062 (function () {
7063 var previousLength = 0; // in int
7064 for (var i = 0; i < encoded.length; i++) {
7065 // calculate length of previous item
7066 previousLength += +(encoded[i - 1] || [])[0] || 0;
7067 result += f.formatInputInt(offset + i * nestedStaticPartLength + previousLength * 32).encode();
7068 }
7069 })();
7070 }
7071
7072 (function () {
7073 for (var i = 0; i < encoded.length; i++) {
7074 var additionalOffset = result / 2;
7075 result += self.encodeWithOffset(nestedName, solidityType, encoded[i], offset + additionalOffset);
7076 }
7077 })();
7078
7079 return result;
7080 })();
7081 }
7082
7083 return encoded;
7084};
7085
7086/**
7087 * Should be used to decode bytes to plain param
7088 *
7089 * @method decodeParam
7090 * @param {String} type
7091 * @param {String} bytes
7092 * @return {Object} plain param
7093 */
7094SolidityCoder.prototype.decodeParam = function (type, bytes) {
7095 return this.decodeParams([type], bytes)[0];
7096};
7097
7098/**
7099 * Should be used to decode list of params
7100 *
7101 * @method decodeParam
7102 * @param {Array} types
7103 * @param {String} bytes
7104 * @return {Array} array of plain params
7105 */
7106SolidityCoder.prototype.decodeParams = function (types, bytes) {
7107 var solidityTypes = this.getSolidityTypes(types);
7108 var offsets = this.getOffsets(types, solidityTypes);
7109
7110 return solidityTypes.map(function (solidityType, index) {
7111 return solidityType.decode(bytes, offsets[index], types[index], index);
7112 });
7113};
7114
7115SolidityCoder.prototype.getOffsets = function (types, solidityTypes) {
7116 var lengths = solidityTypes.map(function (solidityType, index) {
7117 return solidityType.staticPartLength(types[index]);
7118 });
7119
7120 for (var i = 1; i < lengths.length; i++) {
7121 // sum with length of previous element
7122 lengths[i] += lengths[i - 1];
7123 }
7124
7125 return lengths.map(function (length, index) {
7126 // remove the current length, so the length is sum of previous elements
7127 var staticPartLength = solidityTypes[index].staticPartLength(types[index]);
7128 return length - staticPartLength;
7129 });
7130};
7131
7132SolidityCoder.prototype.getSolidityTypes = function (types) {
7133 var self = this;
7134 return types.map(function (type) {
7135 return self._requireType(type);
7136 });
7137};
7138
7139var coder = new SolidityCoder([
7140 new SolidityTypeAddress(),
7141 new SolidityTypeBool(),
7142 new SolidityTypeInt(),
7143 new SolidityTypeUInt(),
7144 new SolidityTypeDynamicBytes(),
7145 new SolidityTypeBytes(),
7146 new SolidityTypeString(),
7147 new SolidityTypeReal(),
7148 new SolidityTypeUReal()
7149]);
7150
7151module.exports = coder;
7152
7153
7154/***/ }),
7155/* 22 */
7156/***/ (function(module, exports, __webpack_require__) {
7157
7158var isObject = __webpack_require__(24);
7159module.exports = function(it){
7160 if(!isObject(it))throw TypeError(it + ' is not an object!');
7161 return it;
7162};
7163
7164/***/ }),
7165/* 23 */
7166/***/ (function(module, exports) {
7167
7168module.exports = function(exec){
7169 try {
7170 return !!exec();
7171 } catch(e){
7172 return true;
7173 }
7174};
7175
7176/***/ }),
7177/* 24 */
7178/***/ (function(module, exports) {
7179
7180module.exports = function(it){
7181 return typeof it === 'object' ? it !== null : typeof it === 'function';
7182};
7183
7184/***/ }),
7185/* 25 */
7186/***/ (function(module, exports, __webpack_require__) {
7187
7188// 19.1.2.14 / 15.2.3.14 Object.keys(O)
7189var $keys = __webpack_require__(56)
7190 , enumBugKeys = __webpack_require__(35);
7191
7192module.exports = Object.keys || function keys(O){
7193 return $keys(O, enumBugKeys);
7194};
7195
7196/***/ }),
7197/* 26 */
7198/***/ (function(module, exports) {
7199
7200module.exports = function(bitmap, value){
7201 return {
7202 enumerable : !(bitmap & 1),
7203 configurable: !(bitmap & 2),
7204 writable : !(bitmap & 4),
7205 value : value
7206 };
7207};
7208
7209/***/ }),
7210/* 27 */
7211/***/ (function(module, exports) {
7212
7213var id = 0
7214 , px = Math.random();
7215module.exports = function(key){
7216 return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
7217};
7218
7219/***/ }),
7220/* 28 */
7221/***/ (function(module, exports, __webpack_require__) {
7222
7223;(function (root, factory) {
7224 if (true) {
7225 // CommonJS
7226 module.exports = exports = factory(__webpack_require__(0));
7227 }
7228 else if (typeof define === "function" && define.amd) {
7229 // AMD
7230 define(["./core"], factory);
7231 }
7232 else {
7233 // Global (browser)
7234 factory(root.CryptoJS);
7235 }
7236}(this, function (CryptoJS) {
7237
7238 (function (undefined) {
7239 // Shortcuts
7240 var C = CryptoJS;
7241 var C_lib = C.lib;
7242 var Base = C_lib.Base;
7243 var X32WordArray = C_lib.WordArray;
7244
7245 /**
7246 * x64 namespace.
7247 */
7248 var C_x64 = C.x64 = {};
7249
7250 /**
7251 * A 64-bit word.
7252 */
7253 var X64Word = C_x64.Word = Base.extend({
7254 /**
7255 * Initializes a newly created 64-bit word.
7256 *
7257 * @param {number} high The high 32 bits.
7258 * @param {number} low The low 32 bits.
7259 *
7260 * @example
7261 *
7262 * var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607);
7263 */
7264 init: function (high, low) {
7265 this.high = high;
7266 this.low = low;
7267 }
7268
7269 /**
7270 * Bitwise NOTs this word.
7271 *
7272 * @return {X64Word} A new x64-Word object after negating.
7273 *
7274 * @example
7275 *
7276 * var negated = x64Word.not();
7277 */
7278 // not: function () {
7279 // var high = ~this.high;
7280 // var low = ~this.low;
7281
7282 // return X64Word.create(high, low);
7283 // },
7284
7285 /**
7286 * Bitwise ANDs this word with the passed word.
7287 *
7288 * @param {X64Word} word The x64-Word to AND with this word.
7289 *
7290 * @return {X64Word} A new x64-Word object after ANDing.
7291 *
7292 * @example
7293 *
7294 * var anded = x64Word.and(anotherX64Word);
7295 */
7296 // and: function (word) {
7297 // var high = this.high & word.high;
7298 // var low = this.low & word.low;
7299
7300 // return X64Word.create(high, low);
7301 // },
7302
7303 /**
7304 * Bitwise ORs this word with the passed word.
7305 *
7306 * @param {X64Word} word The x64-Word to OR with this word.
7307 *
7308 * @return {X64Word} A new x64-Word object after ORing.
7309 *
7310 * @example
7311 *
7312 * var ored = x64Word.or(anotherX64Word);
7313 */
7314 // or: function (word) {
7315 // var high = this.high | word.high;
7316 // var low = this.low | word.low;
7317
7318 // return X64Word.create(high, low);
7319 // },
7320
7321 /**
7322 * Bitwise XORs this word with the passed word.
7323 *
7324 * @param {X64Word} word The x64-Word to XOR with this word.
7325 *
7326 * @return {X64Word} A new x64-Word object after XORing.
7327 *
7328 * @example
7329 *
7330 * var xored = x64Word.xor(anotherX64Word);
7331 */
7332 // xor: function (word) {
7333 // var high = this.high ^ word.high;
7334 // var low = this.low ^ word.low;
7335
7336 // return X64Word.create(high, low);
7337 // },
7338
7339 /**
7340 * Shifts this word n bits to the left.
7341 *
7342 * @param {number} n The number of bits to shift.
7343 *
7344 * @return {X64Word} A new x64-Word object after shifting.
7345 *
7346 * @example
7347 *
7348 * var shifted = x64Word.shiftL(25);
7349 */
7350 // shiftL: function (n) {
7351 // if (n < 32) {
7352 // var high = (this.high << n) | (this.low >>> (32 - n));
7353 // var low = this.low << n;
7354 // } else {
7355 // var high = this.low << (n - 32);
7356 // var low = 0;
7357 // }
7358
7359 // return X64Word.create(high, low);
7360 // },
7361
7362 /**
7363 * Shifts this word n bits to the right.
7364 *
7365 * @param {number} n The number of bits to shift.
7366 *
7367 * @return {X64Word} A new x64-Word object after shifting.
7368 *
7369 * @example
7370 *
7371 * var shifted = x64Word.shiftR(7);
7372 */
7373 // shiftR: function (n) {
7374 // if (n < 32) {
7375 // var low = (this.low >>> n) | (this.high << (32 - n));
7376 // var high = this.high >>> n;
7377 // } else {
7378 // var low = this.high >>> (n - 32);
7379 // var high = 0;
7380 // }
7381
7382 // return X64Word.create(high, low);
7383 // },
7384
7385 /**
7386 * Rotates this word n bits to the left.
7387 *
7388 * @param {number} n The number of bits to rotate.
7389 *
7390 * @return {X64Word} A new x64-Word object after rotating.
7391 *
7392 * @example
7393 *
7394 * var rotated = x64Word.rotL(25);
7395 */
7396 // rotL: function (n) {
7397 // return this.shiftL(n).or(this.shiftR(64 - n));
7398 // },
7399
7400 /**
7401 * Rotates this word n bits to the right.
7402 *
7403 * @param {number} n The number of bits to rotate.
7404 *
7405 * @return {X64Word} A new x64-Word object after rotating.
7406 *
7407 * @example
7408 *
7409 * var rotated = x64Word.rotR(7);
7410 */
7411 // rotR: function (n) {
7412 // return this.shiftR(n).or(this.shiftL(64 - n));
7413 // },
7414
7415 /**
7416 * Adds this word with the passed word.
7417 *
7418 * @param {X64Word} word The x64-Word to add with this word.
7419 *
7420 * @return {X64Word} A new x64-Word object after adding.
7421 *
7422 * @example
7423 *
7424 * var added = x64Word.add(anotherX64Word);
7425 */
7426 // add: function (word) {
7427 // var low = (this.low + word.low) | 0;
7428 // var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0;
7429 // var high = (this.high + word.high + carry) | 0;
7430
7431 // return X64Word.create(high, low);
7432 // }
7433 });
7434
7435 /**
7436 * An array of 64-bit words.
7437 *
7438 * @property {Array} words The array of CryptoJS.x64.Word objects.
7439 * @property {number} sigBytes The number of significant bytes in this word array.
7440 */
7441 var X64WordArray = C_x64.WordArray = Base.extend({
7442 /**
7443 * Initializes a newly created word array.
7444 *
7445 * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects.
7446 * @param {number} sigBytes (Optional) The number of significant bytes in the words.
7447 *
7448 * @example
7449 *
7450 * var wordArray = CryptoJS.x64.WordArray.create();
7451 *
7452 * var wordArray = CryptoJS.x64.WordArray.create([
7453 * CryptoJS.x64.Word.create(0x00010203, 0x04050607),
7454 * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
7455 * ]);
7456 *
7457 * var wordArray = CryptoJS.x64.WordArray.create([
7458 * CryptoJS.x64.Word.create(0x00010203, 0x04050607),
7459 * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
7460 * ], 10);
7461 */
7462 init: function (words, sigBytes) {
7463 words = this.words = words || [];
7464
7465 if (sigBytes != undefined) {
7466 this.sigBytes = sigBytes;
7467 } else {
7468 this.sigBytes = words.length * 8;
7469 }
7470 },
7471
7472 /**
7473 * Converts this 64-bit word array to a 32-bit word array.
7474 *
7475 * @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array.
7476 *
7477 * @example
7478 *
7479 * var x32WordArray = x64WordArray.toX32();
7480 */
7481 toX32: function () {
7482 // Shortcuts
7483 var x64Words = this.words;
7484 var x64WordsLength = x64Words.length;
7485
7486 // Convert
7487 var x32Words = [];
7488 for (var i = 0; i < x64WordsLength; i++) {
7489 var x64Word = x64Words[i];
7490 x32Words.push(x64Word.high);
7491 x32Words.push(x64Word.low);
7492 }
7493
7494 return X32WordArray.create(x32Words, this.sigBytes);
7495 },
7496
7497 /**
7498 * Creates a copy of this word array.
7499 *
7500 * @return {X64WordArray} The clone.
7501 *
7502 * @example
7503 *
7504 * var clone = x64WordArray.clone();
7505 */
7506 clone: function () {
7507 var clone = Base.clone.call(this);
7508
7509 // Clone "words" array
7510 var words = clone.words = this.words.slice(0);
7511
7512 // Clone each X64Word object
7513 var wordsLength = words.length;
7514 for (var i = 0; i < wordsLength; i++) {
7515 words[i] = words[i].clone();
7516 }
7517
7518 return clone;
7519 }
7520 });
7521 }());
7522
7523
7524 return CryptoJS;
7525
7526}));
7527
7528/***/ }),
7529/* 29 */
7530/***/ (function(module, exports, __webpack_require__) {
7531
7532/*
7533 This file is part of web3.js.
7534
7535 web3.js is free software: you can redistribute it and/or modify
7536 it under the terms of the GNU Lesser General Public License as published by
7537 the Free Software Foundation, either version 3 of the License, or
7538 (at your option) any later version.
7539
7540 web3.js is distributed in the hope that it will be useful,
7541 but WITHOUT ANY WARRANTY; without even the implied warranty of
7542 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7543 GNU Lesser General Public License for more details.
7544
7545 You should have received a copy of the GNU Lesser General Public License
7546 along with web3.js. If not, see <http://www.gnu.org/licenses/>.
7547*/
7548/** @file config.js
7549 * @authors:
7550 * Marek Kotewicz <marek@ethdev.com>
7551 * @date 2015
7552 */
7553
7554/**
7555 * Utils
7556 *
7557 * @module utils
7558 */
7559
7560/**
7561 * Utility functions
7562 *
7563 * @class [utils] config
7564 * @constructor
7565 */
7566
7567
7568/// required to define ETH_BIGNUMBER_ROUNDING_MODE
7569var BigNumber = __webpack_require__(18);
7570
7571var ETH_UNITS = [
7572 'wei',
7573 'kwei',
7574 'Mwei',
7575 'Gwei',
7576 'szabo',
7577 'finney',
7578 'femtoether',
7579 'picoether',
7580 'nanoether',
7581 'microether',
7582 'milliether',
7583 'nano',
7584 'micro',
7585 'milli',
7586 'ether',
7587 'grand',
7588 'Mether',
7589 'Gether',
7590 'Tether',
7591 'Pether',
7592 'Eether',
7593 'Zether',
7594 'Yether',
7595 'Nether',
7596 'Dether',
7597 'Vether',
7598 'Uether'
7599];
7600
7601module.exports = {
7602 ETH_PADDING: 32,
7603 ETH_SIGNATURE_LENGTH: 4,
7604 ETH_UNITS: ETH_UNITS,
7605 ETH_BIGNUMBER_ROUNDING_MODE: { ROUNDING_MODE: BigNumber.ROUND_DOWN },
7606 ETH_POLLING_TIMEOUT: 1000/2,
7607 defaultBlock: 'latest',
7608 defaultAccount: undefined
7609};
7610
7611
7612
7613/***/ }),
7614/* 30 */
7615/***/ (function(module, exports, __webpack_require__) {
7616
7617/*
7618 This file is part of web3.js.
7619
7620 web3.js is free software: you can redistribute it and/or modify
7621 it under the terms of the GNU Lesser General Public License as published by
7622 the Free Software Foundation, either version 3 of the License, or
7623 (at your option) any later version.
7624
7625 web3.js is distributed in the hope that it will be useful,
7626 but WITHOUT ANY WARRANTY; without even the implied warranty of
7627 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7628 GNU Lesser General Public License for more details.
7629
7630 You should have received a copy of the GNU Lesser General Public License
7631 along with web3.js. If not, see <http://www.gnu.org/licenses/>.
7632*/
7633/** @file filter.js
7634 * @authors:
7635 * Jeffrey Wilcke <jeff@ethdev.com>
7636 * Marek Kotewicz <marek@ethdev.com>
7637 * Marian Oancea <marian@ethdev.com>
7638 * Fabian Vogelsteller <fabian@ethdev.com>
7639 * Gav Wood <g@ethdev.com>
7640 * @date 2014
7641 */
7642
7643var formatters = __webpack_require__(5);
7644var utils = __webpack_require__(2);
7645
7646/**
7647* Converts a given topic to a hex string, but also allows null values.
7648*
7649* @param {Mixed} value
7650* @return {String}
7651*/
7652var toTopic = function(value){
7653
7654 if(value === null || typeof value === 'undefined')
7655 return null;
7656
7657 value = String(value);
7658
7659 if(value.indexOf('0x') === 0)
7660 return value;
7661 else
7662 return utils.fromUtf8(value);
7663};
7664
7665/// This method should be called on options object, to verify deprecated properties && lazy load dynamic ones
7666/// @param should be string or object
7667/// @returns options string or object
7668var getOptions = function (options) {
7669
7670 if (utils.isString(options)) {
7671 return options;
7672 }
7673
7674 options = options || {};
7675
7676 // make sure topics, get converted to hex
7677 options.topics = options.topics || [];
7678 options.topics = options.topics.map(function(topic){
7679 return (utils.isArray(topic)) ? topic.map(toTopic) : toTopic(topic);
7680 });
7681
7682 return {
7683 topics: options.topics,
7684 from: options.from,
7685 to: options.to,
7686 address: options.address,
7687 fromBlock: formatters.inputBlockNumberFormatter(options.fromBlock),
7688 toBlock: formatters.inputBlockNumberFormatter(options.toBlock)
7689 };
7690};
7691
7692/**
7693Adds the callback and sets up the methods, to iterate over the results.
7694
7695@method getLogsAtStart
7696@param {Object} self
7697@param {funciton}
7698*/
7699var getLogsAtStart = function(self, callback){
7700 // call getFilterLogs for the first watch callback start
7701 if (!utils.isString(self.options)) {
7702 self.get(function (err, messages) {
7703 // don't send all the responses to all the watches again... just to self one
7704 if (err) {
7705 callback(err);
7706 }
7707
7708 if(utils.isArray(messages)) {
7709 messages.forEach(function (message) {
7710 callback(null, message);
7711 });
7712 }
7713 });
7714 }
7715};
7716
7717/**
7718Adds the callback and sets up the methods, to iterate over the results.
7719
7720@method pollFilter
7721@param {Object} self
7722*/
7723var pollFilter = function(self) {
7724
7725 var onMessage = function (error, messages) {
7726 if (error) {
7727 return self.callbacks.forEach(function (callback) {
7728 callback(error);
7729 });
7730 }
7731
7732 if(utils.isArray(messages)) {
7733 messages.forEach(function (message) {
7734 message = self.formatter ? self.formatter(message) : message;
7735 self.callbacks.forEach(function (callback) {
7736 callback(null, message);
7737 });
7738 });
7739 }
7740 };
7741
7742 self.requestManager.startPolling({
7743 method: self.implementation.poll.call,
7744 params: [self.filterId],
7745 }, self.filterId, onMessage, self.stopWatching.bind(self));
7746
7747};
7748
7749var Filter = function (requestManager, options, methods, formatter, callback, filterCreationErrorCallback) {
7750 var self = this;
7751 var implementation = {};
7752 methods.forEach(function (method) {
7753 method.setRequestManager(requestManager);
7754 method.attachToObject(implementation);
7755 });
7756 this.requestManager = requestManager;
7757 this.options = getOptions(options);
7758 this.implementation = implementation;
7759 this.filterId = null;
7760 this.callbacks = [];
7761 this.getLogsCallbacks = [];
7762 this.pollFilters = [];
7763 this.formatter = formatter;
7764 this.implementation.newFilter(this.options, function(error, id){
7765 if(error) {
7766 self.callbacks.forEach(function(cb){
7767 cb(error);
7768 });
7769 filterCreationErrorCallback(error);
7770 } else {
7771 self.filterId = id;
7772
7773 // check if there are get pending callbacks as a consequence
7774 // of calling get() with filterId unassigned.
7775 self.getLogsCallbacks.forEach(function (cb){
7776 self.get(cb);
7777 });
7778 self.getLogsCallbacks = [];
7779
7780 // get filter logs for the already existing watch calls
7781 self.callbacks.forEach(function(cb){
7782 getLogsAtStart(self, cb);
7783 });
7784 if(self.callbacks.length > 0)
7785 pollFilter(self);
7786
7787 // start to watch immediately
7788 if(typeof callback === 'function') {
7789 return self.watch(callback);
7790 }
7791 }
7792 });
7793
7794 return this;
7795};
7796
7797Filter.prototype.watch = function (callback) {
7798 this.callbacks.push(callback);
7799
7800 if(this.filterId) {
7801 getLogsAtStart(this, callback);
7802 pollFilter(this);
7803 }
7804
7805 return this;
7806};
7807
7808Filter.prototype.stopWatching = function (callback) {
7809 this.requestManager.stopPolling(this.filterId);
7810 this.callbacks = [];
7811 // remove filter async
7812 if (callback) {
7813 this.implementation.uninstallFilter(this.filterId, callback);
7814 } else {
7815 return this.implementation.uninstallFilter(this.filterId);
7816 }
7817};
7818
7819Filter.prototype.get = function (callback) {
7820 var self = this;
7821 if (utils.isFunction(callback)) {
7822 if (this.filterId === null) {
7823 // If filterId is not set yet, call it back
7824 // when newFilter() assigns it.
7825 this.getLogsCallbacks.push(callback);
7826 } else {
7827 this.implementation.getLogs(this.filterId, function(err, res){
7828 if (err) {
7829 callback(err);
7830 } else {
7831 callback(null, res.map(function (log) {
7832 return self.formatter ? self.formatter(log) : log;
7833 }));
7834 }
7835 });
7836 }
7837 } else {
7838 if (this.filterId === null) {
7839 throw new Error('Filter ID Error: filter().get() can\'t be chained synchronous, please provide a callback for the get() method.');
7840 }
7841 var logs = this.implementation.getLogs(this.filterId);
7842 return logs.map(function (log) {
7843 return self.formatter ? self.formatter(log) : log;
7844 });
7845 }
7846
7847 return this;
7848};
7849
7850module.exports = Filter;
7851
7852
7853
7854/***/ }),
7855/* 31 */
7856/***/ (function(module, exports, __webpack_require__) {
7857
7858/*
7859 This file is part of web3.js.
7860
7861 web3.js is free software: you can redistribute it and/or modify
7862 it under the terms of the GNU Lesser General Public License as published by
7863 the Free Software Foundation, either version 3 of the License, or
7864 (at your option) any later version.
7865
7866 web3.js is distributed in the hope that it will be useful,
7867 but WITHOUT ANY WARRANTY; without even the implied warranty of
7868 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7869 GNU Lesser General Public License for more details.
7870
7871 You should have received a copy of the GNU Lesser General Public License
7872 along with web3.js. If not, see <http://www.gnu.org/licenses/>.
7873*/
7874/**
7875 * @file iban.js
7876 * @author Marek Kotewicz <marek@ethdev.com>
7877 * @date 2015
7878 */
7879
7880var BigNumber = __webpack_require__(18);
7881
7882var padLeft = function (string, bytes) {
7883 var result = string;
7884 while (result.length < bytes * 2) {
7885 result = '0' + result;
7886 }
7887 return result;
7888};
7889
7890/**
7891 * Prepare an IBAN for mod 97 computation by moving the first 4 chars to the end and transforming the letters to
7892 * numbers (A = 10, B = 11, ..., Z = 35), as specified in ISO13616.
7893 *
7894 * @method iso13616Prepare
7895 * @param {String} iban the IBAN
7896 * @returns {String} the prepared IBAN
7897 */
7898var iso13616Prepare = function (iban) {
7899 var A = 'A'.charCodeAt(0);
7900 var Z = 'Z'.charCodeAt(0);
7901
7902 iban = iban.toUpperCase();
7903 iban = iban.substr(4) + iban.substr(0,4);
7904
7905 return iban.split('').map(function(n){
7906 var code = n.charCodeAt(0);
7907 if (code >= A && code <= Z){
7908 // A = 10, B = 11, ... Z = 35
7909 return code - A + 10;
7910 } else {
7911 return n;
7912 }
7913 }).join('');
7914};
7915
7916/**
7917 * Calculates the MOD 97 10 of the passed IBAN as specified in ISO7064.
7918 *
7919 * @method mod9710
7920 * @param {String} iban
7921 * @returns {Number}
7922 */
7923var mod9710 = function (iban) {
7924 var remainder = iban,
7925 block;
7926
7927 while (remainder.length > 2){
7928 block = remainder.slice(0, 9);
7929 remainder = parseInt(block, 10) % 97 + remainder.slice(block.length);
7930 }
7931
7932 return parseInt(remainder, 10) % 97;
7933};
7934
7935/**
7936 * This prototype should be used to create iban object from iban correct string
7937 *
7938 * @param {String} iban
7939 */
7940var Iban = function (iban) {
7941 this._iban = iban;
7942};
7943
7944/**
7945 * This method should be used to create iban object from ethereum address
7946 *
7947 * @method fromAddress
7948 * @param {String} address
7949 * @return {Iban} the IBAN object
7950 */
7951Iban.fromAddress = function (address) {
7952 var asBn = new BigNumber(address, 16);
7953 var base36 = asBn.toString(36);
7954 var padded = padLeft(base36, 15);
7955 return Iban.fromBban(padded.toUpperCase());
7956};
7957
7958/**
7959 * Convert the passed BBAN to an IBAN for this country specification.
7960 * Please note that <i>"generation of the IBAN shall be the exclusive responsibility of the bank/branch servicing the account"</i>.
7961 * This method implements the preferred algorithm described in http://en.wikipedia.org/wiki/International_Bank_Account_Number#Generating_IBAN_check_digits
7962 *
7963 * @method fromBban
7964 * @param {String} bban the BBAN to convert to IBAN
7965 * @returns {Iban} the IBAN object
7966 */
7967Iban.fromBban = function (bban) {
7968 var countryCode = 'XE';
7969
7970 var remainder = mod9710(iso13616Prepare(countryCode + '00' + bban));
7971 var checkDigit = ('0' + (98 - remainder)).slice(-2);
7972
7973 return new Iban(countryCode + checkDigit + bban);
7974};
7975
7976/**
7977 * Should be used to create IBAN object for given institution and identifier
7978 *
7979 * @method createIndirect
7980 * @param {Object} options, required options are "institution" and "identifier"
7981 * @return {Iban} the IBAN object
7982 */
7983Iban.createIndirect = function (options) {
7984 return Iban.fromBban('ETH' + options.institution + options.identifier);
7985};
7986
7987/**
7988 * Thos method should be used to check if given string is valid iban object
7989 *
7990 * @method isValid
7991 * @param {String} iban string
7992 * @return {Boolean} true if it is valid IBAN
7993 */
7994Iban.isValid = function (iban) {
7995 var i = new Iban(iban);
7996 return i.isValid();
7997};
7998
7999/**
8000 * Should be called to check if iban is correct
8001 *
8002 * @method isValid
8003 * @returns {Boolean} true if it is, otherwise false
8004 */
8005Iban.prototype.isValid = function () {
8006 return /^XE[0-9]{2}(ETH[0-9A-Z]{13}|[0-9A-Z]{30,31})$/.test(this._iban) &&
8007 mod9710(iso13616Prepare(this._iban)) === 1;
8008};
8009
8010/**
8011 * Should be called to check if iban number is direct
8012 *
8013 * @method isDirect
8014 * @returns {Boolean} true if it is, otherwise false
8015 */
8016Iban.prototype.isDirect = function () {
8017 return this._iban.length === 34 || this._iban.length === 35;
8018};
8019
8020/**
8021 * Should be called to check if iban number if indirect
8022 *
8023 * @method isIndirect
8024 * @returns {Boolean} true if it is, otherwise false
8025 */
8026Iban.prototype.isIndirect = function () {
8027 return this._iban.length === 20;
8028};
8029
8030/**
8031 * Should be called to get iban checksum
8032 * Uses the mod-97-10 checksumming protocol (ISO/IEC 7064:2003)
8033 *
8034 * @method checksum
8035 * @returns {String} checksum
8036 */
8037Iban.prototype.checksum = function () {
8038 return this._iban.substr(2, 2);
8039};
8040
8041/**
8042 * Should be called to get institution identifier
8043 * eg. XREG
8044 *
8045 * @method institution
8046 * @returns {String} institution identifier
8047 */
8048Iban.prototype.institution = function () {
8049 return this.isIndirect() ? this._iban.substr(7, 4) : '';
8050};
8051
8052/**
8053 * Should be called to get client identifier within institution
8054 * eg. GAVOFYORK
8055 *
8056 * @method client
8057 * @returns {String} client identifier
8058 */
8059Iban.prototype.client = function () {
8060 return this.isIndirect() ? this._iban.substr(11) : '';
8061};
8062
8063/**
8064 * Should be called to get client direct address
8065 *
8066 * @method address
8067 * @returns {String} client direct address
8068 */
8069Iban.prototype.address = function () {
8070 if (this.isDirect()) {
8071 var base36 = this._iban.substr(4);
8072 var asBn = new BigNumber(base36, 36);
8073 return padLeft(asBn.toString(16), 20);
8074 }
8075
8076 return '';
8077};
8078
8079Iban.prototype.toString = function () {
8080 return this._iban;
8081};
8082
8083module.exports = Iban;
8084
8085
8086
8087/***/ }),
8088/* 32 */
8089/***/ (function(module, exports, __webpack_require__) {
8090
8091/*
8092 This file is part of web3.js.
8093
8094 web3.js is free software: you can redistribute it and/or modify
8095 it under the terms of the GNU Lesser General Public License as published by
8096 the Free Software Foundation, either version 3 of the License, or
8097 (at your option) any later version.
8098
8099 web3.js is distributed in the hope that it will be useful,
8100 but WITHOUT ANY WARRANTY; without even the implied warranty of
8101 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8102 GNU Lesser General Public License for more details.
8103
8104 You should have received a copy of the GNU Lesser General Public License
8105 along with web3.js. If not, see <http://www.gnu.org/licenses/>.
8106*/
8107/** @file watches.js
8108 * @authors:
8109 * Marek Kotewicz <marek@ethdev.com>
8110 * @date 2015
8111 */
8112
8113var Method = __webpack_require__(9);
8114
8115/// @returns an array of objects describing web3.eth.filter api methods
8116var eth = function () {
8117 var newFilterCall = function (args) {
8118 var type = args[0];
8119
8120 switch(type) {
8121 case 'latest':
8122 args.shift();
8123 this.params = 0;
8124 return 'eth_newBlockFilter';
8125 case 'pending':
8126 args.shift();
8127 this.params = 0;
8128 return 'eth_newPendingTransactionFilter';
8129 default:
8130 return 'eth_newFilter';
8131 }
8132 };
8133
8134 var newFilter = new Method({
8135 name: 'newFilter',
8136 call: newFilterCall,
8137 params: 1
8138 });
8139
8140 var uninstallFilter = new Method({
8141 name: 'uninstallFilter',
8142 call: 'eth_uninstallFilter',
8143 params: 1
8144 });
8145
8146 var getLogs = new Method({
8147 name: 'getLogs',
8148 call: 'eth_getFilterLogs',
8149 params: 1
8150 });
8151
8152 var poll = new Method({
8153 name: 'poll',
8154 call: 'eth_getFilterChanges',
8155 params: 1
8156 });
8157
8158 return [
8159 newFilter,
8160 uninstallFilter,
8161 getLogs,
8162 poll
8163 ];
8164};
8165
8166/// @returns an array of objects describing web3.shh.watch api methods
8167var shh = function () {
8168 var newFilter = new Method({
8169 name: 'newFilter',
8170 call: 'shh_newFilter',
8171 params: 1
8172 });
8173
8174 var uninstallFilter = new Method({
8175 name: 'uninstallFilter',
8176 call: 'shh_uninstallFilter',
8177 params: 1
8178 });
8179
8180 var getLogs = new Method({
8181 name: 'getLogs',
8182 call: 'shh_getMessages',
8183 params: 1
8184 });
8185
8186 var poll = new Method({
8187 name: 'poll',
8188 call: 'shh_getFilterChanges',
8189 params: 1
8190 });
8191
8192 return [
8193 newFilter,
8194 uninstallFilter,
8195 getLogs,
8196 poll
8197 ];
8198};
8199
8200module.exports = {
8201 eth: eth,
8202 shh: shh
8203};
8204
8205
8206
8207/***/ }),
8208/* 33 */
8209/***/ (function(module, exports) {
8210
8211var core = module.exports = {version: '2.4.0'};
8212if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef
8213
8214/***/ }),
8215/* 34 */
8216/***/ (function(module, exports) {
8217
8218// 7.2.1 RequireObjectCoercible(argument)
8219module.exports = function(it){
8220 if(it == undefined)throw TypeError("Can't call method on " + it);
8221 return it;
8222};
8223
8224/***/ }),
8225/* 35 */
8226/***/ (function(module, exports) {
8227
8228// IE 8- don't enum bug keys
8229module.exports = (
8230 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
8231).split(',');
8232
8233/***/ }),
8234/* 36 */
8235/***/ (function(module, exports) {
8236
8237module.exports = {};
8238
8239/***/ }),
8240/* 37 */
8241/***/ (function(module, exports) {
8242
8243module.exports = true;
8244
8245/***/ }),
8246/* 38 */
8247/***/ (function(module, exports) {
8248
8249exports.f = {}.propertyIsEnumerable;
8250
8251/***/ }),
8252/* 39 */
8253/***/ (function(module, exports, __webpack_require__) {
8254
8255var def = __webpack_require__(12).f
8256 , has = __webpack_require__(7)
8257 , TAG = __webpack_require__(13)('toStringTag');
8258
8259module.exports = function(it, tag, stat){
8260 if(it && !has(it = stat ? it : it.prototype, TAG))def(it, TAG, {configurable: true, value: tag});
8261};
8262
8263/***/ }),
8264/* 40 */
8265/***/ (function(module, exports, __webpack_require__) {
8266
8267var shared = __webpack_require__(41)('keys')
8268 , uid = __webpack_require__(27);
8269module.exports = function(key){
8270 return shared[key] || (shared[key] = uid(key));
8271};
8272
8273/***/ }),
8274/* 41 */
8275/***/ (function(module, exports, __webpack_require__) {
8276
8277var global = __webpack_require__(6)
8278 , SHARED = '__core-js_shared__'
8279 , store = global[SHARED] || (global[SHARED] = {});
8280module.exports = function(key){
8281 return store[key] || (store[key] = {});
8282};
8283
8284/***/ }),
8285/* 42 */
8286/***/ (function(module, exports) {
8287
8288// 7.1.4 ToInteger
8289var ceil = Math.ceil
8290 , floor = Math.floor;
8291module.exports = function(it){
8292 return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
8293};
8294
8295/***/ }),
8296/* 43 */
8297/***/ (function(module, exports, __webpack_require__) {
8298
8299// 7.1.1 ToPrimitive(input [, PreferredType])
8300var isObject = __webpack_require__(24);
8301// instead of the ES6 spec version, we didn't implement @@toPrimitive case
8302// and the second argument - flag - preferred type is a string
8303module.exports = function(it, S){
8304 if(!isObject(it))return it;
8305 var fn, val;
8306 if(S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val;
8307 if(typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it)))return val;
8308 if(!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val;
8309 throw TypeError("Can't convert object to primitive value");
8310};
8311
8312/***/ }),
8313/* 44 */
8314/***/ (function(module, exports, __webpack_require__) {
8315
8316var global = __webpack_require__(6)
8317 , core = __webpack_require__(33)
8318 , LIBRARY = __webpack_require__(37)
8319 , wksExt = __webpack_require__(45)
8320 , defineProperty = __webpack_require__(12).f;
8321module.exports = function(name){
8322 var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {});
8323 if(name.charAt(0) != '_' && !(name in $Symbol))defineProperty($Symbol, name, {value: wksExt.f(name)});
8324};
8325
8326/***/ }),
8327/* 45 */
8328/***/ (function(module, exports, __webpack_require__) {
8329
8330exports.f = __webpack_require__(13);
8331
8332/***/ }),
8333/* 46 */
8334/***/ (function(module, exports, __webpack_require__) {
8335
8336;(function (root, factory) {
8337 if (true) {
8338 // CommonJS
8339 module.exports = exports = factory(__webpack_require__(0));
8340 }
8341 else if (typeof define === "function" && define.amd) {
8342 // AMD
8343 define(["./core"], factory);
8344 }
8345 else {
8346 // Global (browser)
8347 factory(root.CryptoJS);
8348 }
8349}(this, function (CryptoJS) {
8350
8351 (function () {
8352 // Shortcuts
8353 var C = CryptoJS;
8354 var C_lib = C.lib;
8355 var Base = C_lib.Base;
8356 var C_enc = C.enc;
8357 var Utf8 = C_enc.Utf8;
8358 var C_algo = C.algo;
8359
8360 /**
8361 * HMAC algorithm.
8362 */
8363 var HMAC = C_algo.HMAC = Base.extend({
8364 /**
8365 * Initializes a newly created HMAC.
8366 *
8367 * @param {Hasher} hasher The hash algorithm to use.
8368 * @param {WordArray|string} key The secret key.
8369 *
8370 * @example
8371 *
8372 * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
8373 */
8374 init: function (hasher, key) {
8375 // Init hasher
8376 hasher = this._hasher = new hasher.init();
8377
8378 // Convert string to WordArray, else assume WordArray already
8379 if (typeof key == 'string') {
8380 key = Utf8.parse(key);
8381 }
8382
8383 // Shortcuts
8384 var hasherBlockSize = hasher.blockSize;
8385 var hasherBlockSizeBytes = hasherBlockSize * 4;
8386
8387 // Allow arbitrary length keys
8388 if (key.sigBytes > hasherBlockSizeBytes) {
8389 key = hasher.finalize(key);
8390 }
8391
8392 // Clamp excess bits
8393 key.clamp();
8394
8395 // Clone key for inner and outer pads
8396 var oKey = this._oKey = key.clone();
8397 var iKey = this._iKey = key.clone();
8398
8399 // Shortcuts
8400 var oKeyWords = oKey.words;
8401 var iKeyWords = iKey.words;
8402
8403 // XOR keys with pad constants
8404 for (var i = 0; i < hasherBlockSize; i++) {
8405 oKeyWords[i] ^= 0x5c5c5c5c;
8406 iKeyWords[i] ^= 0x36363636;
8407 }
8408 oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
8409
8410 // Set initial values
8411 this.reset();
8412 },
8413
8414 /**
8415 * Resets this HMAC to its initial state.
8416 *
8417 * @example
8418 *
8419 * hmacHasher.reset();
8420 */
8421 reset: function () {
8422 // Shortcut
8423 var hasher = this._hasher;
8424
8425 // Reset
8426 hasher.reset();
8427 hasher.update(this._iKey);
8428 },
8429
8430 /**
8431 * Updates this HMAC with a message.
8432 *
8433 * @param {WordArray|string} messageUpdate The message to append.
8434 *
8435 * @return {HMAC} This HMAC instance.
8436 *
8437 * @example
8438 *
8439 * hmacHasher.update('message');
8440 * hmacHasher.update(wordArray);
8441 */
8442 update: function (messageUpdate) {
8443 this._hasher.update(messageUpdate);
8444
8445 // Chainable
8446 return this;
8447 },
8448
8449 /**
8450 * Finalizes the HMAC computation.
8451 * Note that the finalize operation is effectively a destructive, read-once operation.
8452 *
8453 * @param {WordArray|string} messageUpdate (Optional) A final message update.
8454 *
8455 * @return {WordArray} The HMAC.
8456 *
8457 * @example
8458 *
8459 * var hmac = hmacHasher.finalize();
8460 * var hmac = hmacHasher.finalize('message');
8461 * var hmac = hmacHasher.finalize(wordArray);
8462 */
8463 finalize: function (messageUpdate) {
8464 // Shortcut
8465 var hasher = this._hasher;
8466
8467 // Compute HMAC
8468 var innerHash = hasher.finalize(messageUpdate);
8469 hasher.reset();
8470 var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));
8471
8472 return hmac;
8473 }
8474 });
8475 }());
8476
8477
8478}));
8479
8480/***/ }),
8481/* 47 */
8482/***/ (function(module, exports, __webpack_require__) {
8483
8484;(function (root, factory) {
8485 if (true) {
8486 // CommonJS
8487 module.exports = exports = factory(__webpack_require__(0));
8488 }
8489 else if (typeof define === "function" && define.amd) {
8490 // AMD
8491 define(["./core"], factory);
8492 }
8493 else {
8494 // Global (browser)
8495 factory(root.CryptoJS);
8496 }
8497}(this, function (CryptoJS) {
8498
8499 (function () {
8500 // Shortcuts
8501 var C = CryptoJS;
8502 var C_lib = C.lib;
8503 var WordArray = C_lib.WordArray;
8504 var Hasher = C_lib.Hasher;
8505 var C_algo = C.algo;
8506
8507 // Reusable object
8508 var W = [];
8509
8510 /**
8511 * SHA-1 hash algorithm.
8512 */
8513 var SHA1 = C_algo.SHA1 = Hasher.extend({
8514 _doReset: function () {
8515 this._hash = new WordArray.init([
8516 0x67452301, 0xefcdab89,
8517 0x98badcfe, 0x10325476,
8518 0xc3d2e1f0
8519 ]);
8520 },
8521
8522 _doProcessBlock: function (M, offset) {
8523 // Shortcut
8524 var H = this._hash.words;
8525
8526 // Working variables
8527 var a = H[0];
8528 var b = H[1];
8529 var c = H[2];
8530 var d = H[3];
8531 var e = H[4];
8532
8533 // Computation
8534 for (var i = 0; i < 80; i++) {
8535 if (i < 16) {
8536 W[i] = M[offset + i] | 0;
8537 } else {
8538 var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
8539 W[i] = (n << 1) | (n >>> 31);
8540 }
8541
8542 var t = ((a << 5) | (a >>> 27)) + e + W[i];
8543 if (i < 20) {
8544 t += ((b & c) | (~b & d)) + 0x5a827999;
8545 } else if (i < 40) {
8546 t += (b ^ c ^ d) + 0x6ed9eba1;
8547 } else if (i < 60) {
8548 t += ((b & c) | (b & d) | (c & d)) - 0x70e44324;
8549 } else /* if (i < 80) */ {
8550 t += (b ^ c ^ d) - 0x359d3e2a;
8551 }
8552
8553 e = d;
8554 d = c;
8555 c = (b << 30) | (b >>> 2);
8556 b = a;
8557 a = t;
8558 }
8559
8560 // Intermediate hash value
8561 H[0] = (H[0] + a) | 0;
8562 H[1] = (H[1] + b) | 0;
8563 H[2] = (H[2] + c) | 0;
8564 H[3] = (H[3] + d) | 0;
8565 H[4] = (H[4] + e) | 0;
8566 },
8567
8568 _doFinalize: function () {
8569 // Shortcuts
8570 var data = this._data;
8571 var dataWords = data.words;
8572
8573 var nBitsTotal = this._nDataBytes * 8;
8574 var nBitsLeft = data.sigBytes * 8;
8575
8576 // Add padding
8577 dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
8578 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
8579 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
8580 data.sigBytes = dataWords.length * 4;
8581
8582 // Hash final blocks
8583 this._process();
8584
8585 // Return final computed hash
8586 return this._hash;
8587 },
8588
8589 clone: function () {
8590 var clone = Hasher.clone.call(this);
8591 clone._hash = this._hash.clone();
8592
8593 return clone;
8594 }
8595 });
8596
8597 /**
8598 * Shortcut function to the hasher's object interface.
8599 *
8600 * @param {WordArray|string} message The message to hash.
8601 *
8602 * @return {WordArray} The hash.
8603 *
8604 * @static
8605 *
8606 * @example
8607 *
8608 * var hash = CryptoJS.SHA1('message');
8609 * var hash = CryptoJS.SHA1(wordArray);
8610 */
8611 C.SHA1 = Hasher._createHelper(SHA1);
8612
8613 /**
8614 * Shortcut function to the HMAC's object interface.
8615 *
8616 * @param {WordArray|string} message The message to hash.
8617 * @param {WordArray|string} key The secret key.
8618 *
8619 * @return {WordArray} The HMAC.
8620 *
8621 * @static
8622 *
8623 * @example
8624 *
8625 * var hmac = CryptoJS.HmacSHA1(message, key);
8626 */
8627 C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
8628 }());
8629
8630
8631 return CryptoJS.SHA1;
8632
8633}));
8634
8635/***/ }),
8636/* 48 */
8637/***/ (function(module, exports) {
8638
8639var toString = {}.toString;
8640
8641module.exports = function(it){
8642 return toString.call(it).slice(8, -1);
8643};
8644
8645/***/ }),
8646/* 49 */
8647/***/ (function(module, exports, __webpack_require__) {
8648
8649var isObject = __webpack_require__(24)
8650 , document = __webpack_require__(6).document
8651 // in old IE typeof document.createElement is 'object'
8652 , is = isObject(document) && isObject(document.createElement);
8653module.exports = function(it){
8654 return is ? document.createElement(it) : {};
8655};
8656
8657/***/ }),
8658/* 50 */
8659/***/ (function(module, exports, __webpack_require__) {
8660
8661var global = __webpack_require__(6)
8662 , core = __webpack_require__(33)
8663 , ctx = __webpack_require__(73)
8664 , hide = __webpack_require__(11)
8665 , PROTOTYPE = 'prototype';
8666
8667var $export = function(type, name, source){
8668 var IS_FORCED = type & $export.F
8669 , IS_GLOBAL = type & $export.G
8670 , IS_STATIC = type & $export.S
8671 , IS_PROTO = type & $export.P
8672 , IS_BIND = type & $export.B
8673 , IS_WRAP = type & $export.W
8674 , exports = IS_GLOBAL ? core : core[name] || (core[name] = {})
8675 , expProto = exports[PROTOTYPE]
8676 , target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE]
8677 , key, own, out;
8678 if(IS_GLOBAL)source = name;
8679 for(key in source){
8680 // contains in native
8681 own = !IS_FORCED && target && target[key] !== undefined;
8682 if(own && key in exports)continue;
8683 // export native or passed
8684 out = own ? target[key] : source[key];
8685 // prevent global pollution for namespaces
8686 exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key]
8687 // bind timers to global for call from export context
8688 : IS_BIND && own ? ctx(out, global)
8689 // wrap global constructors for prevent change them in library
8690 : IS_WRAP && target[key] == out ? (function(C){
8691 var F = function(a, b, c){
8692 if(this instanceof C){
8693 switch(arguments.length){
8694 case 0: return new C;
8695 case 1: return new C(a);
8696 case 2: return new C(a, b);
8697 } return new C(a, b, c);
8698 } return C.apply(this, arguments);
8699 };
8700 F[PROTOTYPE] = C[PROTOTYPE];
8701 return F;
8702 // make static versions for prototype methods
8703 })(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
8704 // export proto methods to core.%CONSTRUCTOR%.methods.%NAME%
8705 if(IS_PROTO){
8706 (exports.virtual || (exports.virtual = {}))[key] = out;
8707 // export proto methods to core.%CONSTRUCTOR%.prototype.%NAME%
8708 if(type & $export.R && expProto && !expProto[key])hide(expProto, key, out);
8709 }
8710 }
8711};
8712// type bitmap
8713$export.F = 1; // forced
8714$export.G = 2; // global
8715$export.S = 4; // static
8716$export.P = 8; // proto
8717$export.B = 16; // bind
8718$export.W = 32; // wrap
8719$export.U = 64; // safe
8720$export.R = 128; // real proto method for `library`
8721module.exports = $export;
8722
8723/***/ }),
8724/* 51 */
8725/***/ (function(module, exports, __webpack_require__) {
8726
8727module.exports = !__webpack_require__(10) && !__webpack_require__(23)(function(){
8728 return Object.defineProperty(__webpack_require__(49)('div'), 'a', {get: function(){ return 7; }}).a != 7;
8729});
8730
8731/***/ }),
8732/* 52 */
8733/***/ (function(module, exports, __webpack_require__) {
8734
8735"use strict";
8736
8737var LIBRARY = __webpack_require__(37)
8738 , $export = __webpack_require__(50)
8739 , redefine = __webpack_require__(57)
8740 , hide = __webpack_require__(11)
8741 , has = __webpack_require__(7)
8742 , Iterators = __webpack_require__(36)
8743 , $iterCreate = __webpack_require__(78)
8744 , setToStringTag = __webpack_require__(39)
8745 , getPrototypeOf = __webpack_require__(85)
8746 , ITERATOR = __webpack_require__(13)('iterator')
8747 , BUGGY = !([].keys && 'next' in [].keys()) // Safari has buggy iterators w/o `next`
8748 , FF_ITERATOR = '@@iterator'
8749 , KEYS = 'keys'
8750 , VALUES = 'values';
8751
8752var returnThis = function(){ return this; };
8753
8754module.exports = function(Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED){
8755 $iterCreate(Constructor, NAME, next);
8756 var getMethod = function(kind){
8757 if(!BUGGY && kind in proto)return proto[kind];
8758 switch(kind){
8759 case KEYS: return function keys(){ return new Constructor(this, kind); };
8760 case VALUES: return function values(){ return new Constructor(this, kind); };
8761 } return function entries(){ return new Constructor(this, kind); };
8762 };
8763 var TAG = NAME + ' Iterator'
8764 , DEF_VALUES = DEFAULT == VALUES
8765 , VALUES_BUG = false
8766 , proto = Base.prototype
8767 , $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT]
8768 , $default = $native || getMethod(DEFAULT)
8769 , $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined
8770 , $anyNative = NAME == 'Array' ? proto.entries || $native : $native
8771 , methods, key, IteratorPrototype;
8772 // Fix native
8773 if($anyNative){
8774 IteratorPrototype = getPrototypeOf($anyNative.call(new Base));
8775 if(IteratorPrototype !== Object.prototype){
8776 // Set @@toStringTag to native iterators
8777 setToStringTag(IteratorPrototype, TAG, true);
8778 // fix for some old engines
8779 if(!LIBRARY && !has(IteratorPrototype, ITERATOR))hide(IteratorPrototype, ITERATOR, returnThis);
8780 }
8781 }
8782 // fix Array#{values, @@iterator}.name in V8 / FF
8783 if(DEF_VALUES && $native && $native.name !== VALUES){
8784 VALUES_BUG = true;
8785 $default = function values(){ return $native.call(this); };
8786 }
8787 // Define iterator
8788 if((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])){
8789 hide(proto, ITERATOR, $default);
8790 }
8791 // Plug for library
8792 Iterators[NAME] = $default;
8793 Iterators[TAG] = returnThis;
8794 if(DEFAULT){
8795 methods = {
8796 values: DEF_VALUES ? $default : getMethod(VALUES),
8797 keys: IS_SET ? $default : getMethod(KEYS),
8798 entries: $entries
8799 };
8800 if(FORCED)for(key in methods){
8801 if(!(key in proto))redefine(proto, key, methods[key]);
8802 } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
8803 }
8804 return methods;
8805};
8806
8807/***/ }),
8808/* 53 */
8809/***/ (function(module, exports, __webpack_require__) {
8810
8811// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
8812var anObject = __webpack_require__(22)
8813 , dPs = __webpack_require__(82)
8814 , enumBugKeys = __webpack_require__(35)
8815 , IE_PROTO = __webpack_require__(40)('IE_PROTO')
8816 , Empty = function(){ /* empty */ }
8817 , PROTOTYPE = 'prototype';
8818
8819// Create object with fake `null` prototype: use iframe Object with cleared prototype
8820var createDict = function(){
8821 // Thrash, waste and sodomy: IE GC bug
8822 var iframe = __webpack_require__(49)('iframe')
8823 , i = enumBugKeys.length
8824 , lt = '<'
8825 , gt = '>'
8826 , iframeDocument;
8827 iframe.style.display = 'none';
8828 __webpack_require__(75).appendChild(iframe);
8829 iframe.src = 'javascript:'; // eslint-disable-line no-script-url
8830 // createDict = iframe.contentWindow.Object;
8831 // html.removeChild(iframe);
8832 iframeDocument = iframe.contentWindow.document;
8833 iframeDocument.open();
8834 iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
8835 iframeDocument.close();
8836 createDict = iframeDocument.F;
8837 while(i--)delete createDict[PROTOTYPE][enumBugKeys[i]];
8838 return createDict();
8839};
8840
8841module.exports = Object.create || function create(O, Properties){
8842 var result;
8843 if(O !== null){
8844 Empty[PROTOTYPE] = anObject(O);
8845 result = new Empty;
8846 Empty[PROTOTYPE] = null;
8847 // add "__proto__" for Object.getPrototypeOf polyfill
8848 result[IE_PROTO] = O;
8849 } else result = createDict();
8850 return Properties === undefined ? result : dPs(result, Properties);
8851};
8852
8853
8854/***/ }),
8855/* 54 */
8856/***/ (function(module, exports, __webpack_require__) {
8857
8858// 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)
8859var $keys = __webpack_require__(56)
8860 , hiddenKeys = __webpack_require__(35).concat('length', 'prototype');
8861
8862exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O){
8863 return $keys(O, hiddenKeys);
8864};
8865
8866/***/ }),
8867/* 55 */
8868/***/ (function(module, exports) {
8869
8870exports.f = Object.getOwnPropertySymbols;
8871
8872/***/ }),
8873/* 56 */
8874/***/ (function(module, exports, __webpack_require__) {
8875
8876var has = __webpack_require__(7)
8877 , toIObject = __webpack_require__(8)
8878 , arrayIndexOf = __webpack_require__(72)(false)
8879 , IE_PROTO = __webpack_require__(40)('IE_PROTO');
8880
8881module.exports = function(object, names){
8882 var O = toIObject(object)
8883 , i = 0
8884 , result = []
8885 , key;
8886 for(key in O)if(key != IE_PROTO)has(O, key) && result.push(key);
8887 // Don't enum bug & hidden keys
8888 while(names.length > i)if(has(O, key = names[i++])){
8889 ~arrayIndexOf(result, key) || result.push(key);
8890 }
8891 return result;
8892};
8893
8894/***/ }),
8895/* 57 */
8896/***/ (function(module, exports, __webpack_require__) {
8897
8898module.exports = __webpack_require__(11);
8899
8900/***/ }),
8901/* 58 */
8902/***/ (function(module, exports, __webpack_require__) {
8903
8904;(function (root, factory) {
8905 if (true) {
8906 // CommonJS
8907 module.exports = exports = factory(__webpack_require__(0));
8908 }
8909 else if (typeof define === "function" && define.amd) {
8910 // AMD
8911 define(["./core"], factory);
8912 }
8913 else {
8914 // Global (browser)
8915 factory(root.CryptoJS);
8916 }
8917}(this, function (CryptoJS) {
8918
8919 (function (Math) {
8920 // Shortcuts
8921 var C = CryptoJS;
8922 var C_lib = C.lib;
8923 var WordArray = C_lib.WordArray;
8924 var Hasher = C_lib.Hasher;
8925 var C_algo = C.algo;
8926
8927 // Initialization and round constants tables
8928 var H = [];
8929 var K = [];
8930
8931 // Compute constants
8932 (function () {
8933 function isPrime(n) {
8934 var sqrtN = Math.sqrt(n);
8935 for (var factor = 2; factor <= sqrtN; factor++) {
8936 if (!(n % factor)) {
8937 return false;
8938 }
8939 }
8940
8941 return true;
8942 }
8943
8944 function getFractionalBits(n) {
8945 return ((n - (n | 0)) * 0x100000000) | 0;
8946 }
8947
8948 var n = 2;
8949 var nPrime = 0;
8950 while (nPrime < 64) {
8951 if (isPrime(n)) {
8952 if (nPrime < 8) {
8953 H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));
8954 }
8955 K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));
8956
8957 nPrime++;
8958 }
8959
8960 n++;
8961 }
8962 }());
8963
8964 // Reusable object
8965 var W = [];
8966
8967 /**
8968 * SHA-256 hash algorithm.
8969 */
8970 var SHA256 = C_algo.SHA256 = Hasher.extend({
8971 _doReset: function () {
8972 this._hash = new WordArray.init(H.slice(0));
8973 },
8974
8975 _doProcessBlock: function (M, offset) {
8976 // Shortcut
8977 var H = this._hash.words;
8978
8979 // Working variables
8980 var a = H[0];
8981 var b = H[1];
8982 var c = H[2];
8983 var d = H[3];
8984 var e = H[4];
8985 var f = H[5];
8986 var g = H[6];
8987 var h = H[7];
8988
8989 // Computation
8990 for (var i = 0; i < 64; i++) {
8991 if (i < 16) {
8992 W[i] = M[offset + i] | 0;
8993 } else {
8994 var gamma0x = W[i - 15];
8995 var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^
8996 ((gamma0x << 14) | (gamma0x >>> 18)) ^
8997 (gamma0x >>> 3);
8998
8999 var gamma1x = W[i - 2];
9000 var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^
9001 ((gamma1x << 13) | (gamma1x >>> 19)) ^
9002 (gamma1x >>> 10);
9003
9004 W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
9005 }
9006
9007 var ch = (e & f) ^ (~e & g);
9008 var maj = (a & b) ^ (a & c) ^ (b & c);
9009
9010 var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));
9011 var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25));
9012
9013 var t1 = h + sigma1 + ch + K[i] + W[i];
9014 var t2 = sigma0 + maj;
9015
9016 h = g;
9017 g = f;
9018 f = e;
9019 e = (d + t1) | 0;
9020 d = c;
9021 c = b;
9022 b = a;
9023 a = (t1 + t2) | 0;
9024 }
9025
9026 // Intermediate hash value
9027 H[0] = (H[0] + a) | 0;
9028 H[1] = (H[1] + b) | 0;
9029 H[2] = (H[2] + c) | 0;
9030 H[3] = (H[3] + d) | 0;
9031 H[4] = (H[4] + e) | 0;
9032 H[5] = (H[5] + f) | 0;
9033 H[6] = (H[6] + g) | 0;
9034 H[7] = (H[7] + h) | 0;
9035 },
9036
9037 _doFinalize: function () {
9038 // Shortcuts
9039 var data = this._data;
9040 var dataWords = data.words;
9041
9042 var nBitsTotal = this._nDataBytes * 8;
9043 var nBitsLeft = data.sigBytes * 8;
9044
9045 // Add padding
9046 dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
9047 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
9048 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
9049 data.sigBytes = dataWords.length * 4;
9050
9051 // Hash final blocks
9052 this._process();
9053
9054 // Return final computed hash
9055 return this._hash;
9056 },
9057
9058 clone: function () {
9059 var clone = Hasher.clone.call(this);
9060 clone._hash = this._hash.clone();
9061
9062 return clone;
9063 }
9064 });
9065
9066 /**
9067 * Shortcut function to the hasher's object interface.
9068 *
9069 * @param {WordArray|string} message The message to hash.
9070 *
9071 * @return {WordArray} The hash.
9072 *
9073 * @static
9074 *
9075 * @example
9076 *
9077 * var hash = CryptoJS.SHA256('message');
9078 * var hash = CryptoJS.SHA256(wordArray);
9079 */
9080 C.SHA256 = Hasher._createHelper(SHA256);
9081
9082 /**
9083 * Shortcut function to the HMAC's object interface.
9084 *
9085 * @param {WordArray|string} message The message to hash.
9086 * @param {WordArray|string} key The secret key.
9087 *
9088 * @return {WordArray} The HMAC.
9089 *
9090 * @static
9091 *
9092 * @example
9093 *
9094 * var hmac = CryptoJS.HmacSHA256(message, key);
9095 */
9096 C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
9097 }(Math));
9098
9099
9100 return CryptoJS.SHA256;
9101
9102}));
9103
9104/***/ }),
9105/* 59 */
9106/***/ (function(module, exports, __webpack_require__) {
9107
9108;(function (root, factory, undef) {
9109 if (true) {
9110 // CommonJS
9111 module.exports = exports = factory(__webpack_require__(0), __webpack_require__(28));
9112 }
9113 else if (typeof define === "function" && define.amd) {
9114 // AMD
9115 define(["./core", "./x64-core"], factory);
9116 }
9117 else {
9118 // Global (browser)
9119 factory(root.CryptoJS);
9120 }
9121}(this, function (CryptoJS) {
9122
9123 (function (Math) {
9124 // Shortcuts
9125 var C = CryptoJS;
9126 var C_lib = C.lib;
9127 var WordArray = C_lib.WordArray;
9128 var Hasher = C_lib.Hasher;
9129 var C_x64 = C.x64;
9130 var X64Word = C_x64.Word;
9131 var C_algo = C.algo;
9132
9133 // Constants tables
9134 var RHO_OFFSETS = [];
9135 var PI_INDEXES = [];
9136 var ROUND_CONSTANTS = [];
9137
9138 // Compute Constants
9139 (function () {
9140 // Compute rho offset constants
9141 var x = 1, y = 0;
9142 for (var t = 0; t < 24; t++) {
9143 RHO_OFFSETS[x + 5 * y] = ((t + 1) * (t + 2) / 2) % 64;
9144
9145 var newX = y % 5;
9146 var newY = (2 * x + 3 * y) % 5;
9147 x = newX;
9148 y = newY;
9149 }
9150
9151 // Compute pi index constants
9152 for (var x = 0; x < 5; x++) {
9153 for (var y = 0; y < 5; y++) {
9154 PI_INDEXES[x + 5 * y] = y + ((2 * x + 3 * y) % 5) * 5;
9155 }
9156 }
9157
9158 // Compute round constants
9159 var LFSR = 0x01;
9160 for (var i = 0; i < 24; i++) {
9161 var roundConstantMsw = 0;
9162 var roundConstantLsw = 0;
9163
9164 for (var j = 0; j < 7; j++) {
9165 if (LFSR & 0x01) {
9166 var bitPosition = (1 << j) - 1;
9167 if (bitPosition < 32) {
9168 roundConstantLsw ^= 1 << bitPosition;
9169 } else /* if (bitPosition >= 32) */ {
9170 roundConstantMsw ^= 1 << (bitPosition - 32);
9171 }
9172 }
9173
9174 // Compute next LFSR
9175 if (LFSR & 0x80) {
9176 // Primitive polynomial over GF(2): x^8 + x^6 + x^5 + x^4 + 1
9177 LFSR = (LFSR << 1) ^ 0x71;
9178 } else {
9179 LFSR <<= 1;
9180 }
9181 }
9182
9183 ROUND_CONSTANTS[i] = X64Word.create(roundConstantMsw, roundConstantLsw);
9184 }
9185 }());
9186
9187 // Reusable objects for temporary values
9188 var T = [];
9189 (function () {
9190 for (var i = 0; i < 25; i++) {
9191 T[i] = X64Word.create();
9192 }
9193 }());
9194
9195 /**
9196 * SHA-3 hash algorithm.
9197 */
9198 var SHA3 = C_algo.SHA3 = Hasher.extend({
9199 /**
9200 * Configuration options.
9201 *
9202 * @property {number} outputLength
9203 * The desired number of bits in the output hash.
9204 * Only values permitted are: 224, 256, 384, 512.
9205 * Default: 512
9206 */
9207 cfg: Hasher.cfg.extend({
9208 outputLength: 512
9209 }),
9210
9211 _doReset: function () {
9212 var state = this._state = []
9213 for (var i = 0; i < 25; i++) {
9214 state[i] = new X64Word.init();
9215 }
9216
9217 this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32;
9218 },
9219
9220 _doProcessBlock: function (M, offset) {
9221 // Shortcuts
9222 var state = this._state;
9223 var nBlockSizeLanes = this.blockSize / 2;
9224
9225 // Absorb
9226 for (var i = 0; i < nBlockSizeLanes; i++) {
9227 // Shortcuts
9228 var M2i = M[offset + 2 * i];
9229 var M2i1 = M[offset + 2 * i + 1];
9230
9231 // Swap endian
9232 M2i = (
9233 (((M2i << 8) | (M2i >>> 24)) & 0x00ff00ff) |
9234 (((M2i << 24) | (M2i >>> 8)) & 0xff00ff00)
9235 );
9236 M2i1 = (
9237 (((M2i1 << 8) | (M2i1 >>> 24)) & 0x00ff00ff) |
9238 (((M2i1 << 24) | (M2i1 >>> 8)) & 0xff00ff00)
9239 );
9240
9241 // Absorb message into state
9242 var lane = state[i];
9243 lane.high ^= M2i1;
9244 lane.low ^= M2i;
9245 }
9246
9247 // Rounds
9248 for (var round = 0; round < 24; round++) {
9249 // Theta
9250 for (var x = 0; x < 5; x++) {
9251 // Mix column lanes
9252 var tMsw = 0, tLsw = 0;
9253 for (var y = 0; y < 5; y++) {
9254 var lane = state[x + 5 * y];
9255 tMsw ^= lane.high;
9256 tLsw ^= lane.low;
9257 }
9258
9259 // Temporary values
9260 var Tx = T[x];
9261 Tx.high = tMsw;
9262 Tx.low = tLsw;
9263 }
9264 for (var x = 0; x < 5; x++) {
9265 // Shortcuts
9266 var Tx4 = T[(x + 4) % 5];
9267 var Tx1 = T[(x + 1) % 5];
9268 var Tx1Msw = Tx1.high;
9269 var Tx1Lsw = Tx1.low;
9270
9271 // Mix surrounding columns
9272 var tMsw = Tx4.high ^ ((Tx1Msw << 1) | (Tx1Lsw >>> 31));
9273 var tLsw = Tx4.low ^ ((Tx1Lsw << 1) | (Tx1Msw >>> 31));
9274 for (var y = 0; y < 5; y++) {
9275 var lane = state[x + 5 * y];
9276 lane.high ^= tMsw;
9277 lane.low ^= tLsw;
9278 }
9279 }
9280
9281 // Rho Pi
9282 for (var laneIndex = 1; laneIndex < 25; laneIndex++) {
9283 // Shortcuts
9284 var lane = state[laneIndex];
9285 var laneMsw = lane.high;
9286 var laneLsw = lane.low;
9287 var rhoOffset = RHO_OFFSETS[laneIndex];
9288
9289 // Rotate lanes
9290 if (rhoOffset < 32) {
9291 var tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset));
9292 var tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset));
9293 } else /* if (rhoOffset >= 32) */ {
9294 var tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset));
9295 var tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset));
9296 }
9297
9298 // Transpose lanes
9299 var TPiLane = T[PI_INDEXES[laneIndex]];
9300 TPiLane.high = tMsw;
9301 TPiLane.low = tLsw;
9302 }
9303
9304 // Rho pi at x = y = 0
9305 var T0 = T[0];
9306 var state0 = state[0];
9307 T0.high = state0.high;
9308 T0.low = state0.low;
9309
9310 // Chi
9311 for (var x = 0; x < 5; x++) {
9312 for (var y = 0; y < 5; y++) {
9313 // Shortcuts
9314 var laneIndex = x + 5 * y;
9315 var lane = state[laneIndex];
9316 var TLane = T[laneIndex];
9317 var Tx1Lane = T[((x + 1) % 5) + 5 * y];
9318 var Tx2Lane = T[((x + 2) % 5) + 5 * y];
9319
9320 // Mix rows
9321 lane.high = TLane.high ^ (~Tx1Lane.high & Tx2Lane.high);
9322 lane.low = TLane.low ^ (~Tx1Lane.low & Tx2Lane.low);
9323 }
9324 }
9325
9326 // Iota
9327 var lane = state[0];
9328 var roundConstant = ROUND_CONSTANTS[round];
9329 lane.high ^= roundConstant.high;
9330 lane.low ^= roundConstant.low;;
9331 }
9332 },
9333
9334 _doFinalize: function () {
9335 // Shortcuts
9336 var data = this._data;
9337 var dataWords = data.words;
9338 var nBitsTotal = this._nDataBytes * 8;
9339 var nBitsLeft = data.sigBytes * 8;
9340 var blockSizeBits = this.blockSize * 32;
9341
9342 // Add padding
9343 dataWords[nBitsLeft >>> 5] |= 0x1 << (24 - nBitsLeft % 32);
9344 dataWords[((Math.ceil((nBitsLeft + 1) / blockSizeBits) * blockSizeBits) >>> 5) - 1] |= 0x80;
9345 data.sigBytes = dataWords.length * 4;
9346
9347 // Hash final blocks
9348 this._process();
9349
9350 // Shortcuts
9351 var state = this._state;
9352 var outputLengthBytes = this.cfg.outputLength / 8;
9353 var outputLengthLanes = outputLengthBytes / 8;
9354
9355 // Squeeze
9356 var hashWords = [];
9357 for (var i = 0; i < outputLengthLanes; i++) {
9358 // Shortcuts
9359 var lane = state[i];
9360 var laneMsw = lane.high;
9361 var laneLsw = lane.low;
9362
9363 // Swap endian
9364 laneMsw = (
9365 (((laneMsw << 8) | (laneMsw >>> 24)) & 0x00ff00ff) |
9366 (((laneMsw << 24) | (laneMsw >>> 8)) & 0xff00ff00)
9367 );
9368 laneLsw = (
9369 (((laneLsw << 8) | (laneLsw >>> 24)) & 0x00ff00ff) |
9370 (((laneLsw << 24) | (laneLsw >>> 8)) & 0xff00ff00)
9371 );
9372
9373 // Squeeze state to retrieve hash
9374 hashWords.push(laneLsw);
9375 hashWords.push(laneMsw);
9376 }
9377
9378 // Return final computed hash
9379 return new WordArray.init(hashWords, outputLengthBytes);
9380 },
9381
9382 clone: function () {
9383 var clone = Hasher.clone.call(this);
9384
9385 var state = clone._state = this._state.slice(0);
9386 for (var i = 0; i < 25; i++) {
9387 state[i] = state[i].clone();
9388 }
9389
9390 return clone;
9391 }
9392 });
9393
9394 /**
9395 * Shortcut function to the hasher's object interface.
9396 *
9397 * @param {WordArray|string} message The message to hash.
9398 *
9399 * @return {WordArray} The hash.
9400 *
9401 * @static
9402 *
9403 * @example
9404 *
9405 * var hash = CryptoJS.SHA3('message');
9406 * var hash = CryptoJS.SHA3(wordArray);
9407 */
9408 C.SHA3 = Hasher._createHelper(SHA3);
9409
9410 /**
9411 * Shortcut function to the HMAC's object interface.
9412 *
9413 * @param {WordArray|string} message The message to hash.
9414 * @param {WordArray|string} key The secret key.
9415 *
9416 * @return {WordArray} The HMAC.
9417 *
9418 * @static
9419 *
9420 * @example
9421 *
9422 * var hmac = CryptoJS.HmacSHA3(message, key);
9423 */
9424 C.HmacSHA3 = Hasher._createHmacHelper(SHA3);
9425 }(Math));
9426
9427
9428 return CryptoJS.SHA3;
9429
9430}));
9431
9432/***/ }),
9433/* 60 */
9434/***/ (function(module, exports, __webpack_require__) {
9435
9436;(function (root, factory, undef) {
9437 if (true) {
9438 // CommonJS
9439 module.exports = exports = factory(__webpack_require__(0), __webpack_require__(28));
9440 }
9441 else if (typeof define === "function" && define.amd) {
9442 // AMD
9443 define(["./core", "./x64-core"], factory);
9444 }
9445 else {
9446 // Global (browser)
9447 factory(root.CryptoJS);
9448 }
9449}(this, function (CryptoJS) {
9450
9451 (function () {
9452 // Shortcuts
9453 var C = CryptoJS;
9454 var C_lib = C.lib;
9455 var Hasher = C_lib.Hasher;
9456 var C_x64 = C.x64;
9457 var X64Word = C_x64.Word;
9458 var X64WordArray = C_x64.WordArray;
9459 var C_algo = C.algo;
9460
9461 function X64Word_create() {
9462 return X64Word.create.apply(X64Word, arguments);
9463 }
9464
9465 // Constants
9466 var K = [
9467 X64Word_create(0x428a2f98, 0xd728ae22), X64Word_create(0x71374491, 0x23ef65cd),
9468 X64Word_create(0xb5c0fbcf, 0xec4d3b2f), X64Word_create(0xe9b5dba5, 0x8189dbbc),
9469 X64Word_create(0x3956c25b, 0xf348b538), X64Word_create(0x59f111f1, 0xb605d019),
9470 X64Word_create(0x923f82a4, 0xaf194f9b), X64Word_create(0xab1c5ed5, 0xda6d8118),
9471 X64Word_create(0xd807aa98, 0xa3030242), X64Word_create(0x12835b01, 0x45706fbe),
9472 X64Word_create(0x243185be, 0x4ee4b28c), X64Word_create(0x550c7dc3, 0xd5ffb4e2),
9473 X64Word_create(0x72be5d74, 0xf27b896f), X64Word_create(0x80deb1fe, 0x3b1696b1),
9474 X64Word_create(0x9bdc06a7, 0x25c71235), X64Word_create(0xc19bf174, 0xcf692694),
9475 X64Word_create(0xe49b69c1, 0x9ef14ad2), X64Word_create(0xefbe4786, 0x384f25e3),
9476 X64Word_create(0x0fc19dc6, 0x8b8cd5b5), X64Word_create(0x240ca1cc, 0x77ac9c65),
9477 X64Word_create(0x2de92c6f, 0x592b0275), X64Word_create(0x4a7484aa, 0x6ea6e483),
9478 X64Word_create(0x5cb0a9dc, 0xbd41fbd4), X64Word_create(0x76f988da, 0x831153b5),
9479 X64Word_create(0x983e5152, 0xee66dfab), X64Word_create(0xa831c66d, 0x2db43210),
9480 X64Word_create(0xb00327c8, 0x98fb213f), X64Word_create(0xbf597fc7, 0xbeef0ee4),
9481 X64Word_create(0xc6e00bf3, 0x3da88fc2), X64Word_create(0xd5a79147, 0x930aa725),
9482 X64Word_create(0x06ca6351, 0xe003826f), X64Word_create(0x14292967, 0x0a0e6e70),
9483 X64Word_create(0x27b70a85, 0x46d22ffc), X64Word_create(0x2e1b2138, 0x5c26c926),
9484 X64Word_create(0x4d2c6dfc, 0x5ac42aed), X64Word_create(0x53380d13, 0x9d95b3df),
9485 X64Word_create(0x650a7354, 0x8baf63de), X64Word_create(0x766a0abb, 0x3c77b2a8),
9486 X64Word_create(0x81c2c92e, 0x47edaee6), X64Word_create(0x92722c85, 0x1482353b),
9487 X64Word_create(0xa2bfe8a1, 0x4cf10364), X64Word_create(0xa81a664b, 0xbc423001),
9488 X64Word_create(0xc24b8b70, 0xd0f89791), X64Word_create(0xc76c51a3, 0x0654be30),
9489 X64Word_create(0xd192e819, 0xd6ef5218), X64Word_create(0xd6990624, 0x5565a910),
9490 X64Word_create(0xf40e3585, 0x5771202a), X64Word_create(0x106aa070, 0x32bbd1b8),
9491 X64Word_create(0x19a4c116, 0xb8d2d0c8), X64Word_create(0x1e376c08, 0x5141ab53),
9492 X64Word_create(0x2748774c, 0xdf8eeb99), X64Word_create(0x34b0bcb5, 0xe19b48a8),
9493 X64Word_create(0x391c0cb3, 0xc5c95a63), X64Word_create(0x4ed8aa4a, 0xe3418acb),
9494 X64Word_create(0x5b9cca4f, 0x7763e373), X64Word_create(0x682e6ff3, 0xd6b2b8a3),
9495 X64Word_create(0x748f82ee, 0x5defb2fc), X64Word_create(0x78a5636f, 0x43172f60),
9496 X64Word_create(0x84c87814, 0xa1f0ab72), X64Word_create(0x8cc70208, 0x1a6439ec),
9497 X64Word_create(0x90befffa, 0x23631e28), X64Word_create(0xa4506ceb, 0xde82bde9),
9498 X64Word_create(0xbef9a3f7, 0xb2c67915), X64Word_create(0xc67178f2, 0xe372532b),
9499 X64Word_create(0xca273ece, 0xea26619c), X64Word_create(0xd186b8c7, 0x21c0c207),
9500 X64Word_create(0xeada7dd6, 0xcde0eb1e), X64Word_create(0xf57d4f7f, 0xee6ed178),
9501 X64Word_create(0x06f067aa, 0x72176fba), X64Word_create(0x0a637dc5, 0xa2c898a6),
9502 X64Word_create(0x113f9804, 0xbef90dae), X64Word_create(0x1b710b35, 0x131c471b),
9503 X64Word_create(0x28db77f5, 0x23047d84), X64Word_create(0x32caab7b, 0x40c72493),
9504 X64Word_create(0x3c9ebe0a, 0x15c9bebc), X64Word_create(0x431d67c4, 0x9c100d4c),
9505 X64Word_create(0x4cc5d4be, 0xcb3e42b6), X64Word_create(0x597f299c, 0xfc657e2a),
9506 X64Word_create(0x5fcb6fab, 0x3ad6faec), X64Word_create(0x6c44198c, 0x4a475817)
9507 ];
9508
9509 // Reusable objects
9510 var W = [];
9511 (function () {
9512 for (var i = 0; i < 80; i++) {
9513 W[i] = X64Word_create();
9514 }
9515 }());
9516
9517 /**
9518 * SHA-512 hash algorithm.
9519 */
9520 var SHA512 = C_algo.SHA512 = Hasher.extend({
9521 _doReset: function () {
9522 this._hash = new X64WordArray.init([
9523 new X64Word.init(0x6a09e667, 0xf3bcc908), new X64Word.init(0xbb67ae85, 0x84caa73b),
9524 new X64Word.init(0x3c6ef372, 0xfe94f82b), new X64Word.init(0xa54ff53a, 0x5f1d36f1),
9525 new X64Word.init(0x510e527f, 0xade682d1), new X64Word.init(0x9b05688c, 0x2b3e6c1f),
9526 new X64Word.init(0x1f83d9ab, 0xfb41bd6b), new X64Word.init(0x5be0cd19, 0x137e2179)
9527 ]);
9528 },
9529
9530 _doProcessBlock: function (M, offset) {
9531 // Shortcuts
9532 var H = this._hash.words;
9533
9534 var H0 = H[0];
9535 var H1 = H[1];
9536 var H2 = H[2];
9537 var H3 = H[3];
9538 var H4 = H[4];
9539 var H5 = H[5];
9540 var H6 = H[6];
9541 var H7 = H[7];
9542
9543 var H0h = H0.high;
9544 var H0l = H0.low;
9545 var H1h = H1.high;
9546 var H1l = H1.low;
9547 var H2h = H2.high;
9548 var H2l = H2.low;
9549 var H3h = H3.high;
9550 var H3l = H3.low;
9551 var H4h = H4.high;
9552 var H4l = H4.low;
9553 var H5h = H5.high;
9554 var H5l = H5.low;
9555 var H6h = H6.high;
9556 var H6l = H6.low;
9557 var H7h = H7.high;
9558 var H7l = H7.low;
9559
9560 // Working variables
9561 var ah = H0h;
9562 var al = H0l;
9563 var bh = H1h;
9564 var bl = H1l;
9565 var ch = H2h;
9566 var cl = H2l;
9567 var dh = H3h;
9568 var dl = H3l;
9569 var eh = H4h;
9570 var el = H4l;
9571 var fh = H5h;
9572 var fl = H5l;
9573 var gh = H6h;
9574 var gl = H6l;
9575 var hh = H7h;
9576 var hl = H7l;
9577
9578 // Rounds
9579 for (var i = 0; i < 80; i++) {
9580 // Shortcut
9581 var Wi = W[i];
9582
9583 // Extend message
9584 if (i < 16) {
9585 var Wih = Wi.high = M[offset + i * 2] | 0;
9586 var Wil = Wi.low = M[offset + i * 2 + 1] | 0;
9587 } else {
9588 // Gamma0
9589 var gamma0x = W[i - 15];
9590 var gamma0xh = gamma0x.high;
9591 var gamma0xl = gamma0x.low;
9592 var gamma0h = ((gamma0xh >>> 1) | (gamma0xl << 31)) ^ ((gamma0xh >>> 8) | (gamma0xl << 24)) ^ (gamma0xh >>> 7);
9593 var gamma0l = ((gamma0xl >>> 1) | (gamma0xh << 31)) ^ ((gamma0xl >>> 8) | (gamma0xh << 24)) ^ ((gamma0xl >>> 7) | (gamma0xh << 25));
9594
9595 // Gamma1
9596 var gamma1x = W[i - 2];
9597 var gamma1xh = gamma1x.high;
9598 var gamma1xl = gamma1x.low;
9599 var gamma1h = ((gamma1xh >>> 19) | (gamma1xl << 13)) ^ ((gamma1xh << 3) | (gamma1xl >>> 29)) ^ (gamma1xh >>> 6);
9600 var gamma1l = ((gamma1xl >>> 19) | (gamma1xh << 13)) ^ ((gamma1xl << 3) | (gamma1xh >>> 29)) ^ ((gamma1xl >>> 6) | (gamma1xh << 26));
9601
9602 // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
9603 var Wi7 = W[i - 7];
9604 var Wi7h = Wi7.high;
9605 var Wi7l = Wi7.low;
9606
9607 var Wi16 = W[i - 16];
9608 var Wi16h = Wi16.high;
9609 var Wi16l = Wi16.low;
9610
9611 var Wil = gamma0l + Wi7l;
9612 var Wih = gamma0h + Wi7h + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0);
9613 var Wil = Wil + gamma1l;
9614 var Wih = Wih + gamma1h + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0);
9615 var Wil = Wil + Wi16l;
9616 var Wih = Wih + Wi16h + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0);
9617
9618 Wi.high = Wih;
9619 Wi.low = Wil;
9620 }
9621
9622 var chh = (eh & fh) ^ (~eh & gh);
9623 var chl = (el & fl) ^ (~el & gl);
9624 var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch);
9625 var majl = (al & bl) ^ (al & cl) ^ (bl & cl);
9626
9627 var sigma0h = ((ah >>> 28) | (al << 4)) ^ ((ah << 30) | (al >>> 2)) ^ ((ah << 25) | (al >>> 7));
9628 var sigma0l = ((al >>> 28) | (ah << 4)) ^ ((al << 30) | (ah >>> 2)) ^ ((al << 25) | (ah >>> 7));
9629 var sigma1h = ((eh >>> 14) | (el << 18)) ^ ((eh >>> 18) | (el << 14)) ^ ((eh << 23) | (el >>> 9));
9630 var sigma1l = ((el >>> 14) | (eh << 18)) ^ ((el >>> 18) | (eh << 14)) ^ ((el << 23) | (eh >>> 9));
9631
9632 // t1 = h + sigma1 + ch + K[i] + W[i]
9633 var Ki = K[i];
9634 var Kih = Ki.high;
9635 var Kil = Ki.low;
9636
9637 var t1l = hl + sigma1l;
9638 var t1h = hh + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0);
9639 var t1l = t1l + chl;
9640 var t1h = t1h + chh + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0);
9641 var t1l = t1l + Kil;
9642 var t1h = t1h + Kih + ((t1l >>> 0) < (Kil >>> 0) ? 1 : 0);
9643 var t1l = t1l + Wil;
9644 var t1h = t1h + Wih + ((t1l >>> 0) < (Wil >>> 0) ? 1 : 0);
9645
9646 // t2 = sigma0 + maj
9647 var t2l = sigma0l + majl;
9648 var t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0);
9649
9650 // Update working variables
9651 hh = gh;
9652 hl = gl;
9653 gh = fh;
9654 gl = fl;
9655 fh = eh;
9656 fl = el;
9657 el = (dl + t1l) | 0;
9658 eh = (dh + t1h + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0;
9659 dh = ch;
9660 dl = cl;
9661 ch = bh;
9662 cl = bl;
9663 bh = ah;
9664 bl = al;
9665 al = (t1l + t2l) | 0;
9666 ah = (t1h + t2h + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0;
9667 }
9668
9669 // Intermediate hash value
9670 H0l = H0.low = (H0l + al);
9671 H0.high = (H0h + ah + ((H0l >>> 0) < (al >>> 0) ? 1 : 0));
9672 H1l = H1.low = (H1l + bl);
9673 H1.high = (H1h + bh + ((H1l >>> 0) < (bl >>> 0) ? 1 : 0));
9674 H2l = H2.low = (H2l + cl);
9675 H2.high = (H2h + ch + ((H2l >>> 0) < (cl >>> 0) ? 1 : 0));
9676 H3l = H3.low = (H3l + dl);
9677 H3.high = (H3h + dh + ((H3l >>> 0) < (dl >>> 0) ? 1 : 0));
9678 H4l = H4.low = (H4l + el);
9679 H4.high = (H4h + eh + ((H4l >>> 0) < (el >>> 0) ? 1 : 0));
9680 H5l = H5.low = (H5l + fl);
9681 H5.high = (H5h + fh + ((H5l >>> 0) < (fl >>> 0) ? 1 : 0));
9682 H6l = H6.low = (H6l + gl);
9683 H6.high = (H6h + gh + ((H6l >>> 0) < (gl >>> 0) ? 1 : 0));
9684 H7l = H7.low = (H7l + hl);
9685 H7.high = (H7h + hh + ((H7l >>> 0) < (hl >>> 0) ? 1 : 0));
9686 },
9687
9688 _doFinalize: function () {
9689 // Shortcuts
9690 var data = this._data;
9691 var dataWords = data.words;
9692
9693 var nBitsTotal = this._nDataBytes * 8;
9694 var nBitsLeft = data.sigBytes * 8;
9695
9696 // Add padding
9697 dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
9698 dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 30] = Math.floor(nBitsTotal / 0x100000000);
9699 dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 31] = nBitsTotal;
9700 data.sigBytes = dataWords.length * 4;
9701
9702 // Hash final blocks
9703 this._process();
9704
9705 // Convert hash to 32-bit word array before returning
9706 var hash = this._hash.toX32();
9707
9708 // Return final computed hash
9709 return hash;
9710 },
9711
9712 clone: function () {
9713 var clone = Hasher.clone.call(this);
9714 clone._hash = this._hash.clone();
9715
9716 return clone;
9717 },
9718
9719 blockSize: 1024/32
9720 });
9721
9722 /**
9723 * Shortcut function to the hasher's object interface.
9724 *
9725 * @param {WordArray|string} message The message to hash.
9726 *
9727 * @return {WordArray} The hash.
9728 *
9729 * @static
9730 *
9731 * @example
9732 *
9733 * var hash = CryptoJS.SHA512('message');
9734 * var hash = CryptoJS.SHA512(wordArray);
9735 */
9736 C.SHA512 = Hasher._createHelper(SHA512);
9737
9738 /**
9739 * Shortcut function to the HMAC's object interface.
9740 *
9741 * @param {WordArray|string} message The message to hash.
9742 * @param {WordArray|string} key The secret key.
9743 *
9744 * @return {WordArray} The HMAC.
9745 *
9746 * @static
9747 *
9748 * @example
9749 *
9750 * var hmac = CryptoJS.HmacSHA512(message, key);
9751 */
9752 C.HmacSHA512 = Hasher._createHmacHelper(SHA512);
9753 }());
9754
9755
9756 return CryptoJS.SHA512;
9757
9758}));
9759
9760/***/ }),
9761/* 61 */
9762/***/ (function(module, exports, __webpack_require__) {
9763
9764/*
9765 This file is part of web3.js.
9766
9767 web3.js is free software: you can redistribute it and/or modify
9768 it under the terms of the GNU Lesser General Public License as published by
9769 the Free Software Foundation, either version 3 of the License, or
9770 (at your option) any later version.
9771
9772 web3.js is distributed in the hope that it will be useful,
9773 but WITHOUT ANY WARRANTY; without even the implied warranty of
9774 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9775 GNU Lesser General Public License for more details.
9776
9777 You should have received a copy of the GNU Lesser General Public License
9778 along with web3.js. If not, see <http://www.gnu.org/licenses/>.
9779*/
9780/**
9781 * @file param.js
9782 * @author Marek Kotewicz <marek@ethdev.com>
9783 * @date 2015
9784 */
9785
9786var utils = __webpack_require__(2);
9787
9788/**
9789 * SolidityParam object prototype.
9790 * Should be used when encoding, decoding solidity bytes
9791 */
9792var SolidityParam = function (value, offset) {
9793 this.value = value || '';
9794 this.offset = offset; // offset in bytes
9795};
9796
9797/**
9798 * This method should be used to get length of params's dynamic part
9799 *
9800 * @method dynamicPartLength
9801 * @returns {Number} length of dynamic part (in bytes)
9802 */
9803SolidityParam.prototype.dynamicPartLength = function () {
9804 return this.dynamicPart().length / 2;
9805};
9806
9807/**
9808 * This method should be used to create copy of solidity param with different offset
9809 *
9810 * @method withOffset
9811 * @param {Number} offset length in bytes
9812 * @returns {SolidityParam} new solidity param with applied offset
9813 */
9814SolidityParam.prototype.withOffset = function (offset) {
9815 return new SolidityParam(this.value, offset);
9816};
9817
9818/**
9819 * This method should be used to combine solidity params together
9820 * eg. when appending an array
9821 *
9822 * @method combine
9823 * @param {SolidityParam} param with which we should combine
9824 * @param {SolidityParam} result of combination
9825 */
9826SolidityParam.prototype.combine = function (param) {
9827 return new SolidityParam(this.value + param.value);
9828};
9829
9830/**
9831 * This method should be called to check if param has dynamic size.
9832 * If it has, it returns true, otherwise false
9833 *
9834 * @method isDynamic
9835 * @returns {Boolean}
9836 */
9837SolidityParam.prototype.isDynamic = function () {
9838 return this.offset !== undefined;
9839};
9840
9841/**
9842 * This method should be called to transform offset to bytes
9843 *
9844 * @method offsetAsBytes
9845 * @returns {String} bytes representation of offset
9846 */
9847SolidityParam.prototype.offsetAsBytes = function () {
9848 return !this.isDynamic() ? '' : utils.padLeft(utils.toTwosComplement(this.offset).toString(16), 64);
9849};
9850
9851/**
9852 * This method should be called to get static part of param
9853 *
9854 * @method staticPart
9855 * @returns {String} offset if it is a dynamic param, otherwise value
9856 */
9857SolidityParam.prototype.staticPart = function () {
9858 if (!this.isDynamic()) {
9859 return this.value;
9860 }
9861 return this.offsetAsBytes();
9862};
9863
9864/**
9865 * This method should be called to get dynamic part of param
9866 *
9867 * @method dynamicPart
9868 * @returns {String} returns a value if it is a dynamic param, otherwise empty string
9869 */
9870SolidityParam.prototype.dynamicPart = function () {
9871 return this.isDynamic() ? this.value : '';
9872};
9873
9874/**
9875 * This method should be called to encode param
9876 *
9877 * @method encode
9878 * @returns {String}
9879 */
9880SolidityParam.prototype.encode = function () {
9881 return this.staticPart() + this.dynamicPart();
9882};
9883
9884/**
9885 * This method should be called to encode array of params
9886 *
9887 * @method encodeList
9888 * @param {Array[SolidityParam]} params
9889 * @returns {String}
9890 */
9891SolidityParam.encodeList = function (params) {
9892
9893 // updating offsets
9894 var totalOffset = params.length * 32;
9895 var offsetParams = params.map(function (param) {
9896 if (!param.isDynamic()) {
9897 return param;
9898 }
9899 var offset = totalOffset;
9900 totalOffset += param.dynamicPartLength();
9901 return param.withOffset(offset);
9902 });
9903
9904 // encode everything!
9905 return offsetParams.reduce(function (result, param) {
9906 return result + param.dynamicPart();
9907 }, offsetParams.reduce(function (result, param) {
9908 return result + param.staticPart();
9909 }, ''));
9910};
9911
9912
9913
9914module.exports = SolidityParam;
9915
9916
9917
9918/***/ }),
9919/* 62 */
9920/***/ (function(module, exports, __webpack_require__) {
9921
9922/*
9923 This file is part of web3.js.
9924
9925 web3.js is free software: you can redistribute it and/or modify
9926 it under the terms of the GNU Lesser General Public License as published by
9927 the Free Software Foundation, either version 3 of the License, or
9928 (at your option) any later version.
9929
9930 web3.js is distributed in the hope that it will be useful,
9931 but WITHOUT ANY WARRANTY; without even the implied warranty of
9932 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9933 GNU Lesser General Public License for more details.
9934
9935 You should have received a copy of the GNU Lesser General Public License
9936 along with web3.js. If not, see <http://www.gnu.org/licenses/>.
9937*/
9938/**
9939 * @file event.js
9940 * @author Marek Kotewicz <marek@ethdev.com>
9941 * @date 2014
9942 */
9943
9944var utils = __webpack_require__(2);
9945var coder = __webpack_require__(21);
9946var formatters = __webpack_require__(5);
9947var sha3 = __webpack_require__(19);
9948var Filter = __webpack_require__(30);
9949var watches = __webpack_require__(32);
9950
9951/**
9952 * This prototype should be used to create event filters
9953 */
9954var SolidityEvent = function (requestManager, json, address) {
9955 this._requestManager = requestManager;
9956 this._params = json.inputs;
9957 this._name = utils.transformToFullName(json);
9958 this._address = address;
9959 this._anonymous = json.anonymous;
9960};
9961
9962/**
9963 * Should be used to get filtered param types
9964 *
9965 * @method types
9966 * @param {Bool} decide if returned typed should be indexed
9967 * @return {Array} array of types
9968 */
9969SolidityEvent.prototype.types = function (indexed) {
9970 return this._params.filter(function (i) {
9971 return i.indexed === indexed;
9972 }).map(function (i) {
9973 return i.type;
9974 });
9975};
9976
9977/**
9978 * Should be used to get event display name
9979 *
9980 * @method displayName
9981 * @return {String} event display name
9982 */
9983SolidityEvent.prototype.displayName = function () {
9984 return utils.extractDisplayName(this._name);
9985};
9986
9987/**
9988 * Should be used to get event type name
9989 *
9990 * @method typeName
9991 * @return {String} event type name
9992 */
9993SolidityEvent.prototype.typeName = function () {
9994 return utils.extractTypeName(this._name);
9995};
9996
9997/**
9998 * Should be used to get event signature
9999 *
10000 * @method signature
10001 * @return {String} event signature
10002 */
10003SolidityEvent.prototype.signature = function () {
10004 return sha3(this._name);
10005};
10006
10007/**
10008 * Should be used to encode indexed params and options to one final object
10009 *
10010 * @method encode
10011 * @param {Object} indexed
10012 * @param {Object} options
10013 * @return {Object} everything combined together and encoded
10014 */
10015SolidityEvent.prototype.encode = function (indexed, options) {
10016 indexed = indexed || {};
10017 options = options || {};
10018 var result = {};
10019
10020 ['fromBlock', 'toBlock'].filter(function (f) {
10021 return options[f] !== undefined;
10022 }).forEach(function (f) {
10023 result[f] = formatters.inputBlockNumberFormatter(options[f]);
10024 });
10025
10026 result.topics = [];
10027
10028 result.address = this._address;
10029 if (!this._anonymous) {
10030 result.topics.push('0x' + this.signature());
10031 }
10032
10033 var indexedTopics = this._params.filter(function (i) {
10034 return i.indexed === true;
10035 }).map(function (i) {
10036 var value = indexed[i.name];
10037 if (value === undefined || value === null) {
10038 return null;
10039 }
10040
10041 if (utils.isArray(value)) {
10042 return value.map(function (v) {
10043 return '0x' + coder.encodeParam(i.type, v);
10044 });
10045 }
10046 return '0x' + coder.encodeParam(i.type, value);
10047 });
10048
10049 result.topics = result.topics.concat(indexedTopics);
10050
10051 return result;
10052};
10053
10054/**
10055 * Should be used to decode indexed params and options
10056 *
10057 * @method decode
10058 * @param {Object} data
10059 * @return {Object} result object with decoded indexed && not indexed params
10060 */
10061SolidityEvent.prototype.decode = function (data) {
10062
10063 data.data = data.data || '';
10064 data.topics = data.topics || [];
10065
10066 var argTopics = this._anonymous ? data.topics : data.topics.slice(1);
10067 var indexedData = argTopics.map(function (topics) { return topics.slice(2); }).join("");
10068 var indexedParams = coder.decodeParams(this.types(true), indexedData);
10069
10070 var notIndexedData = data.data.slice(2);
10071 var notIndexedParams = coder.decodeParams(this.types(false), notIndexedData);
10072
10073 var result = formatters.outputLogFormatter(data);
10074 result.event = this.displayName();
10075 result.address = data.address;
10076
10077 result.args = this._params.reduce(function (acc, current) {
10078 acc[current.name] = current.indexed ? indexedParams.shift() : notIndexedParams.shift();
10079 return acc;
10080 }, {});
10081
10082 delete result.data;
10083 delete result.topics;
10084
10085 return result;
10086};
10087
10088/**
10089 * Should be used to create new filter object from event
10090 *
10091 * @method execute
10092 * @param {Object} indexed
10093 * @param {Object} options
10094 * @return {Object} filter object
10095 */
10096SolidityEvent.prototype.execute = function (indexed, options, callback) {
10097
10098 if (utils.isFunction(arguments[arguments.length - 1])) {
10099 callback = arguments[arguments.length - 1];
10100 if(arguments.length === 2)
10101 options = null;
10102 if(arguments.length === 1) {
10103 options = null;
10104 indexed = {};
10105 }
10106 }
10107
10108 var o = this.encode(indexed, options);
10109 var formatter = this.decode.bind(this);
10110 return new Filter(this._requestManager, o, watches.eth(), formatter, callback);
10111};
10112
10113/**
10114 * Should be used to attach event to contract object
10115 *
10116 * @method attachToContract
10117 * @param {Contract}
10118 */
10119SolidityEvent.prototype.attachToContract = function (contract) {
10120 var execute = this.execute.bind(this);
10121 var displayName = this.displayName();
10122 if (!contract[displayName]) {
10123 contract[displayName] = execute;
10124 }
10125 contract[displayName][this.typeName()] = this.execute.bind(this, contract);
10126};
10127
10128module.exports = SolidityEvent;
10129
10130
10131
10132/***/ }),
10133/* 63 */
10134/***/ (function(module, exports) {
10135
10136/*
10137 This file is part of web3.js.
10138
10139 web3.js is free software: you can redistribute it and/or modify
10140 it under the terms of the GNU Lesser General Public License as published by
10141 the Free Software Foundation, either version 3 of the License, or
10142 (at your option) any later version.
10143
10144 web3.js is distributed in the hope that it will be useful,
10145 but WITHOUT ANY WARRANTY; without even the implied warranty of
10146 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10147 GNU Lesser General Public License for more details.
10148
10149 You should have received a copy of the GNU Lesser General Public License
10150 along with web3.js. If not, see <http://www.gnu.org/licenses/>.
10151*/
10152/** @file jsonrpc.js
10153 * @authors:
10154 * Marek Kotewicz <marek@ethdev.com>
10155 * Aaron Kumavis <aaron@kumavis.me>
10156 * @date 2015
10157 */
10158
10159// Initialize Jsonrpc as a simple object with utility functions.
10160var Jsonrpc = {
10161 messageId: 0
10162};
10163
10164/**
10165 * Should be called to valid json create payload object
10166 *
10167 * @method toPayload
10168 * @param {Function} method of jsonrpc call, required
10169 * @param {Array} params, an array of method params, optional
10170 * @returns {Object} valid jsonrpc payload object
10171 */
10172Jsonrpc.toPayload = function (method, params) {
10173 if (!method)
10174 console.error('jsonrpc method should be specified!');
10175
10176 // advance message ID
10177 Jsonrpc.messageId++;
10178
10179 return {
10180 jsonrpc: '2.0',
10181 id: Jsonrpc.messageId,
10182 method: method,
10183 params: params || []
10184 };
10185};
10186
10187/**
10188 * Should be called to check if jsonrpc response is valid
10189 *
10190 * @method isValidResponse
10191 * @param {Object}
10192 * @returns {Boolean} true if response is valid, otherwise false
10193 */
10194Jsonrpc.isValidResponse = function (response) {
10195 return Array.isArray(response) ? response.every(validateSingleMessage) : validateSingleMessage(response);
10196
10197 function validateSingleMessage(message){
10198 return !!message &&
10199 !message.error &&
10200 message.jsonrpc === '2.0' &&
10201 typeof message.id === 'number' &&
10202 message.result !== undefined; // only undefined is not valid json object
10203 }
10204};
10205
10206/**
10207 * Should be called to create batch payload object
10208 *
10209 * @method toBatchPayload
10210 * @param {Array} messages, an array of objects with method (required) and params (optional) fields
10211 * @returns {Array} batch payload
10212 */
10213Jsonrpc.toBatchPayload = function (messages) {
10214 return messages.map(function (message) {
10215 return Jsonrpc.toPayload(message.method, message.params);
10216 });
10217};
10218
10219module.exports = Jsonrpc;
10220
10221
10222
10223/***/ }),
10224/* 64 */
10225/***/ (function(module, exports, __webpack_require__) {
10226
10227"use strict";
10228
10229
10230exports.__esModule = true;
10231
10232var _iterator = __webpack_require__(67);
10233
10234var _iterator2 = _interopRequireDefault(_iterator);
10235
10236var _symbol = __webpack_require__(66);
10237
10238var _symbol2 = _interopRequireDefault(_symbol);
10239
10240var _typeof = typeof _symbol2.default === "function" && typeof _iterator2.default === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj; };
10241
10242function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10243
10244exports.default = typeof _symbol2.default === "function" && _typeof(_iterator2.default) === "symbol" ? function (obj) {
10245 return typeof obj === "undefined" ? "undefined" : _typeof(obj);
10246} : function (obj) {
10247 return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof(obj);
10248};
10249
10250/***/ }),
10251/* 65 */
10252/***/ (function(module, exports, __webpack_require__) {
10253
10254var Web3 = __webpack_require__(135);
10255
10256// dont override global variable
10257if (typeof window !== 'undefined' && typeof window.Web3 === 'undefined') {
10258 window.Web3 = Web3;
10259}
10260
10261module.exports = Web3;
10262
10263
10264/***/ }),
10265/* 66 */
10266/***/ (function(module, exports, __webpack_require__) {
10267
10268module.exports = { "default": __webpack_require__(68), __esModule: true };
10269
10270/***/ }),
10271/* 67 */
10272/***/ (function(module, exports, __webpack_require__) {
10273
10274module.exports = { "default": __webpack_require__(69), __esModule: true };
10275
10276/***/ }),
10277/* 68 */
10278/***/ (function(module, exports, __webpack_require__) {
10279
10280__webpack_require__(93);
10281__webpack_require__(91);
10282__webpack_require__(94);
10283__webpack_require__(95);
10284module.exports = __webpack_require__(33).Symbol;
10285
10286/***/ }),
10287/* 69 */
10288/***/ (function(module, exports, __webpack_require__) {
10289
10290__webpack_require__(92);
10291__webpack_require__(96);
10292module.exports = __webpack_require__(45).f('iterator');
10293
10294/***/ }),
10295/* 70 */
10296/***/ (function(module, exports) {
10297
10298module.exports = function(it){
10299 if(typeof it != 'function')throw TypeError(it + ' is not a function!');
10300 return it;
10301};
10302
10303/***/ }),
10304/* 71 */
10305/***/ (function(module, exports) {
10306
10307module.exports = function(){ /* empty */ };
10308
10309/***/ }),
10310/* 72 */
10311/***/ (function(module, exports, __webpack_require__) {
10312
10313// false -> Array#indexOf
10314// true -> Array#includes
10315var toIObject = __webpack_require__(8)
10316 , toLength = __webpack_require__(88)
10317 , toIndex = __webpack_require__(87);
10318module.exports = function(IS_INCLUDES){
10319 return function($this, el, fromIndex){
10320 var O = toIObject($this)
10321 , length = toLength(O.length)
10322 , index = toIndex(fromIndex, length)
10323 , value;
10324 // Array#includes uses SameValueZero equality algorithm
10325 if(IS_INCLUDES && el != el)while(length > index){
10326 value = O[index++];
10327 if(value != value)return true;
10328 // Array#toIndex ignores holes, Array#includes - not
10329 } else for(;length > index; index++)if(IS_INCLUDES || index in O){
10330 if(O[index] === el)return IS_INCLUDES || index || 0;
10331 } return !IS_INCLUDES && -1;
10332 };
10333};
10334
10335/***/ }),
10336/* 73 */
10337/***/ (function(module, exports, __webpack_require__) {
10338
10339// optional / simple context binding
10340var aFunction = __webpack_require__(70);
10341module.exports = function(fn, that, length){
10342 aFunction(fn);
10343 if(that === undefined)return fn;
10344 switch(length){
10345 case 1: return function(a){
10346 return fn.call(that, a);
10347 };
10348 case 2: return function(a, b){
10349 return fn.call(that, a, b);
10350 };
10351 case 3: return function(a, b, c){
10352 return fn.call(that, a, b, c);
10353 };
10354 }
10355 return function(/* ...args */){
10356 return fn.apply(that, arguments);
10357 };
10358};
10359
10360/***/ }),
10361/* 74 */
10362/***/ (function(module, exports, __webpack_require__) {
10363
10364// all enumerable object keys, includes symbols
10365var getKeys = __webpack_require__(25)
10366 , gOPS = __webpack_require__(55)
10367 , pIE = __webpack_require__(38);
10368module.exports = function(it){
10369 var result = getKeys(it)
10370 , getSymbols = gOPS.f;
10371 if(getSymbols){
10372 var symbols = getSymbols(it)
10373 , isEnum = pIE.f
10374 , i = 0
10375 , key;
10376 while(symbols.length > i)if(isEnum.call(it, key = symbols[i++]))result.push(key);
10377 } return result;
10378};
10379
10380/***/ }),
10381/* 75 */
10382/***/ (function(module, exports, __webpack_require__) {
10383
10384module.exports = __webpack_require__(6).document && document.documentElement;
10385
10386/***/ }),
10387/* 76 */
10388/***/ (function(module, exports, __webpack_require__) {
10389
10390// fallback for non-array-like ES3 and non-enumerable old V8 strings
10391var cof = __webpack_require__(48);
10392module.exports = Object('z').propertyIsEnumerable(0) ? Object : function(it){
10393 return cof(it) == 'String' ? it.split('') : Object(it);
10394};
10395
10396/***/ }),
10397/* 77 */
10398/***/ (function(module, exports, __webpack_require__) {
10399
10400// 7.2.2 IsArray(argument)
10401var cof = __webpack_require__(48);
10402module.exports = Array.isArray || function isArray(arg){
10403 return cof(arg) == 'Array';
10404};
10405
10406/***/ }),
10407/* 78 */
10408/***/ (function(module, exports, __webpack_require__) {
10409
10410"use strict";
10411
10412var create = __webpack_require__(53)
10413 , descriptor = __webpack_require__(26)
10414 , setToStringTag = __webpack_require__(39)
10415 , IteratorPrototype = {};
10416
10417// 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
10418__webpack_require__(11)(IteratorPrototype, __webpack_require__(13)('iterator'), function(){ return this; });
10419
10420module.exports = function(Constructor, NAME, next){
10421 Constructor.prototype = create(IteratorPrototype, {next: descriptor(1, next)});
10422 setToStringTag(Constructor, NAME + ' Iterator');
10423};
10424
10425/***/ }),
10426/* 79 */
10427/***/ (function(module, exports) {
10428
10429module.exports = function(done, value){
10430 return {value: value, done: !!done};
10431};
10432
10433/***/ }),
10434/* 80 */
10435/***/ (function(module, exports, __webpack_require__) {
10436
10437var getKeys = __webpack_require__(25)
10438 , toIObject = __webpack_require__(8);
10439module.exports = function(object, el){
10440 var O = toIObject(object)
10441 , keys = getKeys(O)
10442 , length = keys.length
10443 , index = 0
10444 , key;
10445 while(length > index)if(O[key = keys[index++]] === el)return key;
10446};
10447
10448/***/ }),
10449/* 81 */
10450/***/ (function(module, exports, __webpack_require__) {
10451
10452var META = __webpack_require__(27)('meta')
10453 , isObject = __webpack_require__(24)
10454 , has = __webpack_require__(7)
10455 , setDesc = __webpack_require__(12).f
10456 , id = 0;
10457var isExtensible = Object.isExtensible || function(){
10458 return true;
10459};
10460var FREEZE = !__webpack_require__(23)(function(){
10461 return isExtensible(Object.preventExtensions({}));
10462});
10463var setMeta = function(it){
10464 setDesc(it, META, {value: {
10465 i: 'O' + ++id, // object ID
10466 w: {} // weak collections IDs
10467 }});
10468};
10469var fastKey = function(it, create){
10470 // return primitive with prefix
10471 if(!isObject(it))return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
10472 if(!has(it, META)){
10473 // can't set metadata to uncaught frozen object
10474 if(!isExtensible(it))return 'F';
10475 // not necessary to add metadata
10476 if(!create)return 'E';
10477 // add missing metadata
10478 setMeta(it);
10479 // return object ID
10480 } return it[META].i;
10481};
10482var getWeak = function(it, create){
10483 if(!has(it, META)){
10484 // can't set metadata to uncaught frozen object
10485 if(!isExtensible(it))return true;
10486 // not necessary to add metadata
10487 if(!create)return false;
10488 // add missing metadata
10489 setMeta(it);
10490 // return hash weak collections IDs
10491 } return it[META].w;
10492};
10493// add metadata on freeze-family methods calling
10494var onFreeze = function(it){
10495 if(FREEZE && meta.NEED && isExtensible(it) && !has(it, META))setMeta(it);
10496 return it;
10497};
10498var meta = module.exports = {
10499 KEY: META,
10500 NEED: false,
10501 fastKey: fastKey,
10502 getWeak: getWeak,
10503 onFreeze: onFreeze
10504};
10505
10506/***/ }),
10507/* 82 */
10508/***/ (function(module, exports, __webpack_require__) {
10509
10510var dP = __webpack_require__(12)
10511 , anObject = __webpack_require__(22)
10512 , getKeys = __webpack_require__(25);
10513
10514module.exports = __webpack_require__(10) ? Object.defineProperties : function defineProperties(O, Properties){
10515 anObject(O);
10516 var keys = getKeys(Properties)
10517 , length = keys.length
10518 , i = 0
10519 , P;
10520 while(length > i)dP.f(O, P = keys[i++], Properties[P]);
10521 return O;
10522};
10523
10524/***/ }),
10525/* 83 */
10526/***/ (function(module, exports, __webpack_require__) {
10527
10528var pIE = __webpack_require__(38)
10529 , createDesc = __webpack_require__(26)
10530 , toIObject = __webpack_require__(8)
10531 , toPrimitive = __webpack_require__(43)
10532 , has = __webpack_require__(7)
10533 , IE8_DOM_DEFINE = __webpack_require__(51)
10534 , gOPD = Object.getOwnPropertyDescriptor;
10535
10536exports.f = __webpack_require__(10) ? gOPD : function getOwnPropertyDescriptor(O, P){
10537 O = toIObject(O);
10538 P = toPrimitive(P, true);
10539 if(IE8_DOM_DEFINE)try {
10540 return gOPD(O, P);
10541 } catch(e){ /* empty */ }
10542 if(has(O, P))return createDesc(!pIE.f.call(O, P), O[P]);
10543};
10544
10545/***/ }),
10546/* 84 */
10547/***/ (function(module, exports, __webpack_require__) {
10548
10549// fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
10550var toIObject = __webpack_require__(8)
10551 , gOPN = __webpack_require__(54).f
10552 , toString = {}.toString;
10553
10554var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
10555 ? Object.getOwnPropertyNames(window) : [];
10556
10557var getWindowNames = function(it){
10558 try {
10559 return gOPN(it);
10560 } catch(e){
10561 return windowNames.slice();
10562 }
10563};
10564
10565module.exports.f = function getOwnPropertyNames(it){
10566 return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it));
10567};
10568
10569
10570/***/ }),
10571/* 85 */
10572/***/ (function(module, exports, __webpack_require__) {
10573
10574// 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
10575var has = __webpack_require__(7)
10576 , toObject = __webpack_require__(89)
10577 , IE_PROTO = __webpack_require__(40)('IE_PROTO')
10578 , ObjectProto = Object.prototype;
10579
10580module.exports = Object.getPrototypeOf || function(O){
10581 O = toObject(O);
10582 if(has(O, IE_PROTO))return O[IE_PROTO];
10583 if(typeof O.constructor == 'function' && O instanceof O.constructor){
10584 return O.constructor.prototype;
10585 } return O instanceof Object ? ObjectProto : null;
10586};
10587
10588/***/ }),
10589/* 86 */
10590/***/ (function(module, exports, __webpack_require__) {
10591
10592var toInteger = __webpack_require__(42)
10593 , defined = __webpack_require__(34);
10594// true -> String#at
10595// false -> String#codePointAt
10596module.exports = function(TO_STRING){
10597 return function(that, pos){
10598 var s = String(defined(that))
10599 , i = toInteger(pos)
10600 , l = s.length
10601 , a, b;
10602 if(i < 0 || i >= l)return TO_STRING ? '' : undefined;
10603 a = s.charCodeAt(i);
10604 return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
10605 ? TO_STRING ? s.charAt(i) : a
10606 : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
10607 };
10608};
10609
10610/***/ }),
10611/* 87 */
10612/***/ (function(module, exports, __webpack_require__) {
10613
10614var toInteger = __webpack_require__(42)
10615 , max = Math.max
10616 , min = Math.min;
10617module.exports = function(index, length){
10618 index = toInteger(index);
10619 return index < 0 ? max(index + length, 0) : min(index, length);
10620};
10621
10622/***/ }),
10623/* 88 */
10624/***/ (function(module, exports, __webpack_require__) {
10625
10626// 7.1.15 ToLength
10627var toInteger = __webpack_require__(42)
10628 , min = Math.min;
10629module.exports = function(it){
10630 return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
10631};
10632
10633/***/ }),
10634/* 89 */
10635/***/ (function(module, exports, __webpack_require__) {
10636
10637// 7.1.13 ToObject(argument)
10638var defined = __webpack_require__(34);
10639module.exports = function(it){
10640 return Object(defined(it));
10641};
10642
10643/***/ }),
10644/* 90 */
10645/***/ (function(module, exports, __webpack_require__) {
10646
10647"use strict";
10648
10649var addToUnscopables = __webpack_require__(71)
10650 , step = __webpack_require__(79)
10651 , Iterators = __webpack_require__(36)
10652 , toIObject = __webpack_require__(8);
10653
10654// 22.1.3.4 Array.prototype.entries()
10655// 22.1.3.13 Array.prototype.keys()
10656// 22.1.3.29 Array.prototype.values()
10657// 22.1.3.30 Array.prototype[@@iterator]()
10658module.exports = __webpack_require__(52)(Array, 'Array', function(iterated, kind){
10659 this._t = toIObject(iterated); // target
10660 this._i = 0; // next index
10661 this._k = kind; // kind
10662// 22.1.5.2.1 %ArrayIteratorPrototype%.next()
10663}, function(){
10664 var O = this._t
10665 , kind = this._k
10666 , index = this._i++;
10667 if(!O || index >= O.length){
10668 this._t = undefined;
10669 return step(1);
10670 }
10671 if(kind == 'keys' )return step(0, index);
10672 if(kind == 'values')return step(0, O[index]);
10673 return step(0, [index, O[index]]);
10674}, 'values');
10675
10676// argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
10677Iterators.Arguments = Iterators.Array;
10678
10679addToUnscopables('keys');
10680addToUnscopables('values');
10681addToUnscopables('entries');
10682
10683/***/ }),
10684/* 91 */
10685/***/ (function(module, exports) {
10686
10687
10688
10689/***/ }),
10690/* 92 */
10691/***/ (function(module, exports, __webpack_require__) {
10692
10693"use strict";
10694
10695var $at = __webpack_require__(86)(true);
10696
10697// 21.1.3.27 String.prototype[@@iterator]()
10698__webpack_require__(52)(String, 'String', function(iterated){
10699 this._t = String(iterated); // target
10700 this._i = 0; // next index
10701// 21.1.5.2.1 %StringIteratorPrototype%.next()
10702}, function(){
10703 var O = this._t
10704 , index = this._i
10705 , point;
10706 if(index >= O.length)return {value: undefined, done: true};
10707 point = $at(O, index);
10708 this._i += point.length;
10709 return {value: point, done: false};
10710});
10711
10712/***/ }),
10713/* 93 */
10714/***/ (function(module, exports, __webpack_require__) {
10715
10716"use strict";
10717
10718// ECMAScript 6 symbols shim
10719var global = __webpack_require__(6)
10720 , has = __webpack_require__(7)
10721 , DESCRIPTORS = __webpack_require__(10)
10722 , $export = __webpack_require__(50)
10723 , redefine = __webpack_require__(57)
10724 , META = __webpack_require__(81).KEY
10725 , $fails = __webpack_require__(23)
10726 , shared = __webpack_require__(41)
10727 , setToStringTag = __webpack_require__(39)
10728 , uid = __webpack_require__(27)
10729 , wks = __webpack_require__(13)
10730 , wksExt = __webpack_require__(45)
10731 , wksDefine = __webpack_require__(44)
10732 , keyOf = __webpack_require__(80)
10733 , enumKeys = __webpack_require__(74)
10734 , isArray = __webpack_require__(77)
10735 , anObject = __webpack_require__(22)
10736 , toIObject = __webpack_require__(8)
10737 , toPrimitive = __webpack_require__(43)
10738 , createDesc = __webpack_require__(26)
10739 , _create = __webpack_require__(53)
10740 , gOPNExt = __webpack_require__(84)
10741 , $GOPD = __webpack_require__(83)
10742 , $DP = __webpack_require__(12)
10743 , $keys = __webpack_require__(25)
10744 , gOPD = $GOPD.f
10745 , dP = $DP.f
10746 , gOPN = gOPNExt.f
10747 , $Symbol = global.Symbol
10748 , $JSON = global.JSON
10749 , _stringify = $JSON && $JSON.stringify
10750 , PROTOTYPE = 'prototype'
10751 , HIDDEN = wks('_hidden')
10752 , TO_PRIMITIVE = wks('toPrimitive')
10753 , isEnum = {}.propertyIsEnumerable
10754 , SymbolRegistry = shared('symbol-registry')
10755 , AllSymbols = shared('symbols')
10756 , OPSymbols = shared('op-symbols')
10757 , ObjectProto = Object[PROTOTYPE]
10758 , USE_NATIVE = typeof $Symbol == 'function'
10759 , QObject = global.QObject;
10760// Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
10761var setter = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
10762
10763// fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
10764var setSymbolDesc = DESCRIPTORS && $fails(function(){
10765 return _create(dP({}, 'a', {
10766 get: function(){ return dP(this, 'a', {value: 7}).a; }
10767 })).a != 7;
10768}) ? function(it, key, D){
10769 var protoDesc = gOPD(ObjectProto, key);
10770 if(protoDesc)delete ObjectProto[key];
10771 dP(it, key, D);
10772 if(protoDesc && it !== ObjectProto)dP(ObjectProto, key, protoDesc);
10773} : dP;
10774
10775var wrap = function(tag){
10776 var sym = AllSymbols[tag] = _create($Symbol[PROTOTYPE]);
10777 sym._k = tag;
10778 return sym;
10779};
10780
10781var isSymbol = USE_NATIVE && typeof $Symbol.iterator == 'symbol' ? function(it){
10782 return typeof it == 'symbol';
10783} : function(it){
10784 return it instanceof $Symbol;
10785};
10786
10787var $defineProperty = function defineProperty(it, key, D){
10788 if(it === ObjectProto)$defineProperty(OPSymbols, key, D);
10789 anObject(it);
10790 key = toPrimitive(key, true);
10791 anObject(D);
10792 if(has(AllSymbols, key)){
10793 if(!D.enumerable){
10794 if(!has(it, HIDDEN))dP(it, HIDDEN, createDesc(1, {}));
10795 it[HIDDEN][key] = true;
10796 } else {
10797 if(has(it, HIDDEN) && it[HIDDEN][key])it[HIDDEN][key] = false;
10798 D = _create(D, {enumerable: createDesc(0, false)});
10799 } return setSymbolDesc(it, key, D);
10800 } return dP(it, key, D);
10801};
10802var $defineProperties = function defineProperties(it, P){
10803 anObject(it);
10804 var keys = enumKeys(P = toIObject(P))
10805 , i = 0
10806 , l = keys.length
10807 , key;
10808 while(l > i)$defineProperty(it, key = keys[i++], P[key]);
10809 return it;
10810};
10811var $create = function create(it, P){
10812 return P === undefined ? _create(it) : $defineProperties(_create(it), P);
10813};
10814var $propertyIsEnumerable = function propertyIsEnumerable(key){
10815 var E = isEnum.call(this, key = toPrimitive(key, true));
10816 if(this === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key))return false;
10817 return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] ? E : true;
10818};
10819var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key){
10820 it = toIObject(it);
10821 key = toPrimitive(key, true);
10822 if(it === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key))return;
10823 var D = gOPD(it, key);
10824 if(D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key]))D.enumerable = true;
10825 return D;
10826};
10827var $getOwnPropertyNames = function getOwnPropertyNames(it){
10828 var names = gOPN(toIObject(it))
10829 , result = []
10830 , i = 0
10831 , key;
10832 while(names.length > i){
10833 if(!has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META)result.push(key);
10834 } return result;
10835};
10836var $getOwnPropertySymbols = function getOwnPropertySymbols(it){
10837 var IS_OP = it === ObjectProto
10838 , names = gOPN(IS_OP ? OPSymbols : toIObject(it))
10839 , result = []
10840 , i = 0
10841 , key;
10842 while(names.length > i){
10843 if(has(AllSymbols, key = names[i++]) && (IS_OP ? has(ObjectProto, key) : true))result.push(AllSymbols[key]);
10844 } return result;
10845};
10846
10847// 19.4.1.1 Symbol([description])
10848if(!USE_NATIVE){
10849 $Symbol = function Symbol(){
10850 if(this instanceof $Symbol)throw TypeError('Symbol is not a constructor!');
10851 var tag = uid(arguments.length > 0 ? arguments[0] : undefined);
10852 var $set = function(value){
10853 if(this === ObjectProto)$set.call(OPSymbols, value);
10854 if(has(this, HIDDEN) && has(this[HIDDEN], tag))this[HIDDEN][tag] = false;
10855 setSymbolDesc(this, tag, createDesc(1, value));
10856 };
10857 if(DESCRIPTORS && setter)setSymbolDesc(ObjectProto, tag, {configurable: true, set: $set});
10858 return wrap(tag);
10859 };
10860 redefine($Symbol[PROTOTYPE], 'toString', function toString(){
10861 return this._k;
10862 });
10863
10864 $GOPD.f = $getOwnPropertyDescriptor;
10865 $DP.f = $defineProperty;
10866 __webpack_require__(54).f = gOPNExt.f = $getOwnPropertyNames;
10867 __webpack_require__(38).f = $propertyIsEnumerable;
10868 __webpack_require__(55).f = $getOwnPropertySymbols;
10869
10870 if(DESCRIPTORS && !__webpack_require__(37)){
10871 redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true);
10872 }
10873
10874 wksExt.f = function(name){
10875 return wrap(wks(name));
10876 }
10877}
10878
10879$export($export.G + $export.W + $export.F * !USE_NATIVE, {Symbol: $Symbol});
10880
10881for(var symbols = (
10882 // 19.4.2.2, 19.4.2.3, 19.4.2.4, 19.4.2.6, 19.4.2.8, 19.4.2.9, 19.4.2.10, 19.4.2.11, 19.4.2.12, 19.4.2.13, 19.4.2.14
10883 'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables'
10884).split(','), i = 0; symbols.length > i; )wks(symbols[i++]);
10885
10886for(var symbols = $keys(wks.store), i = 0; symbols.length > i; )wksDefine(symbols[i++]);
10887
10888$export($export.S + $export.F * !USE_NATIVE, 'Symbol', {
10889 // 19.4.2.1 Symbol.for(key)
10890 'for': function(key){
10891 return has(SymbolRegistry, key += '')
10892 ? SymbolRegistry[key]
10893 : SymbolRegistry[key] = $Symbol(key);
10894 },
10895 // 19.4.2.5 Symbol.keyFor(sym)
10896 keyFor: function keyFor(key){
10897 if(isSymbol(key))return keyOf(SymbolRegistry, key);
10898 throw TypeError(key + ' is not a symbol!');
10899 },
10900 useSetter: function(){ setter = true; },
10901 useSimple: function(){ setter = false; }
10902});
10903
10904$export($export.S + $export.F * !USE_NATIVE, 'Object', {
10905 // 19.1.2.2 Object.create(O [, Properties])
10906 create: $create,
10907 // 19.1.2.4 Object.defineProperty(O, P, Attributes)
10908 defineProperty: $defineProperty,
10909 // 19.1.2.3 Object.defineProperties(O, Properties)
10910 defineProperties: $defineProperties,
10911 // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
10912 getOwnPropertyDescriptor: $getOwnPropertyDescriptor,
10913 // 19.1.2.7 Object.getOwnPropertyNames(O)
10914 getOwnPropertyNames: $getOwnPropertyNames,
10915 // 19.1.2.8 Object.getOwnPropertySymbols(O)
10916 getOwnPropertySymbols: $getOwnPropertySymbols
10917});
10918
10919// 24.3.2 JSON.stringify(value [, replacer [, space]])
10920$JSON && $export($export.S + $export.F * (!USE_NATIVE || $fails(function(){
10921 var S = $Symbol();
10922 // MS Edge converts symbol values to JSON as {}
10923 // WebKit converts symbol values to JSON as null
10924 // V8 throws on boxed symbols
10925 return _stringify([S]) != '[null]' || _stringify({a: S}) != '{}' || _stringify(Object(S)) != '{}';
10926})), 'JSON', {
10927 stringify: function stringify(it){
10928 if(it === undefined || isSymbol(it))return; // IE8 returns string on undefined
10929 var args = [it]
10930 , i = 1
10931 , replacer, $replacer;
10932 while(arguments.length > i)args.push(arguments[i++]);
10933 replacer = args[1];
10934 if(typeof replacer == 'function')$replacer = replacer;
10935 if($replacer || !isArray(replacer))replacer = function(key, value){
10936 if($replacer)value = $replacer.call(this, key, value);
10937 if(!isSymbol(value))return value;
10938 };
10939 args[1] = replacer;
10940 return _stringify.apply($JSON, args);
10941 }
10942});
10943
10944// 19.4.3.4 Symbol.prototype[@@toPrimitive](hint)
10945$Symbol[PROTOTYPE][TO_PRIMITIVE] || __webpack_require__(11)($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);
10946// 19.4.3.5 Symbol.prototype[@@toStringTag]
10947setToStringTag($Symbol, 'Symbol');
10948// 20.2.1.9 Math[@@toStringTag]
10949setToStringTag(Math, 'Math', true);
10950// 24.3.3 JSON[@@toStringTag]
10951setToStringTag(global.JSON, 'JSON', true);
10952
10953/***/ }),
10954/* 94 */
10955/***/ (function(module, exports, __webpack_require__) {
10956
10957__webpack_require__(44)('asyncIterator');
10958
10959/***/ }),
10960/* 95 */
10961/***/ (function(module, exports, __webpack_require__) {
10962
10963__webpack_require__(44)('observable');
10964
10965/***/ }),
10966/* 96 */
10967/***/ (function(module, exports, __webpack_require__) {
10968
10969__webpack_require__(90);
10970var global = __webpack_require__(6)
10971 , hide = __webpack_require__(11)
10972 , Iterators = __webpack_require__(36)
10973 , TO_STRING_TAG = __webpack_require__(13)('toStringTag');
10974
10975for(var collections = ['NodeList', 'DOMTokenList', 'MediaList', 'StyleSheetList', 'CSSRuleList'], i = 0; i < 5; i++){
10976 var NAME = collections[i]
10977 , Collection = global[NAME]
10978 , proto = Collection && Collection.prototype;
10979 if(proto && !proto[TO_STRING_TAG])hide(proto, TO_STRING_TAG, NAME);
10980 Iterators[NAME] = Iterators.Array;
10981}
10982
10983/***/ }),
10984/* 97 */
10985/***/ (function(module, exports, __webpack_require__) {
10986
10987;(function (root, factory, undef) {
10988 if (true) {
10989 // CommonJS
10990 module.exports = exports = factory(__webpack_require__(0), __webpack_require__(14), __webpack_require__(16), __webpack_require__(15), __webpack_require__(1));
10991 }
10992 else if (typeof define === "function" && define.amd) {
10993 // AMD
10994 define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
10995 }
10996 else {
10997 // Global (browser)
10998 factory(root.CryptoJS);
10999 }
11000}(this, function (CryptoJS) {
11001
11002 (function () {
11003 // Shortcuts
11004 var C = CryptoJS;
11005 var C_lib = C.lib;
11006 var BlockCipher = C_lib.BlockCipher;
11007 var C_algo = C.algo;
11008
11009 // Lookup tables
11010 var SBOX = [];
11011 var INV_SBOX = [];
11012 var SUB_MIX_0 = [];
11013 var SUB_MIX_1 = [];
11014 var SUB_MIX_2 = [];
11015 var SUB_MIX_3 = [];
11016 var INV_SUB_MIX_0 = [];
11017 var INV_SUB_MIX_1 = [];
11018 var INV_SUB_MIX_2 = [];
11019 var INV_SUB_MIX_3 = [];
11020
11021 // Compute lookup tables
11022 (function () {
11023 // Compute double table
11024 var d = [];
11025 for (var i = 0; i < 256; i++) {
11026 if (i < 128) {
11027 d[i] = i << 1;
11028 } else {
11029 d[i] = (i << 1) ^ 0x11b;
11030 }
11031 }
11032
11033 // Walk GF(2^8)
11034 var x = 0;
11035 var xi = 0;
11036 for (var i = 0; i < 256; i++) {
11037 // Compute sbox
11038 var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
11039 sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
11040 SBOX[x] = sx;
11041 INV_SBOX[sx] = x;
11042
11043 // Compute multiplication
11044 var x2 = d[x];
11045 var x4 = d[x2];
11046 var x8 = d[x4];
11047
11048 // Compute sub bytes, mix columns tables
11049 var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
11050 SUB_MIX_0[x] = (t << 24) | (t >>> 8);
11051 SUB_MIX_1[x] = (t << 16) | (t >>> 16);
11052 SUB_MIX_2[x] = (t << 8) | (t >>> 24);
11053 SUB_MIX_3[x] = t;
11054
11055 // Compute inv sub bytes, inv mix columns tables
11056 var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
11057 INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
11058 INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
11059 INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24);
11060 INV_SUB_MIX_3[sx] = t;
11061
11062 // Compute next counter
11063 if (!x) {
11064 x = xi = 1;
11065 } else {
11066 x = x2 ^ d[d[d[x8 ^ x2]]];
11067 xi ^= d[d[xi]];
11068 }
11069 }
11070 }());
11071
11072 // Precomputed Rcon lookup
11073 var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
11074
11075 /**
11076 * AES block cipher algorithm.
11077 */
11078 var AES = C_algo.AES = BlockCipher.extend({
11079 _doReset: function () {
11080 // Skip reset of nRounds has been set before and key did not change
11081 if (this._nRounds && this._keyPriorReset === this._key) {
11082 return;
11083 }
11084
11085 // Shortcuts
11086 var key = this._keyPriorReset = this._key;
11087 var keyWords = key.words;
11088 var keySize = key.sigBytes / 4;
11089
11090 // Compute number of rounds
11091 var nRounds = this._nRounds = keySize + 6;
11092
11093 // Compute number of key schedule rows
11094 var ksRows = (nRounds + 1) * 4;
11095
11096 // Compute key schedule
11097 var keySchedule = this._keySchedule = [];
11098 for (var ksRow = 0; ksRow < ksRows; ksRow++) {
11099 if (ksRow < keySize) {
11100 keySchedule[ksRow] = keyWords[ksRow];
11101 } else {
11102 var t = keySchedule[ksRow - 1];
11103
11104 if (!(ksRow % keySize)) {
11105 // Rot word
11106 t = (t << 8) | (t >>> 24);
11107
11108 // Sub word
11109 t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
11110
11111 // Mix Rcon
11112 t ^= RCON[(ksRow / keySize) | 0] << 24;
11113 } else if (keySize > 6 && ksRow % keySize == 4) {
11114 // Sub word
11115 t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
11116 }
11117
11118 keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
11119 }
11120 }
11121
11122 // Compute inv key schedule
11123 var invKeySchedule = this._invKeySchedule = [];
11124 for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
11125 var ksRow = ksRows - invKsRow;
11126
11127 if (invKsRow % 4) {
11128 var t = keySchedule[ksRow];
11129 } else {
11130 var t = keySchedule[ksRow - 4];
11131 }
11132
11133 if (invKsRow < 4 || ksRow <= 4) {
11134 invKeySchedule[invKsRow] = t;
11135 } else {
11136 invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^
11137 INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]];
11138 }
11139 }
11140 },
11141
11142 encryptBlock: function (M, offset) {
11143 this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
11144 },
11145
11146 decryptBlock: function (M, offset) {
11147 // Swap 2nd and 4th rows
11148 var t = M[offset + 1];
11149 M[offset + 1] = M[offset + 3];
11150 M[offset + 3] = t;
11151
11152 this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
11153
11154 // Inv swap 2nd and 4th rows
11155 var t = M[offset + 1];
11156 M[offset + 1] = M[offset + 3];
11157 M[offset + 3] = t;
11158 },
11159
11160 _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
11161 // Shortcut
11162 var nRounds = this._nRounds;
11163
11164 // Get input, add round key
11165 var s0 = M[offset] ^ keySchedule[0];
11166 var s1 = M[offset + 1] ^ keySchedule[1];
11167 var s2 = M[offset + 2] ^ keySchedule[2];
11168 var s3 = M[offset + 3] ^ keySchedule[3];
11169
11170 // Key schedule row counter
11171 var ksRow = 4;
11172
11173 // Rounds
11174 for (var round = 1; round < nRounds; round++) {
11175 // Shift rows, sub bytes, mix columns, add round key
11176 var t0 = SUB_MIX_0[s0 >>> 24] ^ SUB_MIX_1[(s1 >>> 16) & 0xff] ^ SUB_MIX_2[(s2 >>> 8) & 0xff] ^ SUB_MIX_3[s3 & 0xff] ^ keySchedule[ksRow++];
11177 var t1 = SUB_MIX_0[s1 >>> 24] ^ SUB_MIX_1[(s2 >>> 16) & 0xff] ^ SUB_MIX_2[(s3 >>> 8) & 0xff] ^ SUB_MIX_3[s0 & 0xff] ^ keySchedule[ksRow++];
11178 var t2 = SUB_MIX_0[s2 >>> 24] ^ SUB_MIX_1[(s3 >>> 16) & 0xff] ^ SUB_MIX_2[(s0 >>> 8) & 0xff] ^ SUB_MIX_3[s1 & 0xff] ^ keySchedule[ksRow++];
11179 var t3 = SUB_MIX_0[s3 >>> 24] ^ SUB_MIX_1[(s0 >>> 16) & 0xff] ^ SUB_MIX_2[(s1 >>> 8) & 0xff] ^ SUB_MIX_3[s2 & 0xff] ^ keySchedule[ksRow++];
11180
11181 // Update state
11182 s0 = t0;
11183 s1 = t1;
11184 s2 = t2;
11185 s3 = t3;
11186 }
11187
11188 // Shift rows, sub bytes, add round key
11189 var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
11190 var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
11191 var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
11192 var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
11193
11194 // Set output
11195 M[offset] = t0;
11196 M[offset + 1] = t1;
11197 M[offset + 2] = t2;
11198 M[offset + 3] = t3;
11199 },
11200
11201 keySize: 256/32
11202 });
11203
11204 /**
11205 * Shortcut functions to the cipher's object interface.
11206 *
11207 * @example
11208 *
11209 * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
11210 * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg);
11211 */
11212 C.AES = BlockCipher._createHelper(AES);
11213 }());
11214
11215
11216 return CryptoJS.AES;
11217
11218}));
11219
11220/***/ }),
11221/* 98 */
11222/***/ (function(module, exports, __webpack_require__) {
11223
11224;(function (root, factory) {
11225 if (true) {
11226 // CommonJS
11227 module.exports = exports = factory(__webpack_require__(0));
11228 }
11229 else if (typeof define === "function" && define.amd) {
11230 // AMD
11231 define(["./core"], factory);
11232 }
11233 else {
11234 // Global (browser)
11235 factory(root.CryptoJS);
11236 }
11237}(this, function (CryptoJS) {
11238
11239 (function () {
11240 // Shortcuts
11241 var C = CryptoJS;
11242 var C_lib = C.lib;
11243 var WordArray = C_lib.WordArray;
11244 var C_enc = C.enc;
11245
11246 /**
11247 * UTF-16 BE encoding strategy.
11248 */
11249 var Utf16BE = C_enc.Utf16 = C_enc.Utf16BE = {
11250 /**
11251 * Converts a word array to a UTF-16 BE string.
11252 *
11253 * @param {WordArray} wordArray The word array.
11254 *
11255 * @return {string} The UTF-16 BE string.
11256 *
11257 * @static
11258 *
11259 * @example
11260 *
11261 * var utf16String = CryptoJS.enc.Utf16.stringify(wordArray);
11262 */
11263 stringify: function (wordArray) {
11264 // Shortcuts
11265 var words = wordArray.words;
11266 var sigBytes = wordArray.sigBytes;
11267
11268 // Convert
11269 var utf16Chars = [];
11270 for (var i = 0; i < sigBytes; i += 2) {
11271 var codePoint = (words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff;
11272 utf16Chars.push(String.fromCharCode(codePoint));
11273 }
11274
11275 return utf16Chars.join('');
11276 },
11277
11278 /**
11279 * Converts a UTF-16 BE string to a word array.
11280 *
11281 * @param {string} utf16Str The UTF-16 BE string.
11282 *
11283 * @return {WordArray} The word array.
11284 *
11285 * @static
11286 *
11287 * @example
11288 *
11289 * var wordArray = CryptoJS.enc.Utf16.parse(utf16String);
11290 */
11291 parse: function (utf16Str) {
11292 // Shortcut
11293 var utf16StrLength = utf16Str.length;
11294
11295 // Convert
11296 var words = [];
11297 for (var i = 0; i < utf16StrLength; i++) {
11298 words[i >>> 1] |= utf16Str.charCodeAt(i) << (16 - (i % 2) * 16);
11299 }
11300
11301 return WordArray.create(words, utf16StrLength * 2);
11302 }
11303 };
11304
11305 /**
11306 * UTF-16 LE encoding strategy.
11307 */
11308 C_enc.Utf16LE = {
11309 /**
11310 * Converts a word array to a UTF-16 LE string.
11311 *
11312 * @param {WordArray} wordArray The word array.
11313 *
11314 * @return {string} The UTF-16 LE string.
11315 *
11316 * @static
11317 *
11318 * @example
11319 *
11320 * var utf16Str = CryptoJS.enc.Utf16LE.stringify(wordArray);
11321 */
11322 stringify: function (wordArray) {
11323 // Shortcuts
11324 var words = wordArray.words;
11325 var sigBytes = wordArray.sigBytes;
11326
11327 // Convert
11328 var utf16Chars = [];
11329 for (var i = 0; i < sigBytes; i += 2) {
11330 var codePoint = swapEndian((words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff);
11331 utf16Chars.push(String.fromCharCode(codePoint));
11332 }
11333
11334 return utf16Chars.join('');
11335 },
11336
11337 /**
11338 * Converts a UTF-16 LE string to a word array.
11339 *
11340 * @param {string} utf16Str The UTF-16 LE string.
11341 *
11342 * @return {WordArray} The word array.
11343 *
11344 * @static
11345 *
11346 * @example
11347 *
11348 * var wordArray = CryptoJS.enc.Utf16LE.parse(utf16Str);
11349 */
11350 parse: function (utf16Str) {
11351 // Shortcut
11352 var utf16StrLength = utf16Str.length;
11353
11354 // Convert
11355 var words = [];
11356 for (var i = 0; i < utf16StrLength; i++) {
11357 words[i >>> 1] |= swapEndian(utf16Str.charCodeAt(i) << (16 - (i % 2) * 16));
11358 }
11359
11360 return WordArray.create(words, utf16StrLength * 2);
11361 }
11362 };
11363
11364 function swapEndian(word) {
11365 return ((word << 8) & 0xff00ff00) | ((word >>> 8) & 0x00ff00ff);
11366 }
11367 }());
11368
11369
11370 return CryptoJS.enc.Utf16;
11371
11372}));
11373
11374/***/ }),
11375/* 99 */
11376/***/ (function(module, exports, __webpack_require__) {
11377
11378;(function (root, factory, undef) {
11379 if (true) {
11380 // CommonJS
11381 module.exports = exports = factory(__webpack_require__(0), __webpack_require__(1));
11382 }
11383 else if (typeof define === "function" && define.amd) {
11384 // AMD
11385 define(["./core", "./cipher-core"], factory);
11386 }
11387 else {
11388 // Global (browser)
11389 factory(root.CryptoJS);
11390 }
11391}(this, function (CryptoJS) {
11392
11393 (function (undefined) {
11394 // Shortcuts
11395 var C = CryptoJS;
11396 var C_lib = C.lib;
11397 var CipherParams = C_lib.CipherParams;
11398 var C_enc = C.enc;
11399 var Hex = C_enc.Hex;
11400 var C_format = C.format;
11401
11402 var HexFormatter = C_format.Hex = {
11403 /**
11404 * Converts the ciphertext of a cipher params object to a hexadecimally encoded string.
11405 *
11406 * @param {CipherParams} cipherParams The cipher params object.
11407 *
11408 * @return {string} The hexadecimally encoded string.
11409 *
11410 * @static
11411 *
11412 * @example
11413 *
11414 * var hexString = CryptoJS.format.Hex.stringify(cipherParams);
11415 */
11416 stringify: function (cipherParams) {
11417 return cipherParams.ciphertext.toString(Hex);
11418 },
11419
11420 /**
11421 * Converts a hexadecimally encoded ciphertext string to a cipher params object.
11422 *
11423 * @param {string} input The hexadecimally encoded string.
11424 *
11425 * @return {CipherParams} The cipher params object.
11426 *
11427 * @static
11428 *
11429 * @example
11430 *
11431 * var cipherParams = CryptoJS.format.Hex.parse(hexString);
11432 */
11433 parse: function (input) {
11434 var ciphertext = Hex.parse(input);
11435 return CipherParams.create({ ciphertext: ciphertext });
11436 }
11437 };
11438 }());
11439
11440
11441 return CryptoJS.format.Hex;
11442
11443}));
11444
11445/***/ }),
11446/* 100 */
11447/***/ (function(module, exports, __webpack_require__) {
11448
11449;(function (root, factory, undef) {
11450 if (true) {
11451 // CommonJS
11452 module.exports = exports = factory(__webpack_require__(0), __webpack_require__(28), __webpack_require__(101), __webpack_require__(98), __webpack_require__(14), __webpack_require__(16), __webpack_require__(47), __webpack_require__(58), __webpack_require__(117), __webpack_require__(60), __webpack_require__(118), __webpack_require__(59), __webpack_require__(116), __webpack_require__(46), __webpack_require__(112), __webpack_require__(15), __webpack_require__(1), __webpack_require__(102), __webpack_require__(104), __webpack_require__(103), __webpack_require__(106), __webpack_require__(105), __webpack_require__(107), __webpack_require__(108), __webpack_require__(109), __webpack_require__(111), __webpack_require__(110), __webpack_require__(99), __webpack_require__(97), __webpack_require__(119), __webpack_require__(115), __webpack_require__(114), __webpack_require__(113));
11453 }
11454 else if (typeof define === "function" && define.amd) {
11455 // AMD
11456 define(["./core", "./x64-core", "./lib-typedarrays", "./enc-utf16", "./enc-base64", "./md5", "./sha1", "./sha256", "./sha224", "./sha512", "./sha384", "./sha3", "./ripemd160", "./hmac", "./pbkdf2", "./evpkdf", "./cipher-core", "./mode-cfb", "./mode-ctr", "./mode-ctr-gladman", "./mode-ofb", "./mode-ecb", "./pad-ansix923", "./pad-iso10126", "./pad-iso97971", "./pad-zeropadding", "./pad-nopadding", "./format-hex", "./aes", "./tripledes", "./rc4", "./rabbit", "./rabbit-legacy"], factory);
11457 }
11458 else {
11459 // Global (browser)
11460 root.CryptoJS = factory(root.CryptoJS);
11461 }
11462}(this, function (CryptoJS) {
11463
11464 return CryptoJS;
11465
11466}));
11467
11468/***/ }),
11469/* 101 */
11470/***/ (function(module, exports, __webpack_require__) {
11471
11472;(function (root, factory) {
11473 if (true) {
11474 // CommonJS
11475 module.exports = exports = factory(__webpack_require__(0));
11476 }
11477 else if (typeof define === "function" && define.amd) {
11478 // AMD
11479 define(["./core"], factory);
11480 }
11481 else {
11482 // Global (browser)
11483 factory(root.CryptoJS);
11484 }
11485}(this, function (CryptoJS) {
11486
11487 (function () {
11488 // Check if typed arrays are supported
11489 if (typeof ArrayBuffer != 'function') {
11490 return;
11491 }
11492
11493 // Shortcuts
11494 var C = CryptoJS;
11495 var C_lib = C.lib;
11496 var WordArray = C_lib.WordArray;
11497
11498 // Reference original init
11499 var superInit = WordArray.init;
11500
11501 // Augment WordArray.init to handle typed arrays
11502 var subInit = WordArray.init = function (typedArray) {
11503 // Convert buffers to uint8
11504 if (typedArray instanceof ArrayBuffer) {
11505 typedArray = new Uint8Array(typedArray);
11506 }
11507
11508 // Convert other array views to uint8
11509 if (
11510 typedArray instanceof Int8Array ||
11511 (typeof Uint8ClampedArray !== "undefined" && typedArray instanceof Uint8ClampedArray) ||
11512 typedArray instanceof Int16Array ||
11513 typedArray instanceof Uint16Array ||
11514 typedArray instanceof Int32Array ||
11515 typedArray instanceof Uint32Array ||
11516 typedArray instanceof Float32Array ||
11517 typedArray instanceof Float64Array
11518 ) {
11519 typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength);
11520 }
11521
11522 // Handle Uint8Array
11523 if (typedArray instanceof Uint8Array) {
11524 // Shortcut
11525 var typedArrayByteLength = typedArray.byteLength;
11526
11527 // Extract bytes
11528 var words = [];
11529 for (var i = 0; i < typedArrayByteLength; i++) {
11530 words[i >>> 2] |= typedArray[i] << (24 - (i % 4) * 8);
11531 }
11532
11533 // Initialize this word array
11534 superInit.call(this, words, typedArrayByteLength);
11535 } else {
11536 // Else call normal init
11537 superInit.apply(this, arguments);
11538 }
11539 };
11540
11541 subInit.prototype = WordArray;
11542 }());
11543
11544
11545 return CryptoJS.lib.WordArray;
11546
11547}));
11548
11549/***/ }),
11550/* 102 */
11551/***/ (function(module, exports, __webpack_require__) {
11552
11553;(function (root, factory, undef) {
11554 if (true) {
11555 // CommonJS
11556 module.exports = exports = factory(__webpack_require__(0), __webpack_require__(1));
11557 }
11558 else if (typeof define === "function" && define.amd) {
11559 // AMD
11560 define(["./core", "./cipher-core"], factory);
11561 }
11562 else {
11563 // Global (browser)
11564 factory(root.CryptoJS);
11565 }
11566}(this, function (CryptoJS) {
11567
11568 /**
11569 * Cipher Feedback block mode.
11570 */
11571 CryptoJS.mode.CFB = (function () {
11572 var CFB = CryptoJS.lib.BlockCipherMode.extend();
11573
11574 CFB.Encryptor = CFB.extend({
11575 processBlock: function (words, offset) {
11576 // Shortcuts
11577 var cipher = this._cipher;
11578 var blockSize = cipher.blockSize;
11579
11580 generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
11581
11582 // Remember this block to use with next block
11583 this._prevBlock = words.slice(offset, offset + blockSize);
11584 }
11585 });
11586
11587 CFB.Decryptor = CFB.extend({
11588 processBlock: function (words, offset) {
11589 // Shortcuts
11590 var cipher = this._cipher;
11591 var blockSize = cipher.blockSize;
11592
11593 // Remember this block to use with next block
11594 var thisBlock = words.slice(offset, offset + blockSize);
11595
11596 generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
11597
11598 // This block becomes the previous block
11599 this._prevBlock = thisBlock;
11600 }
11601 });
11602
11603 function generateKeystreamAndEncrypt(words, offset, blockSize, cipher) {
11604 // Shortcut
11605 var iv = this._iv;
11606
11607 // Generate keystream
11608 if (iv) {
11609 var keystream = iv.slice(0);
11610
11611 // Remove IV for subsequent blocks
11612 this._iv = undefined;
11613 } else {
11614 var keystream = this._prevBlock;
11615 }
11616 cipher.encryptBlock(keystream, 0);
11617
11618 // Encrypt
11619 for (var i = 0; i < blockSize; i++) {
11620 words[offset + i] ^= keystream[i];
11621 }
11622 }
11623
11624 return CFB;
11625 }());
11626
11627
11628 return CryptoJS.mode.CFB;
11629
11630}));
11631
11632/***/ }),
11633/* 103 */
11634/***/ (function(module, exports, __webpack_require__) {
11635
11636;(function (root, factory, undef) {
11637 if (true) {
11638 // CommonJS
11639 module.exports = exports = factory(__webpack_require__(0), __webpack_require__(1));
11640 }
11641 else if (typeof define === "function" && define.amd) {
11642 // AMD
11643 define(["./core", "./cipher-core"], factory);
11644 }
11645 else {
11646 // Global (browser)
11647 factory(root.CryptoJS);
11648 }
11649}(this, function (CryptoJS) {
11650
11651 /** @preserve
11652 * Counter block mode compatible with Dr Brian Gladman fileenc.c
11653 * derived from CryptoJS.mode.CTR
11654 * Jan Hruby jhruby.web@gmail.com
11655 */
11656 CryptoJS.mode.CTRGladman = (function () {
11657 var CTRGladman = CryptoJS.lib.BlockCipherMode.extend();
11658
11659 function incWord(word)
11660 {
11661 if (((word >> 24) & 0xff) === 0xff) { //overflow
11662 var b1 = (word >> 16)&0xff;
11663 var b2 = (word >> 8)&0xff;
11664 var b3 = word & 0xff;
11665
11666 if (b1 === 0xff) // overflow b1
11667 {
11668 b1 = 0;
11669 if (b2 === 0xff)
11670 {
11671 b2 = 0;
11672 if (b3 === 0xff)
11673 {
11674 b3 = 0;
11675 }
11676 else
11677 {
11678 ++b3;
11679 }
11680 }
11681 else
11682 {
11683 ++b2;
11684 }
11685 }
11686 else
11687 {
11688 ++b1;
11689 }
11690
11691 word = 0;
11692 word += (b1 << 16);
11693 word += (b2 << 8);
11694 word += b3;
11695 }
11696 else
11697 {
11698 word += (0x01 << 24);
11699 }
11700 return word;
11701 }
11702
11703 function incCounter(counter)
11704 {
11705 if ((counter[0] = incWord(counter[0])) === 0)
11706 {
11707 // encr_data in fileenc.c from Dr Brian Gladman's counts only with DWORD j < 8
11708 counter[1] = incWord(counter[1]);
11709 }
11710 return counter;
11711 }
11712
11713 var Encryptor = CTRGladman.Encryptor = CTRGladman.extend({
11714 processBlock: function (words, offset) {
11715 // Shortcuts
11716 var cipher = this._cipher
11717 var blockSize = cipher.blockSize;
11718 var iv = this._iv;
11719 var counter = this._counter;
11720
11721 // Generate keystream
11722 if (iv) {
11723 counter = this._counter = iv.slice(0);
11724
11725 // Remove IV for subsequent blocks
11726 this._iv = undefined;
11727 }
11728
11729 incCounter(counter);
11730
11731 var keystream = counter.slice(0);
11732 cipher.encryptBlock(keystream, 0);
11733
11734 // Encrypt
11735 for (var i = 0; i < blockSize; i++) {
11736 words[offset + i] ^= keystream[i];
11737 }
11738 }
11739 });
11740
11741 CTRGladman.Decryptor = Encryptor;
11742
11743 return CTRGladman;
11744 }());
11745
11746
11747
11748
11749 return CryptoJS.mode.CTRGladman;
11750
11751}));
11752
11753/***/ }),
11754/* 104 */
11755/***/ (function(module, exports, __webpack_require__) {
11756
11757;(function (root, factory, undef) {
11758 if (true) {
11759 // CommonJS
11760 module.exports = exports = factory(__webpack_require__(0), __webpack_require__(1));
11761 }
11762 else if (typeof define === "function" && define.amd) {
11763 // AMD
11764 define(["./core", "./cipher-core"], factory);
11765 }
11766 else {
11767 // Global (browser)
11768 factory(root.CryptoJS);
11769 }
11770}(this, function (CryptoJS) {
11771
11772 /**
11773 * Counter block mode.
11774 */
11775 CryptoJS.mode.CTR = (function () {
11776 var CTR = CryptoJS.lib.BlockCipherMode.extend();
11777
11778 var Encryptor = CTR.Encryptor = CTR.extend({
11779 processBlock: function (words, offset) {
11780 // Shortcuts
11781 var cipher = this._cipher
11782 var blockSize = cipher.blockSize;
11783 var iv = this._iv;
11784 var counter = this._counter;
11785
11786 // Generate keystream
11787 if (iv) {
11788 counter = this._counter = iv.slice(0);
11789
11790 // Remove IV for subsequent blocks
11791 this._iv = undefined;
11792 }
11793 var keystream = counter.slice(0);
11794 cipher.encryptBlock(keystream, 0);
11795
11796 // Increment counter
11797 counter[blockSize - 1] = (counter[blockSize - 1] + 1) | 0
11798
11799 // Encrypt
11800 for (var i = 0; i < blockSize; i++) {
11801 words[offset + i] ^= keystream[i];
11802 }
11803 }
11804 });
11805
11806 CTR.Decryptor = Encryptor;
11807
11808 return CTR;
11809 }());
11810
11811
11812 return CryptoJS.mode.CTR;
11813
11814}));
11815
11816/***/ }),
11817/* 105 */
11818/***/ (function(module, exports, __webpack_require__) {
11819
11820;(function (root, factory, undef) {
11821 if (true) {
11822 // CommonJS
11823 module.exports = exports = factory(__webpack_require__(0), __webpack_require__(1));
11824 }
11825 else if (typeof define === "function" && define.amd) {
11826 // AMD
11827 define(["./core", "./cipher-core"], factory);
11828 }
11829 else {
11830 // Global (browser)
11831 factory(root.CryptoJS);
11832 }
11833}(this, function (CryptoJS) {
11834
11835 /**
11836 * Electronic Codebook block mode.
11837 */
11838 CryptoJS.mode.ECB = (function () {
11839 var ECB = CryptoJS.lib.BlockCipherMode.extend();
11840
11841 ECB.Encryptor = ECB.extend({
11842 processBlock: function (words, offset) {
11843 this._cipher.encryptBlock(words, offset);
11844 }
11845 });
11846
11847 ECB.Decryptor = ECB.extend({
11848 processBlock: function (words, offset) {
11849 this._cipher.decryptBlock(words, offset);
11850 }
11851 });
11852
11853 return ECB;
11854 }());
11855
11856
11857 return CryptoJS.mode.ECB;
11858
11859}));
11860
11861/***/ }),
11862/* 106 */
11863/***/ (function(module, exports, __webpack_require__) {
11864
11865;(function (root, factory, undef) {
11866 if (true) {
11867 // CommonJS
11868 module.exports = exports = factory(__webpack_require__(0), __webpack_require__(1));
11869 }
11870 else if (typeof define === "function" && define.amd) {
11871 // AMD
11872 define(["./core", "./cipher-core"], factory);
11873 }
11874 else {
11875 // Global (browser)
11876 factory(root.CryptoJS);
11877 }
11878}(this, function (CryptoJS) {
11879
11880 /**
11881 * Output Feedback block mode.
11882 */
11883 CryptoJS.mode.OFB = (function () {
11884 var OFB = CryptoJS.lib.BlockCipherMode.extend();
11885
11886 var Encryptor = OFB.Encryptor = OFB.extend({
11887 processBlock: function (words, offset) {
11888 // Shortcuts
11889 var cipher = this._cipher
11890 var blockSize = cipher.blockSize;
11891 var iv = this._iv;
11892 var keystream = this._keystream;
11893
11894 // Generate keystream
11895 if (iv) {
11896 keystream = this._keystream = iv.slice(0);
11897
11898 // Remove IV for subsequent blocks
11899 this._iv = undefined;
11900 }
11901 cipher.encryptBlock(keystream, 0);
11902
11903 // Encrypt
11904 for (var i = 0; i < blockSize; i++) {
11905 words[offset + i] ^= keystream[i];
11906 }
11907 }
11908 });
11909
11910 OFB.Decryptor = Encryptor;
11911
11912 return OFB;
11913 }());
11914
11915
11916 return CryptoJS.mode.OFB;
11917
11918}));
11919
11920/***/ }),
11921/* 107 */
11922/***/ (function(module, exports, __webpack_require__) {
11923
11924;(function (root, factory, undef) {
11925 if (true) {
11926 // CommonJS
11927 module.exports = exports = factory(__webpack_require__(0), __webpack_require__(1));
11928 }
11929 else if (typeof define === "function" && define.amd) {
11930 // AMD
11931 define(["./core", "./cipher-core"], factory);
11932 }
11933 else {
11934 // Global (browser)
11935 factory(root.CryptoJS);
11936 }
11937}(this, function (CryptoJS) {
11938
11939 /**
11940 * ANSI X.923 padding strategy.
11941 */
11942 CryptoJS.pad.AnsiX923 = {
11943 pad: function (data, blockSize) {
11944 // Shortcuts
11945 var dataSigBytes = data.sigBytes;
11946 var blockSizeBytes = blockSize * 4;
11947
11948 // Count padding bytes
11949 var nPaddingBytes = blockSizeBytes - dataSigBytes % blockSizeBytes;
11950
11951 // Compute last byte position
11952 var lastBytePos = dataSigBytes + nPaddingBytes - 1;
11953
11954 // Pad
11955 data.clamp();
11956 data.words[lastBytePos >>> 2] |= nPaddingBytes << (24 - (lastBytePos % 4) * 8);
11957 data.sigBytes += nPaddingBytes;
11958 },
11959
11960 unpad: function (data) {
11961 // Get number of padding bytes from last byte
11962 var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
11963
11964 // Remove padding
11965 data.sigBytes -= nPaddingBytes;
11966 }
11967 };
11968
11969
11970 return CryptoJS.pad.Ansix923;
11971
11972}));
11973
11974/***/ }),
11975/* 108 */
11976/***/ (function(module, exports, __webpack_require__) {
11977
11978;(function (root, factory, undef) {
11979 if (true) {
11980 // CommonJS
11981 module.exports = exports = factory(__webpack_require__(0), __webpack_require__(1));
11982 }
11983 else if (typeof define === "function" && define.amd) {
11984 // AMD
11985 define(["./core", "./cipher-core"], factory);
11986 }
11987 else {
11988 // Global (browser)
11989 factory(root.CryptoJS);
11990 }
11991}(this, function (CryptoJS) {
11992
11993 /**
11994 * ISO 10126 padding strategy.
11995 */
11996 CryptoJS.pad.Iso10126 = {
11997 pad: function (data, blockSize) {
11998 // Shortcut
11999 var blockSizeBytes = blockSize * 4;
12000
12001 // Count padding bytes
12002 var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
12003
12004 // Pad
12005 data.concat(CryptoJS.lib.WordArray.random(nPaddingBytes - 1)).
12006 concat(CryptoJS.lib.WordArray.create([nPaddingBytes << 24], 1));
12007 },
12008
12009 unpad: function (data) {
12010 // Get number of padding bytes from last byte
12011 var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
12012
12013 // Remove padding
12014 data.sigBytes -= nPaddingBytes;
12015 }
12016 };
12017
12018
12019 return CryptoJS.pad.Iso10126;
12020
12021}));
12022
12023/***/ }),
12024/* 109 */
12025/***/ (function(module, exports, __webpack_require__) {
12026
12027;(function (root, factory, undef) {
12028 if (true) {
12029 // CommonJS
12030 module.exports = exports = factory(__webpack_require__(0), __webpack_require__(1));
12031 }
12032 else if (typeof define === "function" && define.amd) {
12033 // AMD
12034 define(["./core", "./cipher-core"], factory);
12035 }
12036 else {
12037 // Global (browser)
12038 factory(root.CryptoJS);
12039 }
12040}(this, function (CryptoJS) {
12041
12042 /**
12043 * ISO/IEC 9797-1 Padding Method 2.
12044 */
12045 CryptoJS.pad.Iso97971 = {
12046 pad: function (data, blockSize) {
12047 // Add 0x80 byte
12048 data.concat(CryptoJS.lib.WordArray.create([0x80000000], 1));
12049
12050 // Zero pad the rest
12051 CryptoJS.pad.ZeroPadding.pad(data, blockSize);
12052 },
12053
12054 unpad: function (data) {
12055 // Remove zero padding
12056 CryptoJS.pad.ZeroPadding.unpad(data);
12057
12058 // Remove one more byte -- the 0x80 byte
12059 data.sigBytes--;
12060 }
12061 };
12062
12063
12064 return CryptoJS.pad.Iso97971;
12065
12066}));
12067
12068/***/ }),
12069/* 110 */
12070/***/ (function(module, exports, __webpack_require__) {
12071
12072;(function (root, factory, undef) {
12073 if (true) {
12074 // CommonJS
12075 module.exports = exports = factory(__webpack_require__(0), __webpack_require__(1));
12076 }
12077 else if (typeof define === "function" && define.amd) {
12078 // AMD
12079 define(["./core", "./cipher-core"], factory);
12080 }
12081 else {
12082 // Global (browser)
12083 factory(root.CryptoJS);
12084 }
12085}(this, function (CryptoJS) {
12086
12087 /**
12088 * A noop padding strategy.
12089 */
12090 CryptoJS.pad.NoPadding = {
12091 pad: function () {
12092 },
12093
12094 unpad: function () {
12095 }
12096 };
12097
12098
12099 return CryptoJS.pad.NoPadding;
12100
12101}));
12102
12103/***/ }),
12104/* 111 */
12105/***/ (function(module, exports, __webpack_require__) {
12106
12107;(function (root, factory, undef) {
12108 if (true) {
12109 // CommonJS
12110 module.exports = exports = factory(__webpack_require__(0), __webpack_require__(1));
12111 }
12112 else if (typeof define === "function" && define.amd) {
12113 // AMD
12114 define(["./core", "./cipher-core"], factory);
12115 }
12116 else {
12117 // Global (browser)
12118 factory(root.CryptoJS);
12119 }
12120}(this, function (CryptoJS) {
12121
12122 /**
12123 * Zero padding strategy.
12124 */
12125 CryptoJS.pad.ZeroPadding = {
12126 pad: function (data, blockSize) {
12127 // Shortcut
12128 var blockSizeBytes = blockSize * 4;
12129
12130 // Pad
12131 data.clamp();
12132 data.sigBytes += blockSizeBytes - ((data.sigBytes % blockSizeBytes) || blockSizeBytes);
12133 },
12134
12135 unpad: function (data) {
12136 // Shortcut
12137 var dataWords = data.words;
12138
12139 // Unpad
12140 var i = data.sigBytes - 1;
12141 while (!((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) {
12142 i--;
12143 }
12144 data.sigBytes = i + 1;
12145 }
12146 };
12147
12148
12149 return CryptoJS.pad.ZeroPadding;
12150
12151}));
12152
12153/***/ }),
12154/* 112 */
12155/***/ (function(module, exports, __webpack_require__) {
12156
12157;(function (root, factory, undef) {
12158 if (true) {
12159 // CommonJS
12160 module.exports = exports = factory(__webpack_require__(0), __webpack_require__(47), __webpack_require__(46));
12161 }
12162 else if (typeof define === "function" && define.amd) {
12163 // AMD
12164 define(["./core", "./sha1", "./hmac"], factory);
12165 }
12166 else {
12167 // Global (browser)
12168 factory(root.CryptoJS);
12169 }
12170}(this, function (CryptoJS) {
12171
12172 (function () {
12173 // Shortcuts
12174 var C = CryptoJS;
12175 var C_lib = C.lib;
12176 var Base = C_lib.Base;
12177 var WordArray = C_lib.WordArray;
12178 var C_algo = C.algo;
12179 var SHA1 = C_algo.SHA1;
12180 var HMAC = C_algo.HMAC;
12181
12182 /**
12183 * Password-Based Key Derivation Function 2 algorithm.
12184 */
12185 var PBKDF2 = C_algo.PBKDF2 = Base.extend({
12186 /**
12187 * Configuration options.
12188 *
12189 * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
12190 * @property {Hasher} hasher The hasher to use. Default: SHA1
12191 * @property {number} iterations The number of iterations to perform. Default: 1
12192 */
12193 cfg: Base.extend({
12194 keySize: 128/32,
12195 hasher: SHA1,
12196 iterations: 1
12197 }),
12198
12199 /**
12200 * Initializes a newly created key derivation function.
12201 *
12202 * @param {Object} cfg (Optional) The configuration options to use for the derivation.
12203 *
12204 * @example
12205 *
12206 * var kdf = CryptoJS.algo.PBKDF2.create();
12207 * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8 });
12208 * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8, iterations: 1000 });
12209 */
12210 init: function (cfg) {
12211 this.cfg = this.cfg.extend(cfg);
12212 },
12213
12214 /**
12215 * Computes the Password-Based Key Derivation Function 2.
12216 *
12217 * @param {WordArray|string} password The password.
12218 * @param {WordArray|string} salt A salt.
12219 *
12220 * @return {WordArray} The derived key.
12221 *
12222 * @example
12223 *
12224 * var key = kdf.compute(password, salt);
12225 */
12226 compute: function (password, salt) {
12227 // Shortcut
12228 var cfg = this.cfg;
12229
12230 // Init HMAC
12231 var hmac = HMAC.create(cfg.hasher, password);
12232
12233 // Initial values
12234 var derivedKey = WordArray.create();
12235 var blockIndex = WordArray.create([0x00000001]);
12236
12237 // Shortcuts
12238 var derivedKeyWords = derivedKey.words;
12239 var blockIndexWords = blockIndex.words;
12240 var keySize = cfg.keySize;
12241 var iterations = cfg.iterations;
12242
12243 // Generate key
12244 while (derivedKeyWords.length < keySize) {
12245 var block = hmac.update(salt).finalize(blockIndex);
12246 hmac.reset();
12247
12248 // Shortcuts
12249 var blockWords = block.words;
12250 var blockWordsLength = blockWords.length;
12251
12252 // Iterations
12253 var intermediate = block;
12254 for (var i = 1; i < iterations; i++) {
12255 intermediate = hmac.finalize(intermediate);
12256 hmac.reset();
12257
12258 // Shortcut
12259 var intermediateWords = intermediate.words;
12260
12261 // XOR intermediate with block
12262 for (var j = 0; j < blockWordsLength; j++) {
12263 blockWords[j] ^= intermediateWords[j];
12264 }
12265 }
12266
12267 derivedKey.concat(block);
12268 blockIndexWords[0]++;
12269 }
12270 derivedKey.sigBytes = keySize * 4;
12271
12272 return derivedKey;
12273 }
12274 });
12275
12276 /**
12277 * Computes the Password-Based Key Derivation Function 2.
12278 *
12279 * @param {WordArray|string} password The password.
12280 * @param {WordArray|string} salt A salt.
12281 * @param {Object} cfg (Optional) The configuration options to use for this computation.
12282 *
12283 * @return {WordArray} The derived key.
12284 *
12285 * @static
12286 *
12287 * @example
12288 *
12289 * var key = CryptoJS.PBKDF2(password, salt);
12290 * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8 });
12291 * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8, iterations: 1000 });
12292 */
12293 C.PBKDF2 = function (password, salt, cfg) {
12294 return PBKDF2.create(cfg).compute(password, salt);
12295 };
12296 }());
12297
12298
12299 return CryptoJS.PBKDF2;
12300
12301}));
12302
12303/***/ }),
12304/* 113 */
12305/***/ (function(module, exports, __webpack_require__) {
12306
12307;(function (root, factory, undef) {
12308 if (true) {
12309 // CommonJS
12310 module.exports = exports = factory(__webpack_require__(0), __webpack_require__(14), __webpack_require__(16), __webpack_require__(15), __webpack_require__(1));
12311 }
12312 else if (typeof define === "function" && define.amd) {
12313 // AMD
12314 define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
12315 }
12316 else {
12317 // Global (browser)
12318 factory(root.CryptoJS);
12319 }
12320}(this, function (CryptoJS) {
12321
12322 (function () {
12323 // Shortcuts
12324 var C = CryptoJS;
12325 var C_lib = C.lib;
12326 var StreamCipher = C_lib.StreamCipher;
12327 var C_algo = C.algo;
12328
12329 // Reusable objects
12330 var S = [];
12331 var C_ = [];
12332 var G = [];
12333
12334 /**
12335 * Rabbit stream cipher algorithm.
12336 *
12337 * This is a legacy version that neglected to convert the key to little-endian.
12338 * This error doesn't affect the cipher's security,
12339 * but it does affect its compatibility with other implementations.
12340 */
12341 var RabbitLegacy = C_algo.RabbitLegacy = StreamCipher.extend({
12342 _doReset: function () {
12343 // Shortcuts
12344 var K = this._key.words;
12345 var iv = this.cfg.iv;
12346
12347 // Generate initial state values
12348 var X = this._X = [
12349 K[0], (K[3] << 16) | (K[2] >>> 16),
12350 K[1], (K[0] << 16) | (K[3] >>> 16),
12351 K[2], (K[1] << 16) | (K[0] >>> 16),
12352 K[3], (K[2] << 16) | (K[1] >>> 16)
12353 ];
12354
12355 // Generate initial counter values
12356 var C = this._C = [
12357 (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
12358 (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
12359 (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
12360 (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
12361 ];
12362
12363 // Carry bit
12364 this._b = 0;
12365
12366 // Iterate the system four times
12367 for (var i = 0; i < 4; i++) {
12368 nextState.call(this);
12369 }
12370
12371 // Modify the counters
12372 for (var i = 0; i < 8; i++) {
12373 C[i] ^= X[(i + 4) & 7];
12374 }
12375
12376 // IV setup
12377 if (iv) {
12378 // Shortcuts
12379 var IV = iv.words;
12380 var IV_0 = IV[0];
12381 var IV_1 = IV[1];
12382
12383 // Generate four subvectors
12384 var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
12385 var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
12386 var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
12387 var i3 = (i2 << 16) | (i0 & 0x0000ffff);
12388
12389 // Modify counter values
12390 C[0] ^= i0;
12391 C[1] ^= i1;
12392 C[2] ^= i2;
12393 C[3] ^= i3;
12394 C[4] ^= i0;
12395 C[5] ^= i1;
12396 C[6] ^= i2;
12397 C[7] ^= i3;
12398
12399 // Iterate the system four times
12400 for (var i = 0; i < 4; i++) {
12401 nextState.call(this);
12402 }
12403 }
12404 },
12405
12406 _doProcessBlock: function (M, offset) {
12407 // Shortcut
12408 var X = this._X;
12409
12410 // Iterate the system
12411 nextState.call(this);
12412
12413 // Generate four keystream words
12414 S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
12415 S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
12416 S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
12417 S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
12418
12419 for (var i = 0; i < 4; i++) {
12420 // Swap endian
12421 S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) |
12422 (((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00);
12423
12424 // Encrypt
12425 M[offset + i] ^= S[i];
12426 }
12427 },
12428
12429 blockSize: 128/32,
12430
12431 ivSize: 64/32
12432 });
12433
12434 function nextState() {
12435 // Shortcuts
12436 var X = this._X;
12437 var C = this._C;
12438
12439 // Save old counter values
12440 for (var i = 0; i < 8; i++) {
12441 C_[i] = C[i];
12442 }
12443
12444 // Calculate new counter values
12445 C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
12446 C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
12447 C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
12448 C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
12449 C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
12450 C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
12451 C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
12452 C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
12453 this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
12454
12455 // Calculate the g-values
12456 for (var i = 0; i < 8; i++) {
12457 var gx = X[i] + C[i];
12458
12459 // Construct high and low argument for squaring
12460 var ga = gx & 0xffff;
12461 var gb = gx >>> 16;
12462
12463 // Calculate high and low result of squaring
12464 var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
12465 var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
12466
12467 // High XOR low
12468 G[i] = gh ^ gl;
12469 }
12470
12471 // Calculate new state values
12472 X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
12473 X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0;
12474 X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
12475 X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0;
12476 X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
12477 X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0;
12478 X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
12479 X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0;
12480 }
12481
12482 /**
12483 * Shortcut functions to the cipher's object interface.
12484 *
12485 * @example
12486 *
12487 * var ciphertext = CryptoJS.RabbitLegacy.encrypt(message, key, cfg);
12488 * var plaintext = CryptoJS.RabbitLegacy.decrypt(ciphertext, key, cfg);
12489 */
12490 C.RabbitLegacy = StreamCipher._createHelper(RabbitLegacy);
12491 }());
12492
12493
12494 return CryptoJS.RabbitLegacy;
12495
12496}));
12497
12498/***/ }),
12499/* 114 */
12500/***/ (function(module, exports, __webpack_require__) {
12501
12502;(function (root, factory, undef) {
12503 if (true) {
12504 // CommonJS
12505 module.exports = exports = factory(__webpack_require__(0), __webpack_require__(14), __webpack_require__(16), __webpack_require__(15), __webpack_require__(1));
12506 }
12507 else if (typeof define === "function" && define.amd) {
12508 // AMD
12509 define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
12510 }
12511 else {
12512 // Global (browser)
12513 factory(root.CryptoJS);
12514 }
12515}(this, function (CryptoJS) {
12516
12517 (function () {
12518 // Shortcuts
12519 var C = CryptoJS;
12520 var C_lib = C.lib;
12521 var StreamCipher = C_lib.StreamCipher;
12522 var C_algo = C.algo;
12523
12524 // Reusable objects
12525 var S = [];
12526 var C_ = [];
12527 var G = [];
12528
12529 /**
12530 * Rabbit stream cipher algorithm
12531 */
12532 var Rabbit = C_algo.Rabbit = StreamCipher.extend({
12533 _doReset: function () {
12534 // Shortcuts
12535 var K = this._key.words;
12536 var iv = this.cfg.iv;
12537
12538 // Swap endian
12539 for (var i = 0; i < 4; i++) {
12540 K[i] = (((K[i] << 8) | (K[i] >>> 24)) & 0x00ff00ff) |
12541 (((K[i] << 24) | (K[i] >>> 8)) & 0xff00ff00);
12542 }
12543
12544 // Generate initial state values
12545 var X = this._X = [
12546 K[0], (K[3] << 16) | (K[2] >>> 16),
12547 K[1], (K[0] << 16) | (K[3] >>> 16),
12548 K[2], (K[1] << 16) | (K[0] >>> 16),
12549 K[3], (K[2] << 16) | (K[1] >>> 16)
12550 ];
12551
12552 // Generate initial counter values
12553 var C = this._C = [
12554 (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
12555 (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
12556 (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
12557 (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
12558 ];
12559
12560 // Carry bit
12561 this._b = 0;
12562
12563 // Iterate the system four times
12564 for (var i = 0; i < 4; i++) {
12565 nextState.call(this);
12566 }
12567
12568 // Modify the counters
12569 for (var i = 0; i < 8; i++) {
12570 C[i] ^= X[(i + 4) & 7];
12571 }
12572
12573 // IV setup
12574 if (iv) {
12575 // Shortcuts
12576 var IV = iv.words;
12577 var IV_0 = IV[0];
12578 var IV_1 = IV[1];
12579
12580 // Generate four subvectors
12581 var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
12582 var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
12583 var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
12584 var i3 = (i2 << 16) | (i0 & 0x0000ffff);
12585
12586 // Modify counter values
12587 C[0] ^= i0;
12588 C[1] ^= i1;
12589 C[2] ^= i2;
12590 C[3] ^= i3;
12591 C[4] ^= i0;
12592 C[5] ^= i1;
12593 C[6] ^= i2;
12594 C[7] ^= i3;
12595
12596 // Iterate the system four times
12597 for (var i = 0; i < 4; i++) {
12598 nextState.call(this);
12599 }
12600 }
12601 },
12602
12603 _doProcessBlock: function (M, offset) {
12604 // Shortcut
12605 var X = this._X;
12606
12607 // Iterate the system
12608 nextState.call(this);
12609
12610 // Generate four keystream words
12611 S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
12612 S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
12613 S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
12614 S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
12615
12616 for (var i = 0; i < 4; i++) {
12617 // Swap endian
12618 S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) |
12619 (((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00);
12620
12621 // Encrypt
12622 M[offset + i] ^= S[i];
12623 }
12624 },
12625
12626 blockSize: 128/32,
12627
12628 ivSize: 64/32
12629 });
12630
12631 function nextState() {
12632 // Shortcuts
12633 var X = this._X;
12634 var C = this._C;
12635
12636 // Save old counter values
12637 for (var i = 0; i < 8; i++) {
12638 C_[i] = C[i];
12639 }
12640
12641 // Calculate new counter values
12642 C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
12643 C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
12644 C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
12645 C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
12646 C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
12647 C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
12648 C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
12649 C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
12650 this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
12651
12652 // Calculate the g-values
12653 for (var i = 0; i < 8; i++) {
12654 var gx = X[i] + C[i];
12655
12656 // Construct high and low argument for squaring
12657 var ga = gx & 0xffff;
12658 var gb = gx >>> 16;
12659
12660 // Calculate high and low result of squaring
12661 var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
12662 var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
12663
12664 // High XOR low
12665 G[i] = gh ^ gl;
12666 }
12667
12668 // Calculate new state values
12669 X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
12670 X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0;
12671 X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
12672 X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0;
12673 X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
12674 X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0;
12675 X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
12676 X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0;
12677 }
12678
12679 /**
12680 * Shortcut functions to the cipher's object interface.
12681 *
12682 * @example
12683 *
12684 * var ciphertext = CryptoJS.Rabbit.encrypt(message, key, cfg);
12685 * var plaintext = CryptoJS.Rabbit.decrypt(ciphertext, key, cfg);
12686 */
12687 C.Rabbit = StreamCipher._createHelper(Rabbit);
12688 }());
12689
12690
12691 return CryptoJS.Rabbit;
12692
12693}));
12694
12695/***/ }),
12696/* 115 */
12697/***/ (function(module, exports, __webpack_require__) {
12698
12699;(function (root, factory, undef) {
12700 if (true) {
12701 // CommonJS
12702 module.exports = exports = factory(__webpack_require__(0), __webpack_require__(14), __webpack_require__(16), __webpack_require__(15), __webpack_require__(1));
12703 }
12704 else if (typeof define === "function" && define.amd) {
12705 // AMD
12706 define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
12707 }
12708 else {
12709 // Global (browser)
12710 factory(root.CryptoJS);
12711 }
12712}(this, function (CryptoJS) {
12713
12714 (function () {
12715 // Shortcuts
12716 var C = CryptoJS;
12717 var C_lib = C.lib;
12718 var StreamCipher = C_lib.StreamCipher;
12719 var C_algo = C.algo;
12720
12721 /**
12722 * RC4 stream cipher algorithm.
12723 */
12724 var RC4 = C_algo.RC4 = StreamCipher.extend({
12725 _doReset: function () {
12726 // Shortcuts
12727 var key = this._key;
12728 var keyWords = key.words;
12729 var keySigBytes = key.sigBytes;
12730
12731 // Init sbox
12732 var S = this._S = [];
12733 for (var i = 0; i < 256; i++) {
12734 S[i] = i;
12735 }
12736
12737 // Key setup
12738 for (var i = 0, j = 0; i < 256; i++) {
12739 var keyByteIndex = i % keySigBytes;
12740 var keyByte = (keyWords[keyByteIndex >>> 2] >>> (24 - (keyByteIndex % 4) * 8)) & 0xff;
12741
12742 j = (j + S[i] + keyByte) % 256;
12743
12744 // Swap
12745 var t = S[i];
12746 S[i] = S[j];
12747 S[j] = t;
12748 }
12749
12750 // Counters
12751 this._i = this._j = 0;
12752 },
12753
12754 _doProcessBlock: function (M, offset) {
12755 M[offset] ^= generateKeystreamWord.call(this);
12756 },
12757
12758 keySize: 256/32,
12759
12760 ivSize: 0
12761 });
12762
12763 function generateKeystreamWord() {
12764 // Shortcuts
12765 var S = this._S;
12766 var i = this._i;
12767 var j = this._j;
12768
12769 // Generate keystream word
12770 var keystreamWord = 0;
12771 for (var n = 0; n < 4; n++) {
12772 i = (i + 1) % 256;
12773 j = (j + S[i]) % 256;
12774
12775 // Swap
12776 var t = S[i];
12777 S[i] = S[j];
12778 S[j] = t;
12779
12780 keystreamWord |= S[(S[i] + S[j]) % 256] << (24 - n * 8);
12781 }
12782
12783 // Update counters
12784 this._i = i;
12785 this._j = j;
12786
12787 return keystreamWord;
12788 }
12789
12790 /**
12791 * Shortcut functions to the cipher's object interface.
12792 *
12793 * @example
12794 *
12795 * var ciphertext = CryptoJS.RC4.encrypt(message, key, cfg);
12796 * var plaintext = CryptoJS.RC4.decrypt(ciphertext, key, cfg);
12797 */
12798 C.RC4 = StreamCipher._createHelper(RC4);
12799
12800 /**
12801 * Modified RC4 stream cipher algorithm.
12802 */
12803 var RC4Drop = C_algo.RC4Drop = RC4.extend({
12804 /**
12805 * Configuration options.
12806 *
12807 * @property {number} drop The number of keystream words to drop. Default 192
12808 */
12809 cfg: RC4.cfg.extend({
12810 drop: 192
12811 }),
12812
12813 _doReset: function () {
12814 RC4._doReset.call(this);
12815
12816 // Drop
12817 for (var i = this.cfg.drop; i > 0; i--) {
12818 generateKeystreamWord.call(this);
12819 }
12820 }
12821 });
12822
12823 /**
12824 * Shortcut functions to the cipher's object interface.
12825 *
12826 * @example
12827 *
12828 * var ciphertext = CryptoJS.RC4Drop.encrypt(message, key, cfg);
12829 * var plaintext = CryptoJS.RC4Drop.decrypt(ciphertext, key, cfg);
12830 */
12831 C.RC4Drop = StreamCipher._createHelper(RC4Drop);
12832 }());
12833
12834
12835 return CryptoJS.RC4;
12836
12837}));
12838
12839/***/ }),
12840/* 116 */
12841/***/ (function(module, exports, __webpack_require__) {
12842
12843;(function (root, factory) {
12844 if (true) {
12845 // CommonJS
12846 module.exports = exports = factory(__webpack_require__(0));
12847 }
12848 else if (typeof define === "function" && define.amd) {
12849 // AMD
12850 define(["./core"], factory);
12851 }
12852 else {
12853 // Global (browser)
12854 factory(root.CryptoJS);
12855 }
12856}(this, function (CryptoJS) {
12857
12858 /** @preserve
12859 (c) 2012 by Cédric Mesnil. All rights reserved.
12860
12861 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
12862
12863 - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
12864 - 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.
12865
12866 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.
12867 */
12868
12869 (function (Math) {
12870 // Shortcuts
12871 var C = CryptoJS;
12872 var C_lib = C.lib;
12873 var WordArray = C_lib.WordArray;
12874 var Hasher = C_lib.Hasher;
12875 var C_algo = C.algo;
12876
12877 // Constants table
12878 var _zl = WordArray.create([
12879 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
12880 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
12881 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
12882 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
12883 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13]);
12884 var _zr = WordArray.create([
12885 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
12886 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
12887 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
12888 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
12889 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]);
12890 var _sl = WordArray.create([
12891 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
12892 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
12893 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
12894 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
12895 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 ]);
12896 var _sr = WordArray.create([
12897 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
12898 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
12899 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
12900 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
12901 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 ]);
12902
12903 var _hl = WordArray.create([ 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E]);
12904 var _hr = WordArray.create([ 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000]);
12905
12906 /**
12907 * RIPEMD160 hash algorithm.
12908 */
12909 var RIPEMD160 = C_algo.RIPEMD160 = Hasher.extend({
12910 _doReset: function () {
12911 this._hash = WordArray.create([0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]);
12912 },
12913
12914 _doProcessBlock: function (M, offset) {
12915
12916 // Swap endian
12917 for (var i = 0; i < 16; i++) {
12918 // Shortcuts
12919 var offset_i = offset + i;
12920 var M_offset_i = M[offset_i];
12921
12922 // Swap
12923 M[offset_i] = (
12924 (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
12925 (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
12926 );
12927 }
12928 // Shortcut
12929 var H = this._hash.words;
12930 var hl = _hl.words;
12931 var hr = _hr.words;
12932 var zl = _zl.words;
12933 var zr = _zr.words;
12934 var sl = _sl.words;
12935 var sr = _sr.words;
12936
12937 // Working variables
12938 var al, bl, cl, dl, el;
12939 var ar, br, cr, dr, er;
12940
12941 ar = al = H[0];
12942 br = bl = H[1];
12943 cr = cl = H[2];
12944 dr = dl = H[3];
12945 er = el = H[4];
12946 // Computation
12947 var t;
12948 for (var i = 0; i < 80; i += 1) {
12949 t = (al + M[offset+zl[i]])|0;
12950 if (i<16){
12951 t += f1(bl,cl,dl) + hl[0];
12952 } else if (i<32) {
12953 t += f2(bl,cl,dl) + hl[1];
12954 } else if (i<48) {
12955 t += f3(bl,cl,dl) + hl[2];
12956 } else if (i<64) {
12957 t += f4(bl,cl,dl) + hl[3];
12958 } else {// if (i<80) {
12959 t += f5(bl,cl,dl) + hl[4];
12960 }
12961 t = t|0;
12962 t = rotl(t,sl[i]);
12963 t = (t+el)|0;
12964 al = el;
12965 el = dl;
12966 dl = rotl(cl, 10);
12967 cl = bl;
12968 bl = t;
12969
12970 t = (ar + M[offset+zr[i]])|0;
12971 if (i<16){
12972 t += f5(br,cr,dr) + hr[0];
12973 } else if (i<32) {
12974 t += f4(br,cr,dr) + hr[1];
12975 } else if (i<48) {
12976 t += f3(br,cr,dr) + hr[2];
12977 } else if (i<64) {
12978 t += f2(br,cr,dr) + hr[3];
12979 } else {// if (i<80) {
12980 t += f1(br,cr,dr) + hr[4];
12981 }
12982 t = t|0;
12983 t = rotl(t,sr[i]) ;
12984 t = (t+er)|0;
12985 ar = er;
12986 er = dr;
12987 dr = rotl(cr, 10);
12988 cr = br;
12989 br = t;
12990 }
12991 // Intermediate hash value
12992 t = (H[1] + cl + dr)|0;
12993 H[1] = (H[2] + dl + er)|0;
12994 H[2] = (H[3] + el + ar)|0;
12995 H[3] = (H[4] + al + br)|0;
12996 H[4] = (H[0] + bl + cr)|0;
12997 H[0] = t;
12998 },
12999
13000 _doFinalize: function () {
13001 // Shortcuts
13002 var data = this._data;
13003 var dataWords = data.words;
13004
13005 var nBitsTotal = this._nDataBytes * 8;
13006 var nBitsLeft = data.sigBytes * 8;
13007
13008 // Add padding
13009 dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
13010 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
13011 (((nBitsTotal << 8) | (nBitsTotal >>> 24)) & 0x00ff00ff) |
13012 (((nBitsTotal << 24) | (nBitsTotal >>> 8)) & 0xff00ff00)
13013 );
13014 data.sigBytes = (dataWords.length + 1) * 4;
13015
13016 // Hash final blocks
13017 this._process();
13018
13019 // Shortcuts
13020 var hash = this._hash;
13021 var H = hash.words;
13022
13023 // Swap endian
13024 for (var i = 0; i < 5; i++) {
13025 // Shortcut
13026 var H_i = H[i];
13027
13028 // Swap
13029 H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
13030 (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
13031 }
13032
13033 // Return final computed hash
13034 return hash;
13035 },
13036
13037 clone: function () {
13038 var clone = Hasher.clone.call(this);
13039 clone._hash = this._hash.clone();
13040
13041 return clone;
13042 }
13043 });
13044
13045
13046 function f1(x, y, z) {
13047 return ((x) ^ (y) ^ (z));
13048
13049 }
13050
13051 function f2(x, y, z) {
13052 return (((x)&(y)) | ((~x)&(z)));
13053 }
13054
13055 function f3(x, y, z) {
13056 return (((x) | (~(y))) ^ (z));
13057 }
13058
13059 function f4(x, y, z) {
13060 return (((x) & (z)) | ((y)&(~(z))));
13061 }
13062
13063 function f5(x, y, z) {
13064 return ((x) ^ ((y) |(~(z))));
13065
13066 }
13067
13068 function rotl(x,n) {
13069 return (x<<n) | (x>>>(32-n));
13070 }
13071
13072
13073 /**
13074 * Shortcut function to the hasher's object interface.
13075 *
13076 * @param {WordArray|string} message The message to hash.
13077 *
13078 * @return {WordArray} The hash.
13079 *
13080 * @static
13081 *
13082 * @example
13083 *
13084 * var hash = CryptoJS.RIPEMD160('message');
13085 * var hash = CryptoJS.RIPEMD160(wordArray);
13086 */
13087 C.RIPEMD160 = Hasher._createHelper(RIPEMD160);
13088
13089 /**
13090 * Shortcut function to the HMAC's object interface.
13091 *
13092 * @param {WordArray|string} message The message to hash.
13093 * @param {WordArray|string} key The secret key.
13094 *
13095 * @return {WordArray} The HMAC.
13096 *
13097 * @static
13098 *
13099 * @example
13100 *
13101 * var hmac = CryptoJS.HmacRIPEMD160(message, key);
13102 */
13103 C.HmacRIPEMD160 = Hasher._createHmacHelper(RIPEMD160);
13104 }(Math));
13105
13106
13107 return CryptoJS.RIPEMD160;
13108
13109}));
13110
13111/***/ }),
13112/* 117 */
13113/***/ (function(module, exports, __webpack_require__) {
13114
13115;(function (root, factory, undef) {
13116 if (true) {
13117 // CommonJS
13118 module.exports = exports = factory(__webpack_require__(0), __webpack_require__(58));
13119 }
13120 else if (typeof define === "function" && define.amd) {
13121 // AMD
13122 define(["./core", "./sha256"], factory);
13123 }
13124 else {
13125 // Global (browser)
13126 factory(root.CryptoJS);
13127 }
13128}(this, function (CryptoJS) {
13129
13130 (function () {
13131 // Shortcuts
13132 var C = CryptoJS;
13133 var C_lib = C.lib;
13134 var WordArray = C_lib.WordArray;
13135 var C_algo = C.algo;
13136 var SHA256 = C_algo.SHA256;
13137
13138 /**
13139 * SHA-224 hash algorithm.
13140 */
13141 var SHA224 = C_algo.SHA224 = SHA256.extend({
13142 _doReset: function () {
13143 this._hash = new WordArray.init([
13144 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
13145 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4
13146 ]);
13147 },
13148
13149 _doFinalize: function () {
13150 var hash = SHA256._doFinalize.call(this);
13151
13152 hash.sigBytes -= 4;
13153
13154 return hash;
13155 }
13156 });
13157
13158 /**
13159 * Shortcut function to the hasher's object interface.
13160 *
13161 * @param {WordArray|string} message The message to hash.
13162 *
13163 * @return {WordArray} The hash.
13164 *
13165 * @static
13166 *
13167 * @example
13168 *
13169 * var hash = CryptoJS.SHA224('message');
13170 * var hash = CryptoJS.SHA224(wordArray);
13171 */
13172 C.SHA224 = SHA256._createHelper(SHA224);
13173
13174 /**
13175 * Shortcut function to the HMAC's object interface.
13176 *
13177 * @param {WordArray|string} message The message to hash.
13178 * @param {WordArray|string} key The secret key.
13179 *
13180 * @return {WordArray} The HMAC.
13181 *
13182 * @static
13183 *
13184 * @example
13185 *
13186 * var hmac = CryptoJS.HmacSHA224(message, key);
13187 */
13188 C.HmacSHA224 = SHA256._createHmacHelper(SHA224);
13189 }());
13190
13191
13192 return CryptoJS.SHA224;
13193
13194}));
13195
13196/***/ }),
13197/* 118 */
13198/***/ (function(module, exports, __webpack_require__) {
13199
13200;(function (root, factory, undef) {
13201 if (true) {
13202 // CommonJS
13203 module.exports = exports = factory(__webpack_require__(0), __webpack_require__(28), __webpack_require__(60));
13204 }
13205 else if (typeof define === "function" && define.amd) {
13206 // AMD
13207 define(["./core", "./x64-core", "./sha512"], factory);
13208 }
13209 else {
13210 // Global (browser)
13211 factory(root.CryptoJS);
13212 }
13213}(this, function (CryptoJS) {
13214
13215 (function () {
13216 // Shortcuts
13217 var C = CryptoJS;
13218 var C_x64 = C.x64;
13219 var X64Word = C_x64.Word;
13220 var X64WordArray = C_x64.WordArray;
13221 var C_algo = C.algo;
13222 var SHA512 = C_algo.SHA512;
13223
13224 /**
13225 * SHA-384 hash algorithm.
13226 */
13227 var SHA384 = C_algo.SHA384 = SHA512.extend({
13228 _doReset: function () {
13229 this._hash = new X64WordArray.init([
13230 new X64Word.init(0xcbbb9d5d, 0xc1059ed8), new X64Word.init(0x629a292a, 0x367cd507),
13231 new X64Word.init(0x9159015a, 0x3070dd17), new X64Word.init(0x152fecd8, 0xf70e5939),
13232 new X64Word.init(0x67332667, 0xffc00b31), new X64Word.init(0x8eb44a87, 0x68581511),
13233 new X64Word.init(0xdb0c2e0d, 0x64f98fa7), new X64Word.init(0x47b5481d, 0xbefa4fa4)
13234 ]);
13235 },
13236
13237 _doFinalize: function () {
13238 var hash = SHA512._doFinalize.call(this);
13239
13240 hash.sigBytes -= 16;
13241
13242 return hash;
13243 }
13244 });
13245
13246 /**
13247 * Shortcut function to the hasher's object interface.
13248 *
13249 * @param {WordArray|string} message The message to hash.
13250 *
13251 * @return {WordArray} The hash.
13252 *
13253 * @static
13254 *
13255 * @example
13256 *
13257 * var hash = CryptoJS.SHA384('message');
13258 * var hash = CryptoJS.SHA384(wordArray);
13259 */
13260 C.SHA384 = SHA512._createHelper(SHA384);
13261
13262 /**
13263 * Shortcut function to the HMAC's object interface.
13264 *
13265 * @param {WordArray|string} message The message to hash.
13266 * @param {WordArray|string} key The secret key.
13267 *
13268 * @return {WordArray} The HMAC.
13269 *
13270 * @static
13271 *
13272 * @example
13273 *
13274 * var hmac = CryptoJS.HmacSHA384(message, key);
13275 */
13276 C.HmacSHA384 = SHA512._createHmacHelper(SHA384);
13277 }());
13278
13279
13280 return CryptoJS.SHA384;
13281
13282}));
13283
13284/***/ }),
13285/* 119 */
13286/***/ (function(module, exports, __webpack_require__) {
13287
13288;(function (root, factory, undef) {
13289 if (true) {
13290 // CommonJS
13291 module.exports = exports = factory(__webpack_require__(0), __webpack_require__(14), __webpack_require__(16), __webpack_require__(15), __webpack_require__(1));
13292 }
13293 else if (typeof define === "function" && define.amd) {
13294 // AMD
13295 define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
13296 }
13297 else {
13298 // Global (browser)
13299 factory(root.CryptoJS);
13300 }
13301}(this, function (CryptoJS) {
13302
13303 (function () {
13304 // Shortcuts
13305 var C = CryptoJS;
13306 var C_lib = C.lib;
13307 var WordArray = C_lib.WordArray;
13308 var BlockCipher = C_lib.BlockCipher;
13309 var C_algo = C.algo;
13310
13311 // Permuted Choice 1 constants
13312 var PC1 = [
13313 57, 49, 41, 33, 25, 17, 9, 1,
13314 58, 50, 42, 34, 26, 18, 10, 2,
13315 59, 51, 43, 35, 27, 19, 11, 3,
13316 60, 52, 44, 36, 63, 55, 47, 39,
13317 31, 23, 15, 7, 62, 54, 46, 38,
13318 30, 22, 14, 6, 61, 53, 45, 37,
13319 29, 21, 13, 5, 28, 20, 12, 4
13320 ];
13321
13322 // Permuted Choice 2 constants
13323 var PC2 = [
13324 14, 17, 11, 24, 1, 5,
13325 3, 28, 15, 6, 21, 10,
13326 23, 19, 12, 4, 26, 8,
13327 16, 7, 27, 20, 13, 2,
13328 41, 52, 31, 37, 47, 55,
13329 30, 40, 51, 45, 33, 48,
13330 44, 49, 39, 56, 34, 53,
13331 46, 42, 50, 36, 29, 32
13332 ];
13333
13334 // Cumulative bit shift constants
13335 var BIT_SHIFTS = [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28];
13336
13337 // SBOXes and round permutation constants
13338 var SBOX_P = [
13339 {
13340 0x0: 0x808200,
13341 0x10000000: 0x8000,
13342 0x20000000: 0x808002,
13343 0x30000000: 0x2,
13344 0x40000000: 0x200,
13345 0x50000000: 0x808202,
13346 0x60000000: 0x800202,
13347 0x70000000: 0x800000,
13348 0x80000000: 0x202,
13349 0x90000000: 0x800200,
13350 0xa0000000: 0x8200,
13351 0xb0000000: 0x808000,
13352 0xc0000000: 0x8002,
13353 0xd0000000: 0x800002,
13354 0xe0000000: 0x0,
13355 0xf0000000: 0x8202,
13356 0x8000000: 0x0,
13357 0x18000000: 0x808202,
13358 0x28000000: 0x8202,
13359 0x38000000: 0x8000,
13360 0x48000000: 0x808200,
13361 0x58000000: 0x200,
13362 0x68000000: 0x808002,
13363 0x78000000: 0x2,
13364 0x88000000: 0x800200,
13365 0x98000000: 0x8200,
13366 0xa8000000: 0x808000,
13367 0xb8000000: 0x800202,
13368 0xc8000000: 0x800002,
13369 0xd8000000: 0x8002,
13370 0xe8000000: 0x202,
13371 0xf8000000: 0x800000,
13372 0x1: 0x8000,
13373 0x10000001: 0x2,
13374 0x20000001: 0x808200,
13375 0x30000001: 0x800000,
13376 0x40000001: 0x808002,
13377 0x50000001: 0x8200,
13378 0x60000001: 0x200,
13379 0x70000001: 0x800202,
13380 0x80000001: 0x808202,
13381 0x90000001: 0x808000,
13382 0xa0000001: 0x800002,
13383 0xb0000001: 0x8202,
13384 0xc0000001: 0x202,
13385 0xd0000001: 0x800200,
13386 0xe0000001: 0x8002,
13387 0xf0000001: 0x0,
13388 0x8000001: 0x808202,
13389 0x18000001: 0x808000,
13390 0x28000001: 0x800000,
13391 0x38000001: 0x200,
13392 0x48000001: 0x8000,
13393 0x58000001: 0x800002,
13394 0x68000001: 0x2,
13395 0x78000001: 0x8202,
13396 0x88000001: 0x8002,
13397 0x98000001: 0x800202,
13398 0xa8000001: 0x202,
13399 0xb8000001: 0x808200,
13400 0xc8000001: 0x800200,
13401 0xd8000001: 0x0,
13402 0xe8000001: 0x8200,
13403 0xf8000001: 0x808002
13404 },
13405 {
13406 0x0: 0x40084010,
13407 0x1000000: 0x4000,
13408 0x2000000: 0x80000,
13409 0x3000000: 0x40080010,
13410 0x4000000: 0x40000010,
13411 0x5000000: 0x40084000,
13412 0x6000000: 0x40004000,
13413 0x7000000: 0x10,
13414 0x8000000: 0x84000,
13415 0x9000000: 0x40004010,
13416 0xa000000: 0x40000000,
13417 0xb000000: 0x84010,
13418 0xc000000: 0x80010,
13419 0xd000000: 0x0,
13420 0xe000000: 0x4010,
13421 0xf000000: 0x40080000,
13422 0x800000: 0x40004000,
13423 0x1800000: 0x84010,
13424 0x2800000: 0x10,
13425 0x3800000: 0x40004010,
13426 0x4800000: 0x40084010,
13427 0x5800000: 0x40000000,
13428 0x6800000: 0x80000,
13429 0x7800000: 0x40080010,
13430 0x8800000: 0x80010,
13431 0x9800000: 0x0,
13432 0xa800000: 0x4000,
13433 0xb800000: 0x40080000,
13434 0xc800000: 0x40000010,
13435 0xd800000: 0x84000,
13436 0xe800000: 0x40084000,
13437 0xf800000: 0x4010,
13438 0x10000000: 0x0,
13439 0x11000000: 0x40080010,
13440 0x12000000: 0x40004010,
13441 0x13000000: 0x40084000,
13442 0x14000000: 0x40080000,
13443 0x15000000: 0x10,
13444 0x16000000: 0x84010,
13445 0x17000000: 0x4000,
13446 0x18000000: 0x4010,
13447 0x19000000: 0x80000,
13448 0x1a000000: 0x80010,
13449 0x1b000000: 0x40000010,
13450 0x1c000000: 0x84000,
13451 0x1d000000: 0x40004000,
13452 0x1e000000: 0x40000000,
13453 0x1f000000: 0x40084010,
13454 0x10800000: 0x84010,
13455 0x11800000: 0x80000,
13456 0x12800000: 0x40080000,
13457 0x13800000: 0x4000,
13458 0x14800000: 0x40004000,
13459 0x15800000: 0x40084010,
13460 0x16800000: 0x10,
13461 0x17800000: 0x40000000,
13462 0x18800000: 0x40084000,
13463 0x19800000: 0x40000010,
13464 0x1a800000: 0x40004010,
13465 0x1b800000: 0x80010,
13466 0x1c800000: 0x0,
13467 0x1d800000: 0x4010,
13468 0x1e800000: 0x40080010,
13469 0x1f800000: 0x84000
13470 },
13471 {
13472 0x0: 0x104,
13473 0x100000: 0x0,
13474 0x200000: 0x4000100,
13475 0x300000: 0x10104,
13476 0x400000: 0x10004,
13477 0x500000: 0x4000004,
13478 0x600000: 0x4010104,
13479 0x700000: 0x4010000,
13480 0x800000: 0x4000000,
13481 0x900000: 0x4010100,
13482 0xa00000: 0x10100,
13483 0xb00000: 0x4010004,
13484 0xc00000: 0x4000104,
13485 0xd00000: 0x10000,
13486 0xe00000: 0x4,
13487 0xf00000: 0x100,
13488 0x80000: 0x4010100,
13489 0x180000: 0x4010004,
13490 0x280000: 0x0,
13491 0x380000: 0x4000100,
13492 0x480000: 0x4000004,
13493 0x580000: 0x10000,
13494 0x680000: 0x10004,
13495 0x780000: 0x104,
13496 0x880000: 0x4,
13497 0x980000: 0x100,
13498 0xa80000: 0x4010000,
13499 0xb80000: 0x10104,
13500 0xc80000: 0x10100,
13501 0xd80000: 0x4000104,
13502 0xe80000: 0x4010104,
13503 0xf80000: 0x4000000,
13504 0x1000000: 0x4010100,
13505 0x1100000: 0x10004,
13506 0x1200000: 0x10000,
13507 0x1300000: 0x4000100,
13508 0x1400000: 0x100,
13509 0x1500000: 0x4010104,
13510 0x1600000: 0x4000004,
13511 0x1700000: 0x0,
13512 0x1800000: 0x4000104,
13513 0x1900000: 0x4000000,
13514 0x1a00000: 0x4,
13515 0x1b00000: 0x10100,
13516 0x1c00000: 0x4010000,
13517 0x1d00000: 0x104,
13518 0x1e00000: 0x10104,
13519 0x1f00000: 0x4010004,
13520 0x1080000: 0x4000000,
13521 0x1180000: 0x104,
13522 0x1280000: 0x4010100,
13523 0x1380000: 0x0,
13524 0x1480000: 0x10004,
13525 0x1580000: 0x4000100,
13526 0x1680000: 0x100,
13527 0x1780000: 0x4010004,
13528 0x1880000: 0x10000,
13529 0x1980000: 0x4010104,
13530 0x1a80000: 0x10104,
13531 0x1b80000: 0x4000004,
13532 0x1c80000: 0x4000104,
13533 0x1d80000: 0x4010000,
13534 0x1e80000: 0x4,
13535 0x1f80000: 0x10100
13536 },
13537 {
13538 0x0: 0x80401000,
13539 0x10000: 0x80001040,
13540 0x20000: 0x401040,
13541 0x30000: 0x80400000,
13542 0x40000: 0x0,
13543 0x50000: 0x401000,
13544 0x60000: 0x80000040,
13545 0x70000: 0x400040,
13546 0x80000: 0x80000000,
13547 0x90000: 0x400000,
13548 0xa0000: 0x40,
13549 0xb0000: 0x80001000,
13550 0xc0000: 0x80400040,
13551 0xd0000: 0x1040,
13552 0xe0000: 0x1000,
13553 0xf0000: 0x80401040,
13554 0x8000: 0x80001040,
13555 0x18000: 0x40,
13556 0x28000: 0x80400040,
13557 0x38000: 0x80001000,
13558 0x48000: 0x401000,
13559 0x58000: 0x80401040,
13560 0x68000: 0x0,
13561 0x78000: 0x80400000,
13562 0x88000: 0x1000,
13563 0x98000: 0x80401000,
13564 0xa8000: 0x400000,
13565 0xb8000: 0x1040,
13566 0xc8000: 0x80000000,
13567 0xd8000: 0x400040,
13568 0xe8000: 0x401040,
13569 0xf8000: 0x80000040,
13570 0x100000: 0x400040,
13571 0x110000: 0x401000,
13572 0x120000: 0x80000040,
13573 0x130000: 0x0,
13574 0x140000: 0x1040,
13575 0x150000: 0x80400040,
13576 0x160000: 0x80401000,
13577 0x170000: 0x80001040,
13578 0x180000: 0x80401040,
13579 0x190000: 0x80000000,
13580 0x1a0000: 0x80400000,
13581 0x1b0000: 0x401040,
13582 0x1c0000: 0x80001000,
13583 0x1d0000: 0x400000,
13584 0x1e0000: 0x40,
13585 0x1f0000: 0x1000,
13586 0x108000: 0x80400000,
13587 0x118000: 0x80401040,
13588 0x128000: 0x0,
13589 0x138000: 0x401000,
13590 0x148000: 0x400040,
13591 0x158000: 0x80000000,
13592 0x168000: 0x80001040,
13593 0x178000: 0x40,
13594 0x188000: 0x80000040,
13595 0x198000: 0x1000,
13596 0x1a8000: 0x80001000,
13597 0x1b8000: 0x80400040,
13598 0x1c8000: 0x1040,
13599 0x1d8000: 0x80401000,
13600 0x1e8000: 0x400000,
13601 0x1f8000: 0x401040
13602 },
13603 {
13604 0x0: 0x80,
13605 0x1000: 0x1040000,
13606 0x2000: 0x40000,
13607 0x3000: 0x20000000,
13608 0x4000: 0x20040080,
13609 0x5000: 0x1000080,
13610 0x6000: 0x21000080,
13611 0x7000: 0x40080,
13612 0x8000: 0x1000000,
13613 0x9000: 0x20040000,
13614 0xa000: 0x20000080,
13615 0xb000: 0x21040080,
13616 0xc000: 0x21040000,
13617 0xd000: 0x0,
13618 0xe000: 0x1040080,
13619 0xf000: 0x21000000,
13620 0x800: 0x1040080,
13621 0x1800: 0x21000080,
13622 0x2800: 0x80,
13623 0x3800: 0x1040000,
13624 0x4800: 0x40000,
13625 0x5800: 0x20040080,
13626 0x6800: 0x21040000,
13627 0x7800: 0x20000000,
13628 0x8800: 0x20040000,
13629 0x9800: 0x0,
13630 0xa800: 0x21040080,
13631 0xb800: 0x1000080,
13632 0xc800: 0x20000080,
13633 0xd800: 0x21000000,
13634 0xe800: 0x1000000,
13635 0xf800: 0x40080,
13636 0x10000: 0x40000,
13637 0x11000: 0x80,
13638 0x12000: 0x20000000,
13639 0x13000: 0x21000080,
13640 0x14000: 0x1000080,
13641 0x15000: 0x21040000,
13642 0x16000: 0x20040080,
13643 0x17000: 0x1000000,
13644 0x18000: 0x21040080,
13645 0x19000: 0x21000000,
13646 0x1a000: 0x1040000,
13647 0x1b000: 0x20040000,
13648 0x1c000: 0x40080,
13649 0x1d000: 0x20000080,
13650 0x1e000: 0x0,
13651 0x1f000: 0x1040080,
13652 0x10800: 0x21000080,
13653 0x11800: 0x1000000,
13654 0x12800: 0x1040000,
13655 0x13800: 0x20040080,
13656 0x14800: 0x20000000,
13657 0x15800: 0x1040080,
13658 0x16800: 0x80,
13659 0x17800: 0x21040000,
13660 0x18800: 0x40080,
13661 0x19800: 0x21040080,
13662 0x1a800: 0x0,
13663 0x1b800: 0x21000000,
13664 0x1c800: 0x1000080,
13665 0x1d800: 0x40000,
13666 0x1e800: 0x20040000,
13667 0x1f800: 0x20000080
13668 },
13669 {
13670 0x0: 0x10000008,
13671 0x100: 0x2000,
13672 0x200: 0x10200000,
13673 0x300: 0x10202008,
13674 0x400: 0x10002000,
13675 0x500: 0x200000,
13676 0x600: 0x200008,
13677 0x700: 0x10000000,
13678 0x800: 0x0,
13679 0x900: 0x10002008,
13680 0xa00: 0x202000,
13681 0xb00: 0x8,
13682 0xc00: 0x10200008,
13683 0xd00: 0x202008,
13684 0xe00: 0x2008,
13685 0xf00: 0x10202000,
13686 0x80: 0x10200000,
13687 0x180: 0x10202008,
13688 0x280: 0x8,
13689 0x380: 0x200000,
13690 0x480: 0x202008,
13691 0x580: 0x10000008,
13692 0x680: 0x10002000,
13693 0x780: 0x2008,
13694 0x880: 0x200008,
13695 0x980: 0x2000,
13696 0xa80: 0x10002008,
13697 0xb80: 0x10200008,
13698 0xc80: 0x0,
13699 0xd80: 0x10202000,
13700 0xe80: 0x202000,
13701 0xf80: 0x10000000,
13702 0x1000: 0x10002000,
13703 0x1100: 0x10200008,
13704 0x1200: 0x10202008,
13705 0x1300: 0x2008,
13706 0x1400: 0x200000,
13707 0x1500: 0x10000000,
13708 0x1600: 0x10000008,
13709 0x1700: 0x202000,
13710 0x1800: 0x202008,
13711 0x1900: 0x0,
13712 0x1a00: 0x8,
13713 0x1b00: 0x10200000,
13714 0x1c00: 0x2000,
13715 0x1d00: 0x10002008,
13716 0x1e00: 0x10202000,
13717 0x1f00: 0x200008,
13718 0x1080: 0x8,
13719 0x1180: 0x202000,
13720 0x1280: 0x200000,
13721 0x1380: 0x10000008,
13722 0x1480: 0x10002000,
13723 0x1580: 0x2008,
13724 0x1680: 0x10202008,
13725 0x1780: 0x10200000,
13726 0x1880: 0x10202000,
13727 0x1980: 0x10200008,
13728 0x1a80: 0x2000,
13729 0x1b80: 0x202008,
13730 0x1c80: 0x200008,
13731 0x1d80: 0x0,
13732 0x1e80: 0x10000000,
13733 0x1f80: 0x10002008
13734 },
13735 {
13736 0x0: 0x100000,
13737 0x10: 0x2000401,
13738 0x20: 0x400,
13739 0x30: 0x100401,
13740 0x40: 0x2100401,
13741 0x50: 0x0,
13742 0x60: 0x1,
13743 0x70: 0x2100001,
13744 0x80: 0x2000400,
13745 0x90: 0x100001,
13746 0xa0: 0x2000001,
13747 0xb0: 0x2100400,
13748 0xc0: 0x2100000,
13749 0xd0: 0x401,
13750 0xe0: 0x100400,
13751 0xf0: 0x2000000,
13752 0x8: 0x2100001,
13753 0x18: 0x0,
13754 0x28: 0x2000401,
13755 0x38: 0x2100400,
13756 0x48: 0x100000,
13757 0x58: 0x2000001,
13758 0x68: 0x2000000,
13759 0x78: 0x401,
13760 0x88: 0x100401,
13761 0x98: 0x2000400,
13762 0xa8: 0x2100000,
13763 0xb8: 0x100001,
13764 0xc8: 0x400,
13765 0xd8: 0x2100401,
13766 0xe8: 0x1,
13767 0xf8: 0x100400,
13768 0x100: 0x2000000,
13769 0x110: 0x100000,
13770 0x120: 0x2000401,
13771 0x130: 0x2100001,
13772 0x140: 0x100001,
13773 0x150: 0x2000400,
13774 0x160: 0x2100400,
13775 0x170: 0x100401,
13776 0x180: 0x401,
13777 0x190: 0x2100401,
13778 0x1a0: 0x100400,
13779 0x1b0: 0x1,
13780 0x1c0: 0x0,
13781 0x1d0: 0x2100000,
13782 0x1e0: 0x2000001,
13783 0x1f0: 0x400,
13784 0x108: 0x100400,
13785 0x118: 0x2000401,
13786 0x128: 0x2100001,
13787 0x138: 0x1,
13788 0x148: 0x2000000,
13789 0x158: 0x100000,
13790 0x168: 0x401,
13791 0x178: 0x2100400,
13792 0x188: 0x2000001,
13793 0x198: 0x2100000,
13794 0x1a8: 0x0,
13795 0x1b8: 0x2100401,
13796 0x1c8: 0x100401,
13797 0x1d8: 0x400,
13798 0x1e8: 0x2000400,
13799 0x1f8: 0x100001
13800 },
13801 {
13802 0x0: 0x8000820,
13803 0x1: 0x20000,
13804 0x2: 0x8000000,
13805 0x3: 0x20,
13806 0x4: 0x20020,
13807 0x5: 0x8020820,
13808 0x6: 0x8020800,
13809 0x7: 0x800,
13810 0x8: 0x8020000,
13811 0x9: 0x8000800,
13812 0xa: 0x20800,
13813 0xb: 0x8020020,
13814 0xc: 0x820,
13815 0xd: 0x0,
13816 0xe: 0x8000020,
13817 0xf: 0x20820,
13818 0x80000000: 0x800,
13819 0x80000001: 0x8020820,
13820 0x80000002: 0x8000820,
13821 0x80000003: 0x8000000,
13822 0x80000004: 0x8020000,
13823 0x80000005: 0x20800,
13824 0x80000006: 0x20820,
13825 0x80000007: 0x20,
13826 0x80000008: 0x8000020,
13827 0x80000009: 0x820,
13828 0x8000000a: 0x20020,
13829 0x8000000b: 0x8020800,
13830 0x8000000c: 0x0,
13831 0x8000000d: 0x8020020,
13832 0x8000000e: 0x8000800,
13833 0x8000000f: 0x20000,
13834 0x10: 0x20820,
13835 0x11: 0x8020800,
13836 0x12: 0x20,
13837 0x13: 0x800,
13838 0x14: 0x8000800,
13839 0x15: 0x8000020,
13840 0x16: 0x8020020,
13841 0x17: 0x20000,
13842 0x18: 0x0,
13843 0x19: 0x20020,
13844 0x1a: 0x8020000,
13845 0x1b: 0x8000820,
13846 0x1c: 0x8020820,
13847 0x1d: 0x20800,
13848 0x1e: 0x820,
13849 0x1f: 0x8000000,
13850 0x80000010: 0x20000,
13851 0x80000011: 0x800,
13852 0x80000012: 0x8020020,
13853 0x80000013: 0x20820,
13854 0x80000014: 0x20,
13855 0x80000015: 0x8020000,
13856 0x80000016: 0x8000000,
13857 0x80000017: 0x8000820,
13858 0x80000018: 0x8020820,
13859 0x80000019: 0x8000020,
13860 0x8000001a: 0x8000800,
13861 0x8000001b: 0x0,
13862 0x8000001c: 0x20800,
13863 0x8000001d: 0x820,
13864 0x8000001e: 0x20020,
13865 0x8000001f: 0x8020800
13866 }
13867 ];
13868
13869 // Masks that select the SBOX input
13870 var SBOX_MASK = [
13871 0xf8000001, 0x1f800000, 0x01f80000, 0x001f8000,
13872 0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f
13873 ];
13874
13875 /**
13876 * DES block cipher algorithm.
13877 */
13878 var DES = C_algo.DES = BlockCipher.extend({
13879 _doReset: function () {
13880 // Shortcuts
13881 var key = this._key;
13882 var keyWords = key.words;
13883
13884 // Select 56 bits according to PC1
13885 var keyBits = [];
13886 for (var i = 0; i < 56; i++) {
13887 var keyBitPos = PC1[i] - 1;
13888 keyBits[i] = (keyWords[keyBitPos >>> 5] >>> (31 - keyBitPos % 32)) & 1;
13889 }
13890
13891 // Assemble 16 subkeys
13892 var subKeys = this._subKeys = [];
13893 for (var nSubKey = 0; nSubKey < 16; nSubKey++) {
13894 // Create subkey
13895 var subKey = subKeys[nSubKey] = [];
13896
13897 // Shortcut
13898 var bitShift = BIT_SHIFTS[nSubKey];
13899
13900 // Select 48 bits according to PC2
13901 for (var i = 0; i < 24; i++) {
13902 // Select from the left 28 key bits
13903 subKey[(i / 6) | 0] |= keyBits[((PC2[i] - 1) + bitShift) % 28] << (31 - i % 6);
13904
13905 // Select from the right 28 key bits
13906 subKey[4 + ((i / 6) | 0)] |= keyBits[28 + (((PC2[i + 24] - 1) + bitShift) % 28)] << (31 - i % 6);
13907 }
13908
13909 // Since each subkey is applied to an expanded 32-bit input,
13910 // the subkey can be broken into 8 values scaled to 32-bits,
13911 // which allows the key to be used without expansion
13912 subKey[0] = (subKey[0] << 1) | (subKey[0] >>> 31);
13913 for (var i = 1; i < 7; i++) {
13914 subKey[i] = subKey[i] >>> ((i - 1) * 4 + 3);
13915 }
13916 subKey[7] = (subKey[7] << 5) | (subKey[7] >>> 27);
13917 }
13918
13919 // Compute inverse subkeys
13920 var invSubKeys = this._invSubKeys = [];
13921 for (var i = 0; i < 16; i++) {
13922 invSubKeys[i] = subKeys[15 - i];
13923 }
13924 },
13925
13926 encryptBlock: function (M, offset) {
13927 this._doCryptBlock(M, offset, this._subKeys);
13928 },
13929
13930 decryptBlock: function (M, offset) {
13931 this._doCryptBlock(M, offset, this._invSubKeys);
13932 },
13933
13934 _doCryptBlock: function (M, offset, subKeys) {
13935 // Get input
13936 this._lBlock = M[offset];
13937 this._rBlock = M[offset + 1];
13938
13939 // Initial permutation
13940 exchangeLR.call(this, 4, 0x0f0f0f0f);
13941 exchangeLR.call(this, 16, 0x0000ffff);
13942 exchangeRL.call(this, 2, 0x33333333);
13943 exchangeRL.call(this, 8, 0x00ff00ff);
13944 exchangeLR.call(this, 1, 0x55555555);
13945
13946 // Rounds
13947 for (var round = 0; round < 16; round++) {
13948 // Shortcuts
13949 var subKey = subKeys[round];
13950 var lBlock = this._lBlock;
13951 var rBlock = this._rBlock;
13952
13953 // Feistel function
13954 var f = 0;
13955 for (var i = 0; i < 8; i++) {
13956 f |= SBOX_P[i][((rBlock ^ subKey[i]) & SBOX_MASK[i]) >>> 0];
13957 }
13958 this._lBlock = rBlock;
13959 this._rBlock = lBlock ^ f;
13960 }
13961
13962 // Undo swap from last round
13963 var t = this._lBlock;
13964 this._lBlock = this._rBlock;
13965 this._rBlock = t;
13966
13967 // Final permutation
13968 exchangeLR.call(this, 1, 0x55555555);
13969 exchangeRL.call(this, 8, 0x00ff00ff);
13970 exchangeRL.call(this, 2, 0x33333333);
13971 exchangeLR.call(this, 16, 0x0000ffff);
13972 exchangeLR.call(this, 4, 0x0f0f0f0f);
13973
13974 // Set output
13975 M[offset] = this._lBlock;
13976 M[offset + 1] = this._rBlock;
13977 },
13978
13979 keySize: 64/32,
13980
13981 ivSize: 64/32,
13982
13983 blockSize: 64/32
13984 });
13985
13986 // Swap bits across the left and right words
13987 function exchangeLR(offset, mask) {
13988 var t = ((this._lBlock >>> offset) ^ this._rBlock) & mask;
13989 this._rBlock ^= t;
13990 this._lBlock ^= t << offset;
13991 }
13992
13993 function exchangeRL(offset, mask) {
13994 var t = ((this._rBlock >>> offset) ^ this._lBlock) & mask;
13995 this._lBlock ^= t;
13996 this._rBlock ^= t << offset;
13997 }
13998
13999 /**
14000 * Shortcut functions to the cipher's object interface.
14001 *
14002 * @example
14003 *
14004 * var ciphertext = CryptoJS.DES.encrypt(message, key, cfg);
14005 * var plaintext = CryptoJS.DES.decrypt(ciphertext, key, cfg);
14006 */
14007 C.DES = BlockCipher._createHelper(DES);
14008
14009 /**
14010 * Triple-DES block cipher algorithm.
14011 */
14012 var TripleDES = C_algo.TripleDES = BlockCipher.extend({
14013 _doReset: function () {
14014 // Shortcuts
14015 var key = this._key;
14016 var keyWords = key.words;
14017
14018 // Create DES instances
14019 this._des1 = DES.createEncryptor(WordArray.create(keyWords.slice(0, 2)));
14020 this._des2 = DES.createEncryptor(WordArray.create(keyWords.slice(2, 4)));
14021 this._des3 = DES.createEncryptor(WordArray.create(keyWords.slice(4, 6)));
14022 },
14023
14024 encryptBlock: function (M, offset) {
14025 this._des1.encryptBlock(M, offset);
14026 this._des2.decryptBlock(M, offset);
14027 this._des3.encryptBlock(M, offset);
14028 },
14029
14030 decryptBlock: function (M, offset) {
14031 this._des3.decryptBlock(M, offset);
14032 this._des2.encryptBlock(M, offset);
14033 this._des1.decryptBlock(M, offset);
14034 },
14035
14036 keySize: 192/32,
14037
14038 ivSize: 64/32,
14039
14040 blockSize: 64/32
14041 });
14042
14043 /**
14044 * Shortcut functions to the cipher's object interface.
14045 *
14046 * @example
14047 *
14048 * var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg);
14049 * var plaintext = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg);
14050 */
14051 C.TripleDES = BlockCipher._createHelper(TripleDES);
14052 }());
14053
14054
14055 return CryptoJS.TripleDES;
14056
14057}));
14058
14059/***/ }),
14060/* 120 */
14061/***/ (function(module, exports) {
14062
14063module.exports = [
14064 {
14065 "constant": true,
14066 "inputs": [
14067 {
14068 "name": "_owner",
14069 "type": "address"
14070 }
14071 ],
14072 "name": "name",
14073 "outputs": [
14074 {
14075 "name": "o_name",
14076 "type": "bytes32"
14077 }
14078 ],
14079 "type": "function"
14080 },
14081 {
14082 "constant": true,
14083 "inputs": [
14084 {
14085 "name": "_name",
14086 "type": "bytes32"
14087 }
14088 ],
14089 "name": "owner",
14090 "outputs": [
14091 {
14092 "name": "",
14093 "type": "address"
14094 }
14095 ],
14096 "type": "function"
14097 },
14098 {
14099 "constant": true,
14100 "inputs": [
14101 {
14102 "name": "_name",
14103 "type": "bytes32"
14104 }
14105 ],
14106 "name": "content",
14107 "outputs": [
14108 {
14109 "name": "",
14110 "type": "bytes32"
14111 }
14112 ],
14113 "type": "function"
14114 },
14115 {
14116 "constant": true,
14117 "inputs": [
14118 {
14119 "name": "_name",
14120 "type": "bytes32"
14121 }
14122 ],
14123 "name": "addr",
14124 "outputs": [
14125 {
14126 "name": "",
14127 "type": "address"
14128 }
14129 ],
14130 "type": "function"
14131 },
14132 {
14133 "constant": false,
14134 "inputs": [
14135 {
14136 "name": "_name",
14137 "type": "bytes32"
14138 }
14139 ],
14140 "name": "reserve",
14141 "outputs": [],
14142 "type": "function"
14143 },
14144 {
14145 "constant": true,
14146 "inputs": [
14147 {
14148 "name": "_name",
14149 "type": "bytes32"
14150 }
14151 ],
14152 "name": "subRegistrar",
14153 "outputs": [
14154 {
14155 "name": "",
14156 "type": "address"
14157 }
14158 ],
14159 "type": "function"
14160 },
14161 {
14162 "constant": false,
14163 "inputs": [
14164 {
14165 "name": "_name",
14166 "type": "bytes32"
14167 },
14168 {
14169 "name": "_newOwner",
14170 "type": "address"
14171 }
14172 ],
14173 "name": "transfer",
14174 "outputs": [],
14175 "type": "function"
14176 },
14177 {
14178 "constant": false,
14179 "inputs": [
14180 {
14181 "name": "_name",
14182 "type": "bytes32"
14183 },
14184 {
14185 "name": "_registrar",
14186 "type": "address"
14187 }
14188 ],
14189 "name": "setSubRegistrar",
14190 "outputs": [],
14191 "type": "function"
14192 },
14193 {
14194 "constant": false,
14195 "inputs": [],
14196 "name": "Registrar",
14197 "outputs": [],
14198 "type": "function"
14199 },
14200 {
14201 "constant": false,
14202 "inputs": [
14203 {
14204 "name": "_name",
14205 "type": "bytes32"
14206 },
14207 {
14208 "name": "_a",
14209 "type": "address"
14210 },
14211 {
14212 "name": "_primary",
14213 "type": "bool"
14214 }
14215 ],
14216 "name": "setAddress",
14217 "outputs": [],
14218 "type": "function"
14219 },
14220 {
14221 "constant": false,
14222 "inputs": [
14223 {
14224 "name": "_name",
14225 "type": "bytes32"
14226 },
14227 {
14228 "name": "_content",
14229 "type": "bytes32"
14230 }
14231 ],
14232 "name": "setContent",
14233 "outputs": [],
14234 "type": "function"
14235 },
14236 {
14237 "constant": false,
14238 "inputs": [
14239 {
14240 "name": "_name",
14241 "type": "bytes32"
14242 }
14243 ],
14244 "name": "disown",
14245 "outputs": [],
14246 "type": "function"
14247 },
14248 {
14249 "anonymous": false,
14250 "inputs": [
14251 {
14252 "indexed": true,
14253 "name": "_name",
14254 "type": "bytes32"
14255 },
14256 {
14257 "indexed": false,
14258 "name": "_winner",
14259 "type": "address"
14260 }
14261 ],
14262 "name": "AuctionEnded",
14263 "type": "event"
14264 },
14265 {
14266 "anonymous": false,
14267 "inputs": [
14268 {
14269 "indexed": true,
14270 "name": "_name",
14271 "type": "bytes32"
14272 },
14273 {
14274 "indexed": false,
14275 "name": "_bidder",
14276 "type": "address"
14277 },
14278 {
14279 "indexed": false,
14280 "name": "_value",
14281 "type": "uint256"
14282 }
14283 ],
14284 "name": "NewBid",
14285 "type": "event"
14286 },
14287 {
14288 "anonymous": false,
14289 "inputs": [
14290 {
14291 "indexed": true,
14292 "name": "name",
14293 "type": "bytes32"
14294 }
14295 ],
14296 "name": "Changed",
14297 "type": "event"
14298 },
14299 {
14300 "anonymous": false,
14301 "inputs": [
14302 {
14303 "indexed": true,
14304 "name": "name",
14305 "type": "bytes32"
14306 },
14307 {
14308 "indexed": true,
14309 "name": "addr",
14310 "type": "address"
14311 }
14312 ],
14313 "name": "PrimaryChanged",
14314 "type": "event"
14315 }
14316];
14317
14318/***/ }),
14319/* 121 */
14320/***/ (function(module, exports) {
14321
14322module.exports = [
14323 {
14324 "constant": true,
14325 "inputs": [
14326 {
14327 "name": "_name",
14328 "type": "bytes32"
14329 }
14330 ],
14331 "name": "owner",
14332 "outputs": [
14333 {
14334 "name": "",
14335 "type": "address"
14336 }
14337 ],
14338 "type": "function"
14339 },
14340 {
14341 "constant": false,
14342 "inputs": [
14343 {
14344 "name": "_name",
14345 "type": "bytes32"
14346 },
14347 {
14348 "name": "_refund",
14349 "type": "address"
14350 }
14351 ],
14352 "name": "disown",
14353 "outputs": [],
14354 "type": "function"
14355 },
14356 {
14357 "constant": true,
14358 "inputs": [
14359 {
14360 "name": "_name",
14361 "type": "bytes32"
14362 }
14363 ],
14364 "name": "addr",
14365 "outputs": [
14366 {
14367 "name": "",
14368 "type": "address"
14369 }
14370 ],
14371 "type": "function"
14372 },
14373 {
14374 "constant": false,
14375 "inputs": [
14376 {
14377 "name": "_name",
14378 "type": "bytes32"
14379 }
14380 ],
14381 "name": "reserve",
14382 "outputs": [],
14383 "type": "function"
14384 },
14385 {
14386 "constant": false,
14387 "inputs": [
14388 {
14389 "name": "_name",
14390 "type": "bytes32"
14391 },
14392 {
14393 "name": "_newOwner",
14394 "type": "address"
14395 }
14396 ],
14397 "name": "transfer",
14398 "outputs": [],
14399 "type": "function"
14400 },
14401 {
14402 "constant": false,
14403 "inputs": [
14404 {
14405 "name": "_name",
14406 "type": "bytes32"
14407 },
14408 {
14409 "name": "_a",
14410 "type": "address"
14411 }
14412 ],
14413 "name": "setAddr",
14414 "outputs": [],
14415 "type": "function"
14416 },
14417 {
14418 "anonymous": false,
14419 "inputs": [
14420 {
14421 "indexed": true,
14422 "name": "name",
14423 "type": "bytes32"
14424 }
14425 ],
14426 "name": "Changed",
14427 "type": "event"
14428 }
14429];
14430
14431/***/ }),
14432/* 122 */
14433/***/ (function(module, exports) {
14434
14435module.exports = [
14436 {
14437 "constant": false,
14438 "inputs": [
14439 {
14440 "name": "from",
14441 "type": "bytes32"
14442 },
14443 {
14444 "name": "to",
14445 "type": "address"
14446 },
14447 {
14448 "name": "value",
14449 "type": "uint256"
14450 }
14451 ],
14452 "name": "transfer",
14453 "outputs": [],
14454 "type": "function"
14455 },
14456 {
14457 "constant": false,
14458 "inputs": [
14459 {
14460 "name": "from",
14461 "type": "bytes32"
14462 },
14463 {
14464 "name": "to",
14465 "type": "address"
14466 },
14467 {
14468 "name": "indirectId",
14469 "type": "bytes32"
14470 },
14471 {
14472 "name": "value",
14473 "type": "uint256"
14474 }
14475 ],
14476 "name": "icapTransfer",
14477 "outputs": [],
14478 "type": "function"
14479 },
14480 {
14481 "constant": false,
14482 "inputs": [
14483 {
14484 "name": "to",
14485 "type": "bytes32"
14486 }
14487 ],
14488 "name": "deposit",
14489 "outputs": [],
14490 "payable": true,
14491 "type": "function"
14492 },
14493 {
14494 "anonymous": false,
14495 "inputs": [
14496 {
14497 "indexed": true,
14498 "name": "from",
14499 "type": "address"
14500 },
14501 {
14502 "indexed": false,
14503 "name": "value",
14504 "type": "uint256"
14505 }
14506 ],
14507 "name": "AnonymousDeposit",
14508 "type": "event"
14509 },
14510 {
14511 "anonymous": false,
14512 "inputs": [
14513 {
14514 "indexed": true,
14515 "name": "from",
14516 "type": "address"
14517 },
14518 {
14519 "indexed": true,
14520 "name": "to",
14521 "type": "bytes32"
14522 },
14523 {
14524 "indexed": false,
14525 "name": "value",
14526 "type": "uint256"
14527 }
14528 ],
14529 "name": "Deposit",
14530 "type": "event"
14531 },
14532 {
14533 "anonymous": false,
14534 "inputs": [
14535 {
14536 "indexed": true,
14537 "name": "from",
14538 "type": "bytes32"
14539 },
14540 {
14541 "indexed": true,
14542 "name": "to",
14543 "type": "address"
14544 },
14545 {
14546 "indexed": false,
14547 "name": "value",
14548 "type": "uint256"
14549 }
14550 ],
14551 "name": "Transfer",
14552 "type": "event"
14553 },
14554 {
14555 "anonymous": false,
14556 "inputs": [
14557 {
14558 "indexed": true,
14559 "name": "from",
14560 "type": "bytes32"
14561 },
14562 {
14563 "indexed": true,
14564 "name": "to",
14565 "type": "address"
14566 },
14567 {
14568 "indexed": false,
14569 "name": "indirectId",
14570 "type": "bytes32"
14571 },
14572 {
14573 "indexed": false,
14574 "name": "value",
14575 "type": "uint256"
14576 }
14577 ],
14578 "name": "IcapTransfer",
14579 "type": "event"
14580 }
14581];
14582
14583/***/ }),
14584/* 123 */
14585/***/ (function(module, exports) {
14586
14587module.exports = {
14588 "version": "0.18.2"
14589};
14590
14591/***/ }),
14592/* 124 */
14593/***/ (function(module, exports, __webpack_require__) {
14594
14595/* WEBPACK VAR INJECTION */(function(module, global) {var __WEBPACK_AMD_DEFINE_RESULT__;/*! https://mths.be/utf8js v2.1.2 by @mathias */
14596;(function(root) {
14597
14598 // Detect free variables `exports`
14599 var freeExports = typeof exports == 'object' && exports;
14600
14601 // Detect free variable `module`
14602 var freeModule = typeof module == 'object' && module &&
14603 module.exports == freeExports && module;
14604
14605 // Detect free variable `global`, from Node.js or Browserified code,
14606 // and use it as `root`
14607 var freeGlobal = typeof global == 'object' && global;
14608 if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
14609 root = freeGlobal;
14610 }
14611
14612 /*--------------------------------------------------------------------------*/
14613
14614 var stringFromCharCode = String.fromCharCode;
14615
14616 // Taken from https://mths.be/punycode
14617 function ucs2decode(string) {
14618 var output = [];
14619 var counter = 0;
14620 var length = string.length;
14621 var value;
14622 var extra;
14623 while (counter < length) {
14624 value = string.charCodeAt(counter++);
14625 if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
14626 // high surrogate, and there is a next character
14627 extra = string.charCodeAt(counter++);
14628 if ((extra & 0xFC00) == 0xDC00) { // low surrogate
14629 output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
14630 } else {
14631 // unmatched surrogate; only append this code unit, in case the next
14632 // code unit is the high surrogate of a surrogate pair
14633 output.push(value);
14634 counter--;
14635 }
14636 } else {
14637 output.push(value);
14638 }
14639 }
14640 return output;
14641 }
14642
14643 // Taken from https://mths.be/punycode
14644 function ucs2encode(array) {
14645 var length = array.length;
14646 var index = -1;
14647 var value;
14648 var output = '';
14649 while (++index < length) {
14650 value = array[index];
14651 if (value > 0xFFFF) {
14652 value -= 0x10000;
14653 output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
14654 value = 0xDC00 | value & 0x3FF;
14655 }
14656 output += stringFromCharCode(value);
14657 }
14658 return output;
14659 }
14660
14661 function checkScalarValue(codePoint) {
14662 if (codePoint >= 0xD800 && codePoint <= 0xDFFF) {
14663 throw Error(
14664 'Lone surrogate U+' + codePoint.toString(16).toUpperCase() +
14665 ' is not a scalar value'
14666 );
14667 }
14668 }
14669 /*--------------------------------------------------------------------------*/
14670
14671 function createByte(codePoint, shift) {
14672 return stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80);
14673 }
14674
14675 function encodeCodePoint(codePoint) {
14676 if ((codePoint & 0xFFFFFF80) == 0) { // 1-byte sequence
14677 return stringFromCharCode(codePoint);
14678 }
14679 var symbol = '';
14680 if ((codePoint & 0xFFFFF800) == 0) { // 2-byte sequence
14681 symbol = stringFromCharCode(((codePoint >> 6) & 0x1F) | 0xC0);
14682 }
14683 else if ((codePoint & 0xFFFF0000) == 0) { // 3-byte sequence
14684 checkScalarValue(codePoint);
14685 symbol = stringFromCharCode(((codePoint >> 12) & 0x0F) | 0xE0);
14686 symbol += createByte(codePoint, 6);
14687 }
14688 else if ((codePoint & 0xFFE00000) == 0) { // 4-byte sequence
14689 symbol = stringFromCharCode(((codePoint >> 18) & 0x07) | 0xF0);
14690 symbol += createByte(codePoint, 12);
14691 symbol += createByte(codePoint, 6);
14692 }
14693 symbol += stringFromCharCode((codePoint & 0x3F) | 0x80);
14694 return symbol;
14695 }
14696
14697 function utf8encode(string) {
14698 var codePoints = ucs2decode(string);
14699 var length = codePoints.length;
14700 var index = -1;
14701 var codePoint;
14702 var byteString = '';
14703 while (++index < length) {
14704 codePoint = codePoints[index];
14705 byteString += encodeCodePoint(codePoint);
14706 }
14707 return byteString;
14708 }
14709
14710 /*--------------------------------------------------------------------------*/
14711
14712 function readContinuationByte() {
14713 if (byteIndex >= byteCount) {
14714 throw Error('Invalid byte index');
14715 }
14716
14717 var continuationByte = byteArray[byteIndex] & 0xFF;
14718 byteIndex++;
14719
14720 if ((continuationByte & 0xC0) == 0x80) {
14721 return continuationByte & 0x3F;
14722 }
14723
14724 // If we end up here, it’s not a continuation byte
14725 throw Error('Invalid continuation byte');
14726 }
14727
14728 function decodeSymbol() {
14729 var byte1;
14730 var byte2;
14731 var byte3;
14732 var byte4;
14733 var codePoint;
14734
14735 if (byteIndex > byteCount) {
14736 throw Error('Invalid byte index');
14737 }
14738
14739 if (byteIndex == byteCount) {
14740 return false;
14741 }
14742
14743 // Read first byte
14744 byte1 = byteArray[byteIndex] & 0xFF;
14745 byteIndex++;
14746
14747 // 1-byte sequence (no continuation bytes)
14748 if ((byte1 & 0x80) == 0) {
14749 return byte1;
14750 }
14751
14752 // 2-byte sequence
14753 if ((byte1 & 0xE0) == 0xC0) {
14754 byte2 = readContinuationByte();
14755 codePoint = ((byte1 & 0x1F) << 6) | byte2;
14756 if (codePoint >= 0x80) {
14757 return codePoint;
14758 } else {
14759 throw Error('Invalid continuation byte');
14760 }
14761 }
14762
14763 // 3-byte sequence (may include unpaired surrogates)
14764 if ((byte1 & 0xF0) == 0xE0) {
14765 byte2 = readContinuationByte();
14766 byte3 = readContinuationByte();
14767 codePoint = ((byte1 & 0x0F) << 12) | (byte2 << 6) | byte3;
14768 if (codePoint >= 0x0800) {
14769 checkScalarValue(codePoint);
14770 return codePoint;
14771 } else {
14772 throw Error('Invalid continuation byte');
14773 }
14774 }
14775
14776 // 4-byte sequence
14777 if ((byte1 & 0xF8) == 0xF0) {
14778 byte2 = readContinuationByte();
14779 byte3 = readContinuationByte();
14780 byte4 = readContinuationByte();
14781 codePoint = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0C) |
14782 (byte3 << 0x06) | byte4;
14783 if (codePoint >= 0x010000 && codePoint <= 0x10FFFF) {
14784 return codePoint;
14785 }
14786 }
14787
14788 throw Error('Invalid UTF-8 detected');
14789 }
14790
14791 var byteArray;
14792 var byteCount;
14793 var byteIndex;
14794 function utf8decode(byteString) {
14795 byteArray = ucs2decode(byteString);
14796 byteCount = byteArray.length;
14797 byteIndex = 0;
14798 var codePoints = [];
14799 var tmp;
14800 while ((tmp = decodeSymbol()) !== false) {
14801 codePoints.push(tmp);
14802 }
14803 return ucs2encode(codePoints);
14804 }
14805
14806 /*--------------------------------------------------------------------------*/
14807
14808 var utf8 = {
14809 'version': '2.1.2',
14810 'encode': utf8encode,
14811 'decode': utf8decode
14812 };
14813
14814 // Some AMD build optimizers, like r.js, check for specific condition patterns
14815 // like the following:
14816 if (
14817 true
14818 ) {
14819 !(__WEBPACK_AMD_DEFINE_RESULT__ = function() {
14820 return utf8;
14821 }.call(exports, __webpack_require__, exports, module),
14822 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
14823 } else if (freeExports && !freeExports.nodeType) {
14824 if (freeModule) { // in Node.js or RingoJS v0.8.0+
14825 freeModule.exports = utf8;
14826 } else { // in Narwhal or RingoJS v0.7.0-
14827 var object = {};
14828 var hasOwnProperty = object.hasOwnProperty;
14829 for (var key in utf8) {
14830 hasOwnProperty.call(utf8, key) && (freeExports[key] = utf8[key]);
14831 }
14832 }
14833 } else { // in Rhino or a web browser
14834 root.utf8 = utf8;
14835 }
14836
14837}(this));
14838
14839/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(155)(module), __webpack_require__(154)))
14840
14841/***/ }),
14842/* 125 */
14843/***/ (function(module, exports, __webpack_require__) {
14844
14845var f = __webpack_require__(3);
14846var SolidityType = __webpack_require__(4);
14847
14848/**
14849 * SolidityTypeAddress is a prootype that represents address type
14850 * It matches:
14851 * address
14852 * address[]
14853 * address[4]
14854 * address[][]
14855 * address[3][]
14856 * address[][6][], ...
14857 */
14858var SolidityTypeAddress = function () {
14859 this._inputFormatter = f.formatInputInt;
14860 this._outputFormatter = f.formatOutputAddress;
14861};
14862
14863SolidityTypeAddress.prototype = new SolidityType({});
14864SolidityTypeAddress.prototype.constructor = SolidityTypeAddress;
14865
14866SolidityTypeAddress.prototype.isType = function (name) {
14867 return !!name.match(/address(\[([0-9]*)\])?/);
14868};
14869
14870module.exports = SolidityTypeAddress;
14871
14872
14873/***/ }),
14874/* 126 */
14875/***/ (function(module, exports, __webpack_require__) {
14876
14877var f = __webpack_require__(3);
14878var SolidityType = __webpack_require__(4);
14879
14880/**
14881 * SolidityTypeBool is a prootype that represents bool type
14882 * It matches:
14883 * bool
14884 * bool[]
14885 * bool[4]
14886 * bool[][]
14887 * bool[3][]
14888 * bool[][6][], ...
14889 */
14890var SolidityTypeBool = function () {
14891 this._inputFormatter = f.formatInputBool;
14892 this._outputFormatter = f.formatOutputBool;
14893};
14894
14895SolidityTypeBool.prototype = new SolidityType({});
14896SolidityTypeBool.prototype.constructor = SolidityTypeBool;
14897
14898SolidityTypeBool.prototype.isType = function (name) {
14899 return !!name.match(/^bool(\[([0-9]*)\])*$/);
14900};
14901
14902module.exports = SolidityTypeBool;
14903
14904
14905/***/ }),
14906/* 127 */
14907/***/ (function(module, exports, __webpack_require__) {
14908
14909var f = __webpack_require__(3);
14910var SolidityType = __webpack_require__(4);
14911
14912/**
14913 * SolidityTypeBytes is a prototype that represents the bytes type.
14914 * It matches:
14915 * bytes
14916 * bytes[]
14917 * bytes[4]
14918 * bytes[][]
14919 * bytes[3][]
14920 * bytes[][6][], ...
14921 * bytes32
14922 * bytes8[4]
14923 * bytes[3][]
14924 */
14925var SolidityTypeBytes = function () {
14926 this._inputFormatter = f.formatInputBytes;
14927 this._outputFormatter = f.formatOutputBytes;
14928};
14929
14930SolidityTypeBytes.prototype = new SolidityType({});
14931SolidityTypeBytes.prototype.constructor = SolidityTypeBytes;
14932
14933SolidityTypeBytes.prototype.isType = function (name) {
14934 return !!name.match(/^bytes([0-9]{1,})(\[([0-9]*)\])*$/);
14935};
14936
14937module.exports = SolidityTypeBytes;
14938
14939
14940/***/ }),
14941/* 128 */
14942/***/ (function(module, exports, __webpack_require__) {
14943
14944var f = __webpack_require__(3);
14945var SolidityType = __webpack_require__(4);
14946
14947var SolidityTypeDynamicBytes = function () {
14948 this._inputFormatter = f.formatInputDynamicBytes;
14949 this._outputFormatter = f.formatOutputDynamicBytes;
14950};
14951
14952SolidityTypeDynamicBytes.prototype = new SolidityType({});
14953SolidityTypeDynamicBytes.prototype.constructor = SolidityTypeDynamicBytes;
14954
14955SolidityTypeDynamicBytes.prototype.isType = function (name) {
14956 return !!name.match(/^bytes(\[([0-9]*)\])*$/);
14957};
14958
14959SolidityTypeDynamicBytes.prototype.isDynamicType = function () {
14960 return true;
14961};
14962
14963module.exports = SolidityTypeDynamicBytes;
14964
14965
14966/***/ }),
14967/* 129 */
14968/***/ (function(module, exports, __webpack_require__) {
14969
14970var f = __webpack_require__(3);
14971var SolidityType = __webpack_require__(4);
14972
14973/**
14974 * SolidityTypeInt is a prootype that represents int type
14975 * It matches:
14976 * int
14977 * int[]
14978 * int[4]
14979 * int[][]
14980 * int[3][]
14981 * int[][6][], ...
14982 * int32
14983 * int64[]
14984 * int8[4]
14985 * int256[][]
14986 * int[3][]
14987 * int64[][6][], ...
14988 */
14989var SolidityTypeInt = function () {
14990 this._inputFormatter = f.formatInputInt;
14991 this._outputFormatter = f.formatOutputInt;
14992};
14993
14994SolidityTypeInt.prototype = new SolidityType({});
14995SolidityTypeInt.prototype.constructor = SolidityTypeInt;
14996
14997SolidityTypeInt.prototype.isType = function (name) {
14998 return !!name.match(/^int([0-9]*)?(\[([0-9]*)\])*$/);
14999};
15000
15001module.exports = SolidityTypeInt;
15002
15003
15004/***/ }),
15005/* 130 */
15006/***/ (function(module, exports, __webpack_require__) {
15007
15008var f = __webpack_require__(3);
15009var SolidityType = __webpack_require__(4);
15010
15011/**
15012 * SolidityTypeReal is a prootype that represents real type
15013 * It matches:
15014 * real
15015 * real[]
15016 * real[4]
15017 * real[][]
15018 * real[3][]
15019 * real[][6][], ...
15020 * real32
15021 * real64[]
15022 * real8[4]
15023 * real256[][]
15024 * real[3][]
15025 * real64[][6][], ...
15026 */
15027var SolidityTypeReal = function () {
15028 this._inputFormatter = f.formatInputReal;
15029 this._outputFormatter = f.formatOutputReal;
15030};
15031
15032SolidityTypeReal.prototype = new SolidityType({});
15033SolidityTypeReal.prototype.constructor = SolidityTypeReal;
15034
15035SolidityTypeReal.prototype.isType = function (name) {
15036 return !!name.match(/real([0-9]*)?(\[([0-9]*)\])?/);
15037};
15038
15039module.exports = SolidityTypeReal;
15040
15041
15042/***/ }),
15043/* 131 */
15044/***/ (function(module, exports, __webpack_require__) {
15045
15046var f = __webpack_require__(3);
15047var SolidityType = __webpack_require__(4);
15048
15049var SolidityTypeString = function () {
15050 this._inputFormatter = f.formatInputString;
15051 this._outputFormatter = f.formatOutputString;
15052};
15053
15054SolidityTypeString.prototype = new SolidityType({});
15055SolidityTypeString.prototype.constructor = SolidityTypeString;
15056
15057SolidityTypeString.prototype.isType = function (name) {
15058 return !!name.match(/^string(\[([0-9]*)\])*$/);
15059};
15060
15061SolidityTypeString.prototype.isDynamicType = function () {
15062 return true;
15063};
15064
15065module.exports = SolidityTypeString;
15066
15067
15068/***/ }),
15069/* 132 */
15070/***/ (function(module, exports, __webpack_require__) {
15071
15072var f = __webpack_require__(3);
15073var SolidityType = __webpack_require__(4);
15074
15075/**
15076 * SolidityTypeUInt is a prootype that represents uint type
15077 * It matches:
15078 * uint
15079 * uint[]
15080 * uint[4]
15081 * uint[][]
15082 * uint[3][]
15083 * uint[][6][], ...
15084 * uint32
15085 * uint64[]
15086 * uint8[4]
15087 * uint256[][]
15088 * uint[3][]
15089 * uint64[][6][], ...
15090 */
15091var SolidityTypeUInt = function () {
15092 this._inputFormatter = f.formatInputInt;
15093 this._outputFormatter = f.formatOutputUInt;
15094};
15095
15096SolidityTypeUInt.prototype = new SolidityType({});
15097SolidityTypeUInt.prototype.constructor = SolidityTypeUInt;
15098
15099SolidityTypeUInt.prototype.isType = function (name) {
15100 return !!name.match(/^uint([0-9]*)?(\[([0-9]*)\])*$/);
15101};
15102
15103module.exports = SolidityTypeUInt;
15104
15105
15106/***/ }),
15107/* 133 */
15108/***/ (function(module, exports, __webpack_require__) {
15109
15110var f = __webpack_require__(3);
15111var SolidityType = __webpack_require__(4);
15112
15113/**
15114 * SolidityTypeUReal is a prootype that represents ureal type
15115 * It matches:
15116 * ureal
15117 * ureal[]
15118 * ureal[4]
15119 * ureal[][]
15120 * ureal[3][]
15121 * ureal[][6][], ...
15122 * ureal32
15123 * ureal64[]
15124 * ureal8[4]
15125 * ureal256[][]
15126 * ureal[3][]
15127 * ureal64[][6][], ...
15128 */
15129var SolidityTypeUReal = function () {
15130 this._inputFormatter = f.formatInputReal;
15131 this._outputFormatter = f.formatOutputUReal;
15132};
15133
15134SolidityTypeUReal.prototype = new SolidityType({});
15135SolidityTypeUReal.prototype.constructor = SolidityTypeUReal;
15136
15137SolidityTypeUReal.prototype.isType = function (name) {
15138 return !!name.match(/^ureal([0-9]*)?(\[([0-9]*)\])*$/);
15139};
15140
15141module.exports = SolidityTypeUReal;
15142
15143
15144/***/ }),
15145/* 134 */
15146/***/ (function(module, exports, __webpack_require__) {
15147
15148"use strict";
15149
15150
15151// go env doesn't have and need XMLHttpRequest
15152if (typeof XMLHttpRequest === 'undefined') {
15153 exports.XMLHttpRequest = {};
15154} else {
15155 exports.XMLHttpRequest = XMLHttpRequest; // jshint ignore:line
15156}
15157
15158
15159
15160/***/ }),
15161/* 135 */
15162/***/ (function(module, exports, __webpack_require__) {
15163
15164/*
15165 This file is part of web3.js.
15166
15167 web3.js is free software: you can redistribute it and/or modify
15168 it under the terms of the GNU Lesser General Public License as published by
15169 the Free Software Foundation, either version 3 of the License, or
15170 (at your option) any later version.
15171
15172 web3.js is distributed in the hope that it will be useful,
15173 but WITHOUT ANY WARRANTY; without even the implied warranty of
15174 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15175 GNU Lesser General Public License for more details.
15176
15177 You should have received a copy of the GNU Lesser General Public License
15178 along with web3.js. If not, see <http://www.gnu.org/licenses/>.
15179*/
15180/**
15181 * @file web3.js
15182 * @authors:
15183 * Jeffrey Wilcke <jeff@ethdev.com>
15184 * Marek Kotewicz <marek@ethdev.com>
15185 * Marian Oancea <marian@ethdev.com>
15186 * Fabian Vogelsteller <fabian@ethdev.com>
15187 * Gav Wood <g@ethdev.com>
15188 * @date 2014
15189 */
15190
15191var RequestManager = __webpack_require__(150);
15192var Iban = __webpack_require__(31);
15193var Eth = __webpack_require__(144);
15194var DB = __webpack_require__(143);
15195var Shh = __webpack_require__(147);
15196var Net = __webpack_require__(145);
15197var Personal = __webpack_require__(146);
15198var Swarm = __webpack_require__(148);
15199var Settings = __webpack_require__(151);
15200var version = __webpack_require__(123);
15201var utils = __webpack_require__(2);
15202var sha3 = __webpack_require__(19);
15203var extend = __webpack_require__(139);
15204var Batch = __webpack_require__(137);
15205var Property = __webpack_require__(17);
15206var HttpProvider = __webpack_require__(141);
15207var IpcProvider = __webpack_require__(142);
15208var BigNumber = __webpack_require__(18);
15209
15210
15211
15212function Web3 (provider) {
15213 this._requestManager = new RequestManager(provider);
15214 this.currentProvider = provider;
15215 this.eth = new Eth(this);
15216 this.db = new DB(this);
15217 this.shh = new Shh(this);
15218 this.net = new Net(this);
15219 this.personal = new Personal(this);
15220 this.bzz = new Swarm(this);
15221 this.settings = new Settings();
15222 this.version = {
15223 api: version.version
15224 };
15225 this.providers = {
15226 HttpProvider: HttpProvider,
15227 IpcProvider: IpcProvider
15228 };
15229 this._extend = extend(this);
15230 this._extend({
15231 properties: properties()
15232 });
15233}
15234
15235// expose providers on the class
15236Web3.providers = {
15237 HttpProvider: HttpProvider,
15238 IpcProvider: IpcProvider
15239};
15240
15241Web3.prototype.setProvider = function (provider) {
15242 this._requestManager.setProvider(provider);
15243 this.currentProvider = provider;
15244};
15245
15246Web3.prototype.reset = function (keepIsSyncing) {
15247 this._requestManager.reset(keepIsSyncing);
15248 this.settings = new Settings();
15249};
15250
15251Web3.prototype.BigNumber = BigNumber;
15252Web3.prototype.toHex = utils.toHex;
15253Web3.prototype.toAscii = utils.toAscii;
15254Web3.prototype.toUtf8 = utils.toUtf8;
15255Web3.prototype.fromAscii = utils.fromAscii;
15256Web3.prototype.fromUtf8 = utils.fromUtf8;
15257Web3.prototype.toDecimal = utils.toDecimal;
15258Web3.prototype.fromDecimal = utils.fromDecimal;
15259Web3.prototype.toBigNumber = utils.toBigNumber;
15260Web3.prototype.toWei = utils.toWei;
15261Web3.prototype.fromWei = utils.fromWei;
15262Web3.prototype.isAddress = utils.isAddress;
15263Web3.prototype.isChecksumAddress = utils.isChecksumAddress;
15264Web3.prototype.toChecksumAddress = utils.toChecksumAddress;
15265Web3.prototype.isIBAN = utils.isIBAN;
15266
15267
15268Web3.prototype.sha3 = function(string, options) {
15269 return '0x' + sha3(string, options);
15270};
15271
15272/**
15273 * Transforms direct icap to address
15274 */
15275Web3.prototype.fromICAP = function (icap) {
15276 var iban = new Iban(icap);
15277 return iban.address();
15278};
15279
15280var properties = function () {
15281 return [
15282 new Property({
15283 name: 'version.node',
15284 getter: 'web3_clientVersion'
15285 }),
15286 new Property({
15287 name: 'version.network',
15288 getter: 'net_version',
15289 inputFormatter: utils.toDecimal
15290 }),
15291 new Property({
15292 name: 'version.ethereum',
15293 getter: 'eth_protocolVersion',
15294 inputFormatter: utils.toDecimal
15295 }),
15296 new Property({
15297 name: 'version.whisper',
15298 getter: 'shh_version',
15299 inputFormatter: utils.toDecimal
15300 })
15301 ];
15302};
15303
15304Web3.prototype.isConnected = function(){
15305 return (this.currentProvider && this.currentProvider.isConnected());
15306};
15307
15308Web3.prototype.createBatch = function () {
15309 return new Batch(this);
15310};
15311
15312module.exports = Web3;
15313
15314
15315
15316/***/ }),
15317/* 136 */
15318/***/ (function(module, exports, __webpack_require__) {
15319
15320/*
15321 This file is part of web3.js.
15322
15323 web3.js is free software: you can redistribute it and/or modify
15324 it under the terms of the GNU Lesser General Public License as published by
15325 the Free Software Foundation, either version 3 of the License, or
15326 (at your option) any later version.
15327
15328 web3.js is distributed in the hope that it will be useful,
15329 but WITHOUT ANY WARRANTY; without even the implied warranty of
15330 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15331 GNU Lesser General Public License for more details.
15332
15333 You should have received a copy of the GNU Lesser General Public License
15334 along with web3.js. If not, see <http://www.gnu.org/licenses/>.
15335*/
15336/**
15337 * @file allevents.js
15338 * @author Marek Kotewicz <marek@ethdev.com>
15339 * @date 2014
15340 */
15341
15342var sha3 = __webpack_require__(19);
15343var SolidityEvent = __webpack_require__(62);
15344var formatters = __webpack_require__(5);
15345var utils = __webpack_require__(2);
15346var Filter = __webpack_require__(30);
15347var watches = __webpack_require__(32);
15348
15349var AllSolidityEvents = function (requestManager, json, address) {
15350 this._requestManager = requestManager;
15351 this._json = json;
15352 this._address = address;
15353};
15354
15355AllSolidityEvents.prototype.encode = function (options) {
15356 options = options || {};
15357 var result = {};
15358
15359 ['fromBlock', 'toBlock'].filter(function (f) {
15360 return options[f] !== undefined;
15361 }).forEach(function (f) {
15362 result[f] = formatters.inputBlockNumberFormatter(options[f]);
15363 });
15364
15365 result.address = this._address;
15366
15367 return result;
15368};
15369
15370AllSolidityEvents.prototype.decode = function (data) {
15371 data.data = data.data || '';
15372 data.topics = data.topics || [];
15373
15374 var eventTopic = data.topics[0].slice(2);
15375 var match = this._json.filter(function (j) {
15376 return eventTopic === sha3(utils.transformToFullName(j));
15377 })[0];
15378
15379 if (!match) { // cannot find matching event?
15380 console.warn('cannot find event for log');
15381 return data;
15382 }
15383
15384 var event = new SolidityEvent(this._requestManager, match, this._address);
15385 return event.decode(data);
15386};
15387
15388AllSolidityEvents.prototype.execute = function (options, callback) {
15389
15390 if (utils.isFunction(arguments[arguments.length - 1])) {
15391 callback = arguments[arguments.length - 1];
15392 if(arguments.length === 1)
15393 options = null;
15394 }
15395
15396 var o = this.encode(options);
15397 var formatter = this.decode.bind(this);
15398 return new Filter(this._requestManager, o, watches.eth(), formatter, callback);
15399};
15400
15401AllSolidityEvents.prototype.attachToContract = function (contract) {
15402 var execute = this.execute.bind(this);
15403 contract.allEvents = execute;
15404};
15405
15406module.exports = AllSolidityEvents;
15407
15408
15409
15410/***/ }),
15411/* 137 */
15412/***/ (function(module, exports, __webpack_require__) {
15413
15414/*
15415 This file is part of web3.js.
15416
15417 web3.js is free software: you can redistribute it and/or modify
15418 it under the terms of the GNU Lesser General Public License as published by
15419 the Free Software Foundation, either version 3 of the License, or
15420 (at your option) any later version.
15421
15422 web3.js is distributed in the hope that it will be useful,
15423 but WITHOUT ANY WARRANTY; without even the implied warranty of
15424 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15425 GNU Lesser General Public License for more details.
15426
15427 You should have received a copy of the GNU Lesser General Public License
15428 along with web3.js. If not, see <http://www.gnu.org/licenses/>.
15429*/
15430/**
15431 * @file batch.js
15432 * @author Marek Kotewicz <marek@ethdev.com>
15433 * @date 2015
15434 */
15435
15436var Jsonrpc = __webpack_require__(63);
15437var errors = __webpack_require__(20);
15438
15439var Batch = function (web3) {
15440 this.requestManager = web3._requestManager;
15441 this.requests = [];
15442};
15443
15444/**
15445 * Should be called to add create new request to batch request
15446 *
15447 * @method add
15448 * @param {Object} jsonrpc requet object
15449 */
15450Batch.prototype.add = function (request) {
15451 this.requests.push(request);
15452};
15453
15454/**
15455 * Should be called to execute batch request
15456 *
15457 * @method execute
15458 */
15459Batch.prototype.execute = function () {
15460 var requests = this.requests;
15461 this.requestManager.sendBatch(requests, function (err, results) {
15462 results = results || [];
15463 requests.map(function (request, index) {
15464 return results[index] || {};
15465 }).forEach(function (result, index) {
15466 if (requests[index].callback) {
15467
15468 if (!Jsonrpc.isValidResponse(result)) {
15469 return requests[index].callback(errors.InvalidResponse(result));
15470 }
15471
15472 requests[index].callback(null, (requests[index].format ? requests[index].format(result.result) : result.result));
15473 }
15474 });
15475 });
15476};
15477
15478module.exports = Batch;
15479
15480
15481
15482/***/ }),
15483/* 138 */
15484/***/ (function(module, exports, __webpack_require__) {
15485
15486/*
15487 This file is part of web3.js.
15488
15489 web3.js is free software: you can redistribute it and/or modify
15490 it under the terms of the GNU Lesser General Public License as published by
15491 the Free Software Foundation, either version 3 of the License, or
15492 (at your option) any later version.
15493
15494 web3.js is distributed in the hope that it will be useful,
15495 but WITHOUT ANY WARRANTY; without even the implied warranty of
15496 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15497 GNU Lesser General Public License for more details.
15498
15499 You should have received a copy of the GNU Lesser General Public License
15500 along with web3.js. If not, see <http://www.gnu.org/licenses/>.
15501*/
15502/**
15503 * @file contract.js
15504 * @author Marek Kotewicz <marek@ethdev.com>
15505 * @date 2014
15506 */
15507
15508var utils = __webpack_require__(2);
15509var coder = __webpack_require__(21);
15510var SolidityEvent = __webpack_require__(62);
15511var SolidityFunction = __webpack_require__(140);
15512var AllEvents = __webpack_require__(136);
15513
15514/**
15515 * Should be called to encode constructor params
15516 *
15517 * @method encodeConstructorParams
15518 * @param {Array} abi
15519 * @param {Array} constructor params
15520 */
15521var encodeConstructorParams = function (abi, params) {
15522 return abi.filter(function (json) {
15523 return json.type === 'constructor' && json.inputs.length === params.length;
15524 }).map(function (json) {
15525 return json.inputs.map(function (input) {
15526 return input.type;
15527 });
15528 }).map(function (types) {
15529 return coder.encodeParams(types, params);
15530 })[0] || '';
15531};
15532
15533/**
15534 * Should be called to add functions to contract object
15535 *
15536 * @method addFunctionsToContract
15537 * @param {Contract} contract
15538 * @param {Array} abi
15539 */
15540var addFunctionsToContract = function (contract) {
15541 contract.abi.filter(function (json) {
15542 return json.type === 'function';
15543 }).map(function (json) {
15544 return new SolidityFunction(contract._eth, json, contract.address);
15545 }).forEach(function (f) {
15546 f.attachToContract(contract);
15547 });
15548};
15549
15550/**
15551 * Should be called to add events to contract object
15552 *
15553 * @method addEventsToContract
15554 * @param {Contract} contract
15555 * @param {Array} abi
15556 */
15557var addEventsToContract = function (contract) {
15558 var events = contract.abi.filter(function (json) {
15559 return json.type === 'event';
15560 });
15561
15562 var All = new AllEvents(contract._eth._requestManager, events, contract.address);
15563 All.attachToContract(contract);
15564
15565 events.map(function (json) {
15566 return new SolidityEvent(contract._eth._requestManager, json, contract.address);
15567 }).forEach(function (e) {
15568 e.attachToContract(contract);
15569 });
15570};
15571
15572
15573/**
15574 * Should be called to check if the contract gets properly deployed on the blockchain.
15575 *
15576 * @method checkForContractAddress
15577 * @param {Object} contract
15578 * @param {Function} callback
15579 * @returns {Undefined}
15580 */
15581var checkForContractAddress = function(contract, callback){
15582 var count = 0,
15583 callbackFired = false;
15584
15585 // wait for receipt
15586 var filter = contract._eth.filter('latest', function(e){
15587 if (!e && !callbackFired) {
15588 count++;
15589
15590 // stop watching after 50 blocks (timeout)
15591 if (count > 50) {
15592
15593 filter.stopWatching(function() {});
15594 callbackFired = true;
15595
15596 if (callback)
15597 callback(new Error('Contract transaction couldn\'t be found after 50 blocks'));
15598 else
15599 throw new Error('Contract transaction couldn\'t be found after 50 blocks');
15600
15601
15602 } else {
15603
15604 contract._eth.getTransactionReceipt(contract.transactionHash, function(e, receipt){
15605 if(receipt && !callbackFired) {
15606
15607 contract._eth.getCode(receipt.contractAddress, function(e, code){
15608 /*jshint maxcomplexity: 6 */
15609
15610 if(callbackFired || !code)
15611 return;
15612
15613 filter.stopWatching(function() {});
15614 callbackFired = true;
15615
15616 if(code.length > 3) {
15617
15618 // console.log('Contract code deployed!');
15619
15620 contract.address = receipt.contractAddress;
15621
15622 // attach events and methods again after we have
15623 addFunctionsToContract(contract);
15624 addEventsToContract(contract);
15625
15626 // call callback for the second time
15627 if(callback)
15628 callback(null, contract);
15629
15630 } else {
15631 if(callback)
15632 callback(new Error('The contract code couldn\'t be stored, please check your gas amount.'));
15633 else
15634 throw new Error('The contract code couldn\'t be stored, please check your gas amount.');
15635 }
15636 });
15637 }
15638 });
15639 }
15640 }
15641 });
15642};
15643
15644/**
15645 * Should be called to create new ContractFactory instance
15646 *
15647 * @method ContractFactory
15648 * @param {Array} abi
15649 */
15650var ContractFactory = function (eth, abi) {
15651 this.eth = eth;
15652 this.abi = abi;
15653
15654 /**
15655 * Should be called to create new contract on a blockchain
15656 *
15657 * @method new
15658 * @param {Any} contract constructor param1 (optional)
15659 * @param {Any} contract constructor param2 (optional)
15660 * @param {Object} contract transaction object (required)
15661 * @param {Function} callback
15662 * @returns {Contract} returns contract instance
15663 */
15664 this.new = function () {
15665 /*jshint maxcomplexity: 7 */
15666
15667 var contract = new Contract(this.eth, this.abi);
15668
15669 // parse arguments
15670 var options = {}; // required!
15671 var callback;
15672
15673 var args = Array.prototype.slice.call(arguments);
15674 if (utils.isFunction(args[args.length - 1])) {
15675 callback = args.pop();
15676 }
15677
15678 var last = args[args.length - 1];
15679 if (utils.isObject(last) && !utils.isArray(last)) {
15680 options = args.pop();
15681 }
15682
15683 if (options.value > 0) {
15684 var constructorAbi = abi.filter(function (json) {
15685 return json.type === 'constructor' && json.inputs.length === args.length;
15686 })[0] || {};
15687
15688 if (!constructorAbi.payable) {
15689 throw new Error('Cannot send value to non-payable constructor');
15690 }
15691 }
15692
15693 var bytes = encodeConstructorParams(this.abi, args);
15694 options.data += bytes;
15695
15696 if (callback) {
15697
15698 // wait for the contract address adn check if the code was deployed
15699 this.eth.sendTransaction(options, function (err, hash) {
15700 if (err) {
15701 callback(err);
15702 } else {
15703 // add the transaction hash
15704 contract.transactionHash = hash;
15705
15706 // call callback for the first time
15707 callback(null, contract);
15708
15709 checkForContractAddress(contract, callback);
15710 }
15711 });
15712 } else {
15713 var hash = this.eth.sendTransaction(options);
15714 // add the transaction hash
15715 contract.transactionHash = hash;
15716 checkForContractAddress(contract);
15717 }
15718
15719 return contract;
15720 };
15721
15722 this.new.getData = this.getData.bind(this);
15723};
15724
15725/**
15726 * Should be called to create new ContractFactory
15727 *
15728 * @method contract
15729 * @param {Array} abi
15730 * @returns {ContractFactory} new contract factory
15731 */
15732//var contract = function (abi) {
15733 //return new ContractFactory(abi);
15734//};
15735
15736
15737
15738/**
15739 * Should be called to get access to existing contract on a blockchain
15740 *
15741 * @method at
15742 * @param {Address} contract address (required)
15743 * @param {Function} callback {optional)
15744 * @returns {Contract} returns contract if no callback was passed,
15745 * otherwise calls callback function (err, contract)
15746 */
15747ContractFactory.prototype.at = function (address, callback) {
15748 var contract = new Contract(this.eth, this.abi, address);
15749
15750 // this functions are not part of prototype,
15751 // because we dont want to spoil the interface
15752 addFunctionsToContract(contract);
15753 addEventsToContract(contract);
15754
15755 if (callback) {
15756 callback(null, contract);
15757 }
15758 return contract;
15759};
15760
15761/**
15762 * Gets the data, which is data to deploy plus constructor params
15763 *
15764 * @method getData
15765 */
15766ContractFactory.prototype.getData = function () {
15767 var options = {}; // required!
15768 var args = Array.prototype.slice.call(arguments);
15769
15770 var last = args[args.length - 1];
15771 if (utils.isObject(last) && !utils.isArray(last)) {
15772 options = args.pop();
15773 }
15774
15775 var bytes = encodeConstructorParams(this.abi, args);
15776 options.data += bytes;
15777
15778 return options.data;
15779};
15780
15781/**
15782 * Should be called to create new contract instance
15783 *
15784 * @method Contract
15785 * @param {Array} abi
15786 * @param {Address} contract address
15787 */
15788var Contract = function (eth, abi, address) {
15789 this._eth = eth;
15790 this.transactionHash = null;
15791 this.address = address;
15792 this.abi = abi;
15793};
15794
15795module.exports = ContractFactory;
15796
15797
15798/***/ }),
15799/* 139 */
15800/***/ (function(module, exports, __webpack_require__) {
15801
15802var formatters = __webpack_require__(5);
15803var utils = __webpack_require__(2);
15804var Method = __webpack_require__(9);
15805var Property = __webpack_require__(17);
15806
15807// TODO: refactor, so the input params are not altered.
15808// it's necessary to make same 'extension' work with multiple providers
15809var extend = function (web3) {
15810 /* jshint maxcomplexity:5 */
15811 var ex = function (extension) {
15812
15813 var extendedObject;
15814 if (extension.property) {
15815 if (!web3[extension.property]) {
15816 web3[extension.property] = {};
15817 }
15818 extendedObject = web3[extension.property];
15819 } else {
15820 extendedObject = web3;
15821 }
15822
15823 if (extension.methods) {
15824 extension.methods.forEach(function (method) {
15825 method.attachToObject(extendedObject);
15826 method.setRequestManager(web3._requestManager);
15827 });
15828 }
15829
15830 if (extension.properties) {
15831 extension.properties.forEach(function (property) {
15832 property.attachToObject(extendedObject);
15833 property.setRequestManager(web3._requestManager);
15834 });
15835 }
15836 };
15837
15838 ex.formatters = formatters;
15839 ex.utils = utils;
15840 ex.Method = Method;
15841 ex.Property = Property;
15842
15843 return ex;
15844};
15845
15846
15847
15848module.exports = extend;
15849
15850
15851
15852/***/ }),
15853/* 140 */
15854/***/ (function(module, exports, __webpack_require__) {
15855
15856/*
15857 This file is part of web3.js.
15858
15859 web3.js is free software: you can redistribute it and/or modify
15860 it under the terms of the GNU Lesser General Public License as published by
15861 the Free Software Foundation, either version 3 of the License, or
15862 (at your option) any later version.
15863
15864 web3.js is distributed in the hope that it will be useful,
15865 but WITHOUT ANY WARRANTY; without even the implied warranty of
15866 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15867 GNU Lesser General Public License for more details.
15868
15869 You should have received a copy of the GNU Lesser General Public License
15870 along with web3.js. If not, see <http://www.gnu.org/licenses/>.
15871*/
15872/**
15873 * @file function.js
15874 * @author Marek Kotewicz <marek@ethdev.com>
15875 * @date 2015
15876 */
15877
15878var coder = __webpack_require__(21);
15879var utils = __webpack_require__(2);
15880var formatters = __webpack_require__(5);
15881var sha3 = __webpack_require__(19);
15882
15883/**
15884 * This prototype should be used to call/sendTransaction to solidity functions
15885 */
15886var SolidityFunction = function (eth, json, address) {
15887 this._eth = eth;
15888 this._inputTypes = json.inputs.map(function (i) {
15889 return i.type;
15890 });
15891 this._outputTypes = json.outputs.map(function (i) {
15892 return i.type;
15893 });
15894 this._constant = json.constant;
15895 this._payable = json.payable;
15896 this._name = utils.transformToFullName(json);
15897 this._address = address;
15898};
15899
15900SolidityFunction.prototype.extractCallback = function (args) {
15901 if (utils.isFunction(args[args.length - 1])) {
15902 return args.pop(); // modify the args array!
15903 }
15904};
15905
15906SolidityFunction.prototype.extractDefaultBlock = function (args) {
15907 if (args.length > this._inputTypes.length && !utils.isObject(args[args.length -1])) {
15908 return formatters.inputDefaultBlockNumberFormatter(args.pop()); // modify the args array!
15909 }
15910};
15911
15912/**
15913 * Should be used to create payload from arguments
15914 *
15915 * @method toPayload
15916 * @param {Array} solidity function params
15917 * @param {Object} optional payload options
15918 */
15919SolidityFunction.prototype.toPayload = function (args) {
15920 var options = {};
15921 if (args.length > this._inputTypes.length && utils.isObject(args[args.length -1])) {
15922 options = args[args.length - 1];
15923 }
15924 options.to = this._address;
15925 options.data = '0x' + this.signature() + coder.encodeParams(this._inputTypes, args);
15926 return options;
15927};
15928
15929/**
15930 * Should be used to get function signature
15931 *
15932 * @method signature
15933 * @return {String} function signature
15934 */
15935SolidityFunction.prototype.signature = function () {
15936 return sha3(this._name).slice(0, 8);
15937};
15938
15939
15940SolidityFunction.prototype.unpackOutput = function (output) {
15941 if (!output) {
15942 return;
15943 }
15944
15945 output = output.length >= 2 ? output.slice(2) : output;
15946 var result = coder.decodeParams(this._outputTypes, output);
15947 return result.length === 1 ? result[0] : result;
15948};
15949
15950/**
15951 * Calls a contract function.
15952 *
15953 * @method call
15954 * @param {...Object} Contract function arguments
15955 * @param {function} If the last argument is a function, the contract function
15956 * call will be asynchronous, and the callback will be passed the
15957 * error and result.
15958 * @return {String} output bytes
15959 */
15960SolidityFunction.prototype.call = function () {
15961 var args = Array.prototype.slice.call(arguments).filter(function (a) {return a !== undefined; });
15962 var callback = this.extractCallback(args);
15963 var defaultBlock = this.extractDefaultBlock(args);
15964 var payload = this.toPayload(args);
15965
15966
15967 if (!callback) {
15968 var output = this._eth.call(payload, defaultBlock);
15969 return this.unpackOutput(output);
15970 }
15971
15972 var self = this;
15973 this._eth.call(payload, defaultBlock, function (error, output) {
15974 if (error) return callback(error, null);
15975
15976 var unpacked = null;
15977 try {
15978 unpacked = self.unpackOutput(output);
15979 }
15980 catch (e) {
15981 error = e;
15982 }
15983
15984 callback(error, unpacked);
15985 });
15986};
15987
15988/**
15989 * Should be used to sendTransaction to solidity function
15990 *
15991 * @method sendTransaction
15992 */
15993SolidityFunction.prototype.sendTransaction = function () {
15994 var args = Array.prototype.slice.call(arguments).filter(function (a) {return a !== undefined; });
15995 var callback = this.extractCallback(args);
15996 var payload = this.toPayload(args);
15997
15998 if (payload.value > 0 && !this._payable) {
15999 throw new Error('Cannot send value to non-payable function');
16000 }
16001
16002 if (!callback) {
16003 return this._eth.sendTransaction(payload);
16004 }
16005
16006 this._eth.sendTransaction(payload, callback);
16007};
16008
16009/**
16010 * Should be used to estimateGas of solidity function
16011 *
16012 * @method estimateGas
16013 */
16014SolidityFunction.prototype.estimateGas = function () {
16015 var args = Array.prototype.slice.call(arguments);
16016 var callback = this.extractCallback(args);
16017 var payload = this.toPayload(args);
16018
16019 if (!callback) {
16020 return this._eth.estimateGas(payload);
16021 }
16022
16023 this._eth.estimateGas(payload, callback);
16024};
16025
16026/**
16027 * Return the encoded data of the call
16028 *
16029 * @method getData
16030 * @return {String} the encoded data
16031 */
16032SolidityFunction.prototype.getData = function () {
16033 var args = Array.prototype.slice.call(arguments);
16034 var payload = this.toPayload(args);
16035
16036 return payload.data;
16037};
16038
16039/**
16040 * Should be used to get function display name
16041 *
16042 * @method displayName
16043 * @return {String} display name of the function
16044 */
16045SolidityFunction.prototype.displayName = function () {
16046 return utils.extractDisplayName(this._name);
16047};
16048
16049/**
16050 * Should be used to get function type name
16051 *
16052 * @method typeName
16053 * @return {String} type name of the function
16054 */
16055SolidityFunction.prototype.typeName = function () {
16056 return utils.extractTypeName(this._name);
16057};
16058
16059/**
16060 * Should be called to get rpc requests from solidity function
16061 *
16062 * @method request
16063 * @returns {Object}
16064 */
16065SolidityFunction.prototype.request = function () {
16066 var args = Array.prototype.slice.call(arguments);
16067 var callback = this.extractCallback(args);
16068 var payload = this.toPayload(args);
16069 var format = this.unpackOutput.bind(this);
16070
16071 return {
16072 method: this._constant ? 'eth_call' : 'eth_sendTransaction',
16073 callback: callback,
16074 params: [payload],
16075 format: format
16076 };
16077};
16078
16079/**
16080 * Should be called to execute function
16081 *
16082 * @method execute
16083 */
16084SolidityFunction.prototype.execute = function () {
16085 var transaction = !this._constant;
16086
16087 // send transaction
16088 if (transaction) {
16089 return this.sendTransaction.apply(this, Array.prototype.slice.call(arguments));
16090 }
16091
16092 // call
16093 return this.call.apply(this, Array.prototype.slice.call(arguments));
16094};
16095
16096/**
16097 * Should be called to attach function to contract
16098 *
16099 * @method attachToContract
16100 * @param {Contract}
16101 */
16102SolidityFunction.prototype.attachToContract = function (contract) {
16103 var execute = this.execute.bind(this);
16104 execute.request = this.request.bind(this);
16105 execute.call = this.call.bind(this);
16106 execute.sendTransaction = this.sendTransaction.bind(this);
16107 execute.estimateGas = this.estimateGas.bind(this);
16108 execute.getData = this.getData.bind(this);
16109 var displayName = this.displayName();
16110 if (!contract[displayName]) {
16111 contract[displayName] = execute;
16112 }
16113 contract[displayName][this.typeName()] = execute; // circular!!!!
16114};
16115
16116module.exports = SolidityFunction;
16117
16118
16119
16120/***/ }),
16121/* 141 */
16122/***/ (function(module, exports, __webpack_require__) {
16123
16124/*
16125 This file is part of web3.js.
16126
16127 web3.js is free software: you can redistribute it and/or modify
16128 it under the terms of the GNU Lesser General Public License as published by
16129 the Free Software Foundation, either version 3 of the License, or
16130 (at your option) any later version.
16131
16132 web3.js is distributed in the hope that it will be useful,
16133 but WITHOUT ANY WARRANTY; without even the implied warranty of
16134 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16135 GNU Lesser General Public License for more details.
16136
16137 You should have received a copy of the GNU Lesser General Public License
16138 along with web3.js. If not, see <http://www.gnu.org/licenses/>.
16139*/
16140/** @file httpprovider.js
16141 * @authors:
16142 * Marek Kotewicz <marek@ethdev.com>
16143 * Marian Oancea <marian@ethdev.com>
16144 * Fabian Vogelsteller <fabian@ethdev.com>
16145 * @date 2015
16146 */
16147
16148
16149var errors = __webpack_require__(20);
16150
16151// workaround to use httpprovider in different envs
16152
16153// browser
16154if (typeof window !== 'undefined' && window.XMLHttpRequest) {
16155 XMLHttpRequest = window.XMLHttpRequest; // jshint ignore: line
16156// node
16157} else {
16158 XMLHttpRequest = __webpack_require__(134).XMLHttpRequest; // jshint ignore: line
16159}
16160
16161var XHR2 = __webpack_require__(156); // jshint ignore: line
16162
16163/**
16164 * HttpProvider should be used to send rpc calls over http
16165 */
16166var HttpProvider = function (host, timeout) {
16167 this.host = host || 'http://localhost:8545';
16168 this.timeout = timeout || 0;
16169};
16170
16171/**
16172 * Should be called to prepare new XMLHttpRequest
16173 *
16174 * @method prepareRequest
16175 * @param {Boolean} true if request should be async
16176 * @return {XMLHttpRequest} object
16177 */
16178HttpProvider.prototype.prepareRequest = function (async) {
16179 var request;
16180
16181 if (async) {
16182 request = new XHR2();
16183 request.timeout = this.timeout;
16184 }else {
16185 request = new XMLHttpRequest();
16186 }
16187
16188 request.open('POST', this.host, async);
16189 request.setRequestHeader('Content-Type','application/json');
16190 return request;
16191};
16192
16193/**
16194 * Should be called to make sync request
16195 *
16196 * @method send
16197 * @param {Object} payload
16198 * @return {Object} result
16199 */
16200HttpProvider.prototype.send = function (payload) {
16201 var request = this.prepareRequest(false);
16202
16203 try {
16204 request.send(JSON.stringify(payload));
16205 } catch(error) {
16206 throw errors.InvalidConnection(this.host);
16207 }
16208
16209 var result = request.responseText;
16210
16211 try {
16212 result = JSON.parse(result);
16213 } catch(e) {
16214 throw errors.InvalidResponse(request.responseText);
16215 }
16216
16217 return result;
16218};
16219
16220/**
16221 * Should be used to make async request
16222 *
16223 * @method sendAsync
16224 * @param {Object} payload
16225 * @param {Function} callback triggered on end with (err, result)
16226 */
16227HttpProvider.prototype.sendAsync = function (payload, callback) {
16228 var request = this.prepareRequest(true);
16229
16230 request.onreadystatechange = function() {
16231 if (request.readyState === 4 && request.timeout !== 1) {
16232 var result = request.responseText;
16233 var error = null;
16234
16235 try {
16236 result = JSON.parse(result);
16237 } catch(e) {
16238 error = errors.InvalidResponse(request.responseText);
16239 }
16240
16241 callback(error, result);
16242 }
16243 };
16244
16245 request.ontimeout = function() {
16246 callback(errors.ConnectionTimeout(this.timeout));
16247 };
16248
16249 try {
16250 request.send(JSON.stringify(payload));
16251 } catch(error) {
16252 callback(errors.InvalidConnection(this.host));
16253 }
16254};
16255
16256/**
16257 * Synchronously tries to make Http request
16258 *
16259 * @method isConnected
16260 * @return {Boolean} returns true if request haven't failed. Otherwise false
16261 */
16262HttpProvider.prototype.isConnected = function() {
16263 try {
16264 this.send({
16265 id: 9999999999,
16266 jsonrpc: '2.0',
16267 method: 'net_listening',
16268 params: []
16269 });
16270 return true;
16271 } catch(e) {
16272 return false;
16273 }
16274};
16275
16276module.exports = HttpProvider;
16277
16278
16279/***/ }),
16280/* 142 */
16281/***/ (function(module, exports, __webpack_require__) {
16282
16283"use strict";
16284/*
16285 This file is part of web3.js.
16286
16287 web3.js is free software: you can redistribute it and/or modify
16288 it under the terms of the GNU Lesser General Public License as published by
16289 the Free Software Foundation, either version 3 of the License, or
16290 (at your option) any later version.
16291
16292 web3.js is distributed in the hope that it will be useful,
16293 but WITHOUT ANY WARRANTY; without even the implied warranty of
16294 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16295 GNU Lesser General Public License for more details.
16296
16297 You should have received a copy of the GNU Lesser General Public License
16298 along with web3.js. If not, see <http://www.gnu.org/licenses/>.
16299*/
16300/** @file ipcprovider.js
16301 * @authors:
16302 * Fabian Vogelsteller <fabian@ethdev.com>
16303 * @date 2015
16304 */
16305
16306
16307
16308var utils = __webpack_require__(2);
16309var errors = __webpack_require__(20);
16310
16311
16312var IpcProvider = function (path, net) {
16313 var _this = this;
16314 this.responseCallbacks = {};
16315 this.path = path;
16316
16317 this.connection = net.connect({path: this.path});
16318
16319 this.connection.on('error', function(e){
16320 console.error('IPC Connection Error', e);
16321 _this._timeout();
16322 });
16323
16324 this.connection.on('end', function(){
16325 _this._timeout();
16326 });
16327
16328
16329 // LISTEN FOR CONNECTION RESPONSES
16330 this.connection.on('data', function(data) {
16331 /*jshint maxcomplexity: 6 */
16332
16333 _this._parseResponse(data.toString()).forEach(function(result){
16334
16335 var id = null;
16336
16337 // get the id which matches the returned id
16338 if(utils.isArray(result)) {
16339 result.forEach(function(load){
16340 if(_this.responseCallbacks[load.id])
16341 id = load.id;
16342 });
16343 } else {
16344 id = result.id;
16345 }
16346
16347 // fire the callback
16348 if(_this.responseCallbacks[id]) {
16349 _this.responseCallbacks[id](null, result);
16350 delete _this.responseCallbacks[id];
16351 }
16352 });
16353 });
16354};
16355
16356/**
16357Will parse the response and make an array out of it.
16358
16359@method _parseResponse
16360@param {String} data
16361*/
16362IpcProvider.prototype._parseResponse = function(data) {
16363 var _this = this,
16364 returnValues = [];
16365
16366 // DE-CHUNKER
16367 var dechunkedData = data
16368 .replace(/\}[\n\r]?\{/g,'}|--|{') // }{
16369 .replace(/\}\][\n\r]?\[\{/g,'}]|--|[{') // }][{
16370 .replace(/\}[\n\r]?\[\{/g,'}|--|[{') // }[{
16371 .replace(/\}\][\n\r]?\{/g,'}]|--|{') // }]{
16372 .split('|--|');
16373
16374 dechunkedData.forEach(function(data){
16375
16376 // prepend the last chunk
16377 if(_this.lastChunk)
16378 data = _this.lastChunk + data;
16379
16380 var result = null;
16381
16382 try {
16383 result = JSON.parse(data);
16384
16385 } catch(e) {
16386
16387 _this.lastChunk = data;
16388
16389 // start timeout to cancel all requests
16390 clearTimeout(_this.lastChunkTimeout);
16391 _this.lastChunkTimeout = setTimeout(function(){
16392 _this._timeout();
16393 throw errors.InvalidResponse(data);
16394 }, 1000 * 15);
16395
16396 return;
16397 }
16398
16399 // cancel timeout and set chunk to null
16400 clearTimeout(_this.lastChunkTimeout);
16401 _this.lastChunk = null;
16402
16403 if(result)
16404 returnValues.push(result);
16405 });
16406
16407 return returnValues;
16408};
16409
16410
16411/**
16412Get the adds a callback to the responseCallbacks object,
16413which will be called if a response matching the response Id will arrive.
16414
16415@method _addResponseCallback
16416*/
16417IpcProvider.prototype._addResponseCallback = function(payload, callback) {
16418 var id = payload.id || payload[0].id;
16419 var method = payload.method || payload[0].method;
16420
16421 this.responseCallbacks[id] = callback;
16422 this.responseCallbacks[id].method = method;
16423};
16424
16425/**
16426Timeout all requests when the end/error event is fired
16427
16428@method _timeout
16429*/
16430IpcProvider.prototype._timeout = function() {
16431 for(var key in this.responseCallbacks) {
16432 if(this.responseCallbacks.hasOwnProperty(key)){
16433 this.responseCallbacks[key](errors.InvalidConnection('on IPC'));
16434 delete this.responseCallbacks[key];
16435 }
16436 }
16437};
16438
16439
16440/**
16441Check if the current connection is still valid.
16442
16443@method isConnected
16444*/
16445IpcProvider.prototype.isConnected = function() {
16446 var _this = this;
16447
16448 // try reconnect, when connection is gone
16449 if(!_this.connection.writable)
16450 _this.connection.connect({path: _this.path});
16451
16452 return !!this.connection.writable;
16453};
16454
16455IpcProvider.prototype.send = function (payload) {
16456
16457 if(this.connection.writeSync) {
16458 var result;
16459
16460 // try reconnect, when connection is gone
16461 if(!this.connection.writable)
16462 this.connection.connect({path: this.path});
16463
16464 var data = this.connection.writeSync(JSON.stringify(payload));
16465
16466 try {
16467 result = JSON.parse(data);
16468 } catch(e) {
16469 throw errors.InvalidResponse(data);
16470 }
16471
16472 return result;
16473
16474 } else {
16475 throw new Error('You tried to send "'+ payload.method +'" synchronously. Synchronous requests are not supported by the IPC provider.');
16476 }
16477};
16478
16479IpcProvider.prototype.sendAsync = function (payload, callback) {
16480 // try reconnect, when connection is gone
16481 if(!this.connection.writable)
16482 this.connection.connect({path: this.path});
16483
16484
16485 this.connection.write(JSON.stringify(payload));
16486 this._addResponseCallback(payload, callback);
16487};
16488
16489module.exports = IpcProvider;
16490
16491
16492
16493/***/ }),
16494/* 143 */
16495/***/ (function(module, exports, __webpack_require__) {
16496
16497/*
16498 This file is part of web3.js.
16499
16500 web3.js is free software: you can redistribute it and/or modify
16501 it under the terms of the GNU Lesser General Public License as published by
16502 the Free Software Foundation, either version 3 of the License, or
16503 (at your option) any later version.
16504
16505 web3.js is distributed in the hope that it will be useful,
16506 but WITHOUT ANY WARRANTY; without even the implied warranty of
16507 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16508 GNU Lesser General Public License for more details.
16509
16510 You should have received a copy of the GNU Lesser General Public License
16511 along with web3.js. If not, see <http://www.gnu.org/licenses/>.
16512*/
16513/** @file db.js
16514 * @authors:
16515 * Marek Kotewicz <marek@ethdev.com>
16516 * @date 2015
16517 */
16518
16519var Method = __webpack_require__(9);
16520
16521var DB = function (web3) {
16522 this._requestManager = web3._requestManager;
16523
16524 var self = this;
16525
16526 methods().forEach(function(method) {
16527 method.attachToObject(self);
16528 method.setRequestManager(web3._requestManager);
16529 });
16530};
16531
16532var methods = function () {
16533 var putString = new Method({
16534 name: 'putString',
16535 call: 'db_putString',
16536 params: 3
16537 });
16538
16539 var getString = new Method({
16540 name: 'getString',
16541 call: 'db_getString',
16542 params: 2
16543 });
16544
16545 var putHex = new Method({
16546 name: 'putHex',
16547 call: 'db_putHex',
16548 params: 3
16549 });
16550
16551 var getHex = new Method({
16552 name: 'getHex',
16553 call: 'db_getHex',
16554 params: 2
16555 });
16556
16557 return [
16558 putString, getString, putHex, getHex
16559 ];
16560};
16561
16562module.exports = DB;
16563
16564
16565/***/ }),
16566/* 144 */
16567/***/ (function(module, exports, __webpack_require__) {
16568
16569"use strict";
16570/*
16571 This file is part of web3.js.
16572
16573 web3.js is free software: you can redistribute it and/or modify
16574 it under the terms of the GNU Lesser General Public License as published by
16575 the Free Software Foundation, either version 3 of the License, or
16576 (at your option) any later version.
16577
16578 web3.js is distributed in the hope that it will be useful,
16579 but WITHOUT ANY WARRANTY; without even the implied warranty of
16580 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16581 GNU Lesser General Public License for more details.
16582
16583 You should have received a copy of the GNU Lesser General Public License
16584 along with web3.js. If not, see <http://www.gnu.org/licenses/>.
16585*/
16586/**
16587 * @file eth.js
16588 * @author Marek Kotewicz <marek@ethdev.com>
16589 * @author Fabian Vogelsteller <fabian@ethdev.com>
16590 * @date 2015
16591 */
16592
16593
16594
16595var formatters = __webpack_require__(5);
16596var utils = __webpack_require__(2);
16597var Method = __webpack_require__(9);
16598var Property = __webpack_require__(17);
16599var c = __webpack_require__(29);
16600var Contract = __webpack_require__(138);
16601var watches = __webpack_require__(32);
16602var Filter = __webpack_require__(30);
16603var IsSyncing = __webpack_require__(152);
16604var namereg = __webpack_require__(149);
16605var Iban = __webpack_require__(31);
16606var transfer = __webpack_require__(153);
16607
16608var blockCall = function (args) {
16609 return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? "eth_getBlockByHash" : "eth_getBlockByNumber";
16610};
16611
16612var transactionFromBlockCall = function (args) {
16613 return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getTransactionByBlockHashAndIndex' : 'eth_getTransactionByBlockNumberAndIndex';
16614};
16615
16616var uncleCall = function (args) {
16617 return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleByBlockHashAndIndex' : 'eth_getUncleByBlockNumberAndIndex';
16618};
16619
16620var getBlockTransactionCountCall = function (args) {
16621 return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getBlockTransactionCountByHash' : 'eth_getBlockTransactionCountByNumber';
16622};
16623
16624var uncleCountCall = function (args) {
16625 return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleCountByBlockHash' : 'eth_getUncleCountByBlockNumber';
16626};
16627
16628function Eth(web3) {
16629 this._requestManager = web3._requestManager;
16630
16631 var self = this;
16632
16633 methods().forEach(function(method) {
16634 method.attachToObject(self);
16635 method.setRequestManager(self._requestManager);
16636 });
16637
16638 properties().forEach(function(p) {
16639 p.attachToObject(self);
16640 p.setRequestManager(self._requestManager);
16641 });
16642
16643
16644 this.iban = Iban;
16645 this.sendIBANTransaction = transfer.bind(null, this);
16646}
16647
16648Object.defineProperty(Eth.prototype, 'defaultBlock', {
16649 get: function () {
16650 return c.defaultBlock;
16651 },
16652 set: function (val) {
16653 c.defaultBlock = val;
16654 return val;
16655 }
16656});
16657
16658Object.defineProperty(Eth.prototype, 'defaultAccount', {
16659 get: function () {
16660 return c.defaultAccount;
16661 },
16662 set: function (val) {
16663 c.defaultAccount = val;
16664 return val;
16665 }
16666});
16667
16668var methods = function () {
16669 var getBalance = new Method({
16670 name: 'getBalance',
16671 call: 'eth_getBalance',
16672 params: 2,
16673 inputFormatter: [formatters.inputAddressFormatter, formatters.inputDefaultBlockNumberFormatter],
16674 outputFormatter: formatters.outputBigNumberFormatter
16675 });
16676
16677 var getStorageAt = new Method({
16678 name: 'getStorageAt',
16679 call: 'eth_getStorageAt',
16680 params: 3,
16681 inputFormatter: [null, utils.toHex, formatters.inputDefaultBlockNumberFormatter]
16682 });
16683
16684 var getCode = new Method({
16685 name: 'getCode',
16686 call: 'eth_getCode',
16687 params: 2,
16688 inputFormatter: [formatters.inputAddressFormatter, formatters.inputDefaultBlockNumberFormatter]
16689 });
16690
16691 var getBlock = new Method({
16692 name: 'getBlock',
16693 call: blockCall,
16694 params: 2,
16695 inputFormatter: [formatters.inputBlockNumberFormatter, function (val) { return !!val; }],
16696 outputFormatter: formatters.outputBlockFormatter
16697 });
16698
16699 var getUncle = new Method({
16700 name: 'getUncle',
16701 call: uncleCall,
16702 params: 2,
16703 inputFormatter: [formatters.inputBlockNumberFormatter, utils.toHex],
16704 outputFormatter: formatters.outputBlockFormatter,
16705
16706 });
16707
16708 var getCompilers = new Method({
16709 name: 'getCompilers',
16710 call: 'eth_getCompilers',
16711 params: 0
16712 });
16713
16714 var getBlockTransactionCount = new Method({
16715 name: 'getBlockTransactionCount',
16716 call: getBlockTransactionCountCall,
16717 params: 1,
16718 inputFormatter: [formatters.inputBlockNumberFormatter],
16719 outputFormatter: utils.toDecimal
16720 });
16721
16722 var getBlockUncleCount = new Method({
16723 name: 'getBlockUncleCount',
16724 call: uncleCountCall,
16725 params: 1,
16726 inputFormatter: [formatters.inputBlockNumberFormatter],
16727 outputFormatter: utils.toDecimal
16728 });
16729
16730 var getTransaction = new Method({
16731 name: 'getTransaction',
16732 call: 'eth_getTransactionByHash',
16733 params: 1,
16734 outputFormatter: formatters.outputTransactionFormatter
16735 });
16736
16737 var getTransactionFromBlock = new Method({
16738 name: 'getTransactionFromBlock',
16739 call: transactionFromBlockCall,
16740 params: 2,
16741 inputFormatter: [formatters.inputBlockNumberFormatter, utils.toHex],
16742 outputFormatter: formatters.outputTransactionFormatter
16743 });
16744
16745 var getTransactionReceipt = new Method({
16746 name: 'getTransactionReceipt',
16747 call: 'eth_getTransactionReceipt',
16748 params: 1,
16749 outputFormatter: formatters.outputTransactionReceiptFormatter
16750 });
16751
16752 var getTransactionCount = new Method({
16753 name: 'getTransactionCount',
16754 call: 'eth_getTransactionCount',
16755 params: 2,
16756 inputFormatter: [null, formatters.inputDefaultBlockNumberFormatter],
16757 outputFormatter: utils.toDecimal
16758 });
16759
16760 var sendRawTransaction = new Method({
16761 name: 'sendRawTransaction',
16762 call: 'eth_sendRawTransaction',
16763 params: 1,
16764 inputFormatter: [null]
16765 });
16766
16767 var sendTransaction = new Method({
16768 name: 'sendTransaction',
16769 call: 'eth_sendTransaction',
16770 params: 1,
16771 inputFormatter: [formatters.inputTransactionFormatter]
16772 });
16773
16774 var sign = new Method({
16775 name: 'sign',
16776 call: 'eth_sign',
16777 params: 2,
16778 inputFormatter: [formatters.inputAddressFormatter, null]
16779 });
16780
16781 var call = new Method({
16782 name: 'call',
16783 call: 'eth_call',
16784 params: 2,
16785 inputFormatter: [formatters.inputCallFormatter, formatters.inputDefaultBlockNumberFormatter]
16786 });
16787
16788 var estimateGas = new Method({
16789 name: 'estimateGas',
16790 call: 'eth_estimateGas',
16791 params: 1,
16792 inputFormatter: [formatters.inputCallFormatter],
16793 outputFormatter: utils.toDecimal
16794 });
16795
16796 var compileSolidity = new Method({
16797 name: 'compile.solidity',
16798 call: 'eth_compileSolidity',
16799 params: 1
16800 });
16801
16802 var compileLLL = new Method({
16803 name: 'compile.lll',
16804 call: 'eth_compileLLL',
16805 params: 1
16806 });
16807
16808 var compileSerpent = new Method({
16809 name: 'compile.serpent',
16810 call: 'eth_compileSerpent',
16811 params: 1
16812 });
16813
16814 var submitWork = new Method({
16815 name: 'submitWork',
16816 call: 'eth_submitWork',
16817 params: 3
16818 });
16819
16820 var getWork = new Method({
16821 name: 'getWork',
16822 call: 'eth_getWork',
16823 params: 0
16824 });
16825
16826 return [
16827 getBalance,
16828 getStorageAt,
16829 getCode,
16830 getBlock,
16831 getUncle,
16832 getCompilers,
16833 getBlockTransactionCount,
16834 getBlockUncleCount,
16835 getTransaction,
16836 getTransactionFromBlock,
16837 getTransactionReceipt,
16838 getTransactionCount,
16839 call,
16840 estimateGas,
16841 sendRawTransaction,
16842 sendTransaction,
16843 sign,
16844 compileSolidity,
16845 compileLLL,
16846 compileSerpent,
16847 submitWork,
16848 getWork
16849 ];
16850};
16851
16852
16853var properties = function () {
16854 return [
16855 new Property({
16856 name: 'coinbase',
16857 getter: 'eth_coinbase'
16858 }),
16859 new Property({
16860 name: 'mining',
16861 getter: 'eth_mining'
16862 }),
16863 new Property({
16864 name: 'hashrate',
16865 getter: 'eth_hashrate',
16866 outputFormatter: utils.toDecimal
16867 }),
16868 new Property({
16869 name: 'syncing',
16870 getter: 'eth_syncing',
16871 outputFormatter: formatters.outputSyncingFormatter
16872 }),
16873 new Property({
16874 name: 'gasPrice',
16875 getter: 'eth_gasPrice',
16876 outputFormatter: formatters.outputBigNumberFormatter
16877 }),
16878 new Property({
16879 name: 'accounts',
16880 getter: 'eth_accounts'
16881 }),
16882 new Property({
16883 name: 'blockNumber',
16884 getter: 'eth_blockNumber',
16885 outputFormatter: utils.toDecimal
16886 }),
16887 new Property({
16888 name: 'protocolVersion',
16889 getter: 'eth_protocolVersion'
16890 })
16891 ];
16892};
16893
16894Eth.prototype.contract = function (abi) {
16895 var factory = new Contract(this, abi);
16896 return factory;
16897};
16898
16899Eth.prototype.filter = function (fil, callback) {
16900 return new Filter(this._requestManager, fil, watches.eth(), formatters.outputLogFormatter, callback);
16901};
16902
16903Eth.prototype.namereg = function () {
16904 return this.contract(namereg.global.abi).at(namereg.global.address);
16905};
16906
16907Eth.prototype.icapNamereg = function () {
16908 return this.contract(namereg.icap.abi).at(namereg.icap.address);
16909};
16910
16911Eth.prototype.isSyncing = function (callback) {
16912 return new IsSyncing(this._requestManager, callback);
16913};
16914
16915module.exports = Eth;
16916
16917
16918
16919/***/ }),
16920/* 145 */
16921/***/ (function(module, exports, __webpack_require__) {
16922
16923/*
16924 This file is part of web3.js.
16925
16926 web3.js is free software: you can redistribute it and/or modify
16927 it under the terms of the GNU Lesser General Public License as published by
16928 the Free Software Foundation, either version 3 of the License, or
16929 (at your option) any later version.
16930
16931 web3.js is distributed in the hope that it will be useful,
16932 but WITHOUT ANY WARRANTY; without even the implied warranty of
16933 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16934 GNU Lesser General Public License for more details.
16935
16936 You should have received a copy of the GNU Lesser General Public License
16937 along with web3.js. If not, see <http://www.gnu.org/licenses/>.
16938*/
16939/** @file eth.js
16940 * @authors:
16941 * Marek Kotewicz <marek@ethdev.com>
16942 * @date 2015
16943 */
16944
16945var utils = __webpack_require__(2);
16946var Property = __webpack_require__(17);
16947
16948var Net = function (web3) {
16949 this._requestManager = web3._requestManager;
16950
16951 var self = this;
16952
16953 properties().forEach(function(p) {
16954 p.attachToObject(self);
16955 p.setRequestManager(web3._requestManager);
16956 });
16957};
16958
16959/// @returns an array of objects describing web3.eth api properties
16960var properties = function () {
16961 return [
16962 new Property({
16963 name: 'listening',
16964 getter: 'net_listening'
16965 }),
16966 new Property({
16967 name: 'peerCount',
16968 getter: 'net_peerCount',
16969 outputFormatter: utils.toDecimal
16970 })
16971 ];
16972};
16973
16974module.exports = Net;
16975
16976
16977/***/ }),
16978/* 146 */
16979/***/ (function(module, exports, __webpack_require__) {
16980
16981"use strict";
16982/*
16983 This file is part of web3.js.
16984
16985 web3.js is free software: you can redistribute it and/or modify
16986 it under the terms of the GNU Lesser General Public License as published by
16987 the Free Software Foundation, either version 3 of the License, or
16988 (at your option) any later version.
16989
16990 web3.js is distributed in the hope that it will be useful,
16991 but WITHOUT ANY WARRANTY; without even the implied warranty of
16992 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16993 GNU Lesser General Public License for more details.
16994
16995 You should have received a copy of the GNU Lesser General Public License
16996 along with web3.js. If not, see <http://www.gnu.org/licenses/>.
16997*/
16998/**
16999 * @file eth.js
17000 * @author Marek Kotewicz <marek@ethdev.com>
17001 * @author Fabian Vogelsteller <fabian@ethdev.com>
17002 * @date 2015
17003 */
17004
17005
17006
17007var Method = __webpack_require__(9);
17008var Property = __webpack_require__(17);
17009var formatters = __webpack_require__(5);
17010
17011function Personal(web3) {
17012 this._requestManager = web3._requestManager;
17013
17014 var self = this;
17015
17016 methods().forEach(function(method) {
17017 method.attachToObject(self);
17018 method.setRequestManager(self._requestManager);
17019 });
17020
17021 properties().forEach(function(p) {
17022 p.attachToObject(self);
17023 p.setRequestManager(self._requestManager);
17024 });
17025}
17026
17027var methods = function () {
17028 var newAccount = new Method({
17029 name: 'newAccount',
17030 call: 'personal_newAccount',
17031 params: 1,
17032 inputFormatter: [null]
17033 });
17034
17035 var unlockAccount = new Method({
17036 name: 'unlockAccount',
17037 call: 'personal_unlockAccount',
17038 params: 3,
17039 inputFormatter: [formatters.inputAddressFormatter, null, null]
17040 });
17041
17042 var sendTransaction = new Method({
17043 name: 'sendTransaction',
17044 call: 'personal_sendTransaction',
17045 params: 2,
17046 inputFormatter: [formatters.inputTransactionFormatter, null]
17047 });
17048
17049 var lockAccount = new Method({
17050 name: 'lockAccount',
17051 call: 'personal_lockAccount',
17052 params: 1,
17053 inputFormatter: [formatters.inputAddressFormatter]
17054 });
17055
17056 return [
17057 newAccount,
17058 unlockAccount,
17059 sendTransaction,
17060 lockAccount
17061 ];
17062};
17063
17064var properties = function () {
17065 return [
17066 new Property({
17067 name: 'listAccounts',
17068 getter: 'personal_listAccounts'
17069 })
17070 ];
17071};
17072
17073
17074module.exports = Personal;
17075
17076
17077/***/ }),
17078/* 147 */
17079/***/ (function(module, exports, __webpack_require__) {
17080
17081/*
17082 This file is part of web3.js.
17083
17084 web3.js is free software: you can redistribute it and/or modify
17085 it under the terms of the GNU Lesser General Public License as published by
17086 the Free Software Foundation, either version 3 of the License, or
17087 (at your option) any later version.
17088
17089 web3.js is distributed in the hope that it will be useful,
17090 but WITHOUT ANY WARRANTY; without even the implied warranty of
17091 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17092 GNU Lesser General Public License for more details.
17093
17094 You should have received a copy of the GNU Lesser General Public License
17095 along with web3.js. If not, see <http://www.gnu.org/licenses/>.
17096*/
17097/** @file shh.js
17098 * @authors:
17099 * Marek Kotewicz <marek@ethdev.com>
17100 * @date 2015
17101 */
17102
17103var Method = __webpack_require__(9);
17104var formatters = __webpack_require__(5);
17105var Filter = __webpack_require__(30);
17106var watches = __webpack_require__(32);
17107
17108var Shh = function (web3) {
17109 this._requestManager = web3._requestManager;
17110
17111 var self = this;
17112
17113 methods().forEach(function(method) {
17114 method.attachToObject(self);
17115 method.setRequestManager(self._requestManager);
17116 });
17117};
17118
17119Shh.prototype.filter = function (fil, callback) {
17120 return new Filter(this._requestManager, fil, watches.shh(), formatters.outputPostFormatter, callback);
17121};
17122
17123var methods = function () {
17124
17125 var post = new Method({
17126 name: 'post',
17127 call: 'shh_post',
17128 params: 1,
17129 inputFormatter: [formatters.inputPostFormatter]
17130 });
17131
17132 var newIdentity = new Method({
17133 name: 'newIdentity',
17134 call: 'shh_newIdentity',
17135 params: 0
17136 });
17137
17138 var hasIdentity = new Method({
17139 name: 'hasIdentity',
17140 call: 'shh_hasIdentity',
17141 params: 1
17142 });
17143
17144 var newGroup = new Method({
17145 name: 'newGroup',
17146 call: 'shh_newGroup',
17147 params: 0
17148 });
17149
17150 var addToGroup = new Method({
17151 name: 'addToGroup',
17152 call: 'shh_addToGroup',
17153 params: 0
17154 });
17155
17156 return [
17157 post,
17158 newIdentity,
17159 hasIdentity,
17160 newGroup,
17161 addToGroup
17162 ];
17163};
17164
17165module.exports = Shh;
17166
17167
17168
17169/***/ }),
17170/* 148 */
17171/***/ (function(module, exports, __webpack_require__) {
17172
17173"use strict";
17174/*
17175 This file is part of web3.js.
17176
17177 web3.js is free software: you can redistribute it and/or modify
17178 it under the terms of the GNU Lesser General Public License as published by
17179 the Free Software Foundation, either version 3 of the License, or
17180 (at your option) any later version.
17181
17182 web3.js is distributed in the hope that it will be useful,
17183 but WITHOUT ANY WARRANTY; without even the implied warranty of
17184 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17185 GNU Lesser General Public License for more details.
17186
17187 You should have received a copy of the GNU Lesser General Public License
17188 along with web3.js. If not, see <http://www.gnu.org/licenses/>.
17189*/
17190/**
17191 * @file bzz.js
17192 * @author Alex Beregszaszi <alex@rtfs.hu>
17193 * @date 2016
17194 *
17195 * Reference: https://github.com/ethereum/go-ethereum/blob/swarm/internal/web3ext/web3ext.go#L33
17196 */
17197
17198
17199
17200var Method = __webpack_require__(9);
17201var Property = __webpack_require__(17);
17202
17203function Swarm(web3) {
17204 this._requestManager = web3._requestManager;
17205
17206 var self = this;
17207
17208 methods().forEach(function(method) {
17209 method.attachToObject(self);
17210 method.setRequestManager(self._requestManager);
17211 });
17212
17213 properties().forEach(function(p) {
17214 p.attachToObject(self);
17215 p.setRequestManager(self._requestManager);
17216 });
17217}
17218
17219var methods = function () {
17220 var blockNetworkRead = new Method({
17221 name: 'blockNetworkRead',
17222 call: 'bzz_blockNetworkRead',
17223 params: 1,
17224 inputFormatter: [null]
17225 });
17226
17227 var syncEnabled = new Method({
17228 name: 'syncEnabled',
17229 call: 'bzz_syncEnabled',
17230 params: 1,
17231 inputFormatter: [null]
17232 });
17233
17234 var swapEnabled = new Method({
17235 name: 'swapEnabled',
17236 call: 'bzz_swapEnabled',
17237 params: 1,
17238 inputFormatter: [null]
17239 });
17240
17241 var download = new Method({
17242 name: 'download',
17243 call: 'bzz_download',
17244 params: 2,
17245 inputFormatter: [null, null]
17246 });
17247
17248 var upload = new Method({
17249 name: 'upload',
17250 call: 'bzz_upload',
17251 params: 2,
17252 inputFormatter: [null, null]
17253 });
17254
17255 var retrieve = new Method({
17256 name: 'retrieve',
17257 call: 'bzz_retrieve',
17258 params: 1,
17259 inputFormatter: [null]
17260 });
17261
17262 var store = new Method({
17263 name: 'store',
17264 call: 'bzz_store',
17265 params: 2,
17266 inputFormatter: [null, null]
17267 });
17268
17269 var get = new Method({
17270 name: 'get',
17271 call: 'bzz_get',
17272 params: 1,
17273 inputFormatter: [null]
17274 });
17275
17276 var put = new Method({
17277 name: 'put',
17278 call: 'bzz_put',
17279 params: 2,
17280 inputFormatter: [null, null]
17281 });
17282
17283 var modify = new Method({
17284 name: 'modify',
17285 call: 'bzz_modify',
17286 params: 4,
17287 inputFormatter: [null, null, null, null]
17288 });
17289
17290 return [
17291 blockNetworkRead,
17292 syncEnabled,
17293 swapEnabled,
17294 download,
17295 upload,
17296 retrieve,
17297 store,
17298 get,
17299 put,
17300 modify
17301 ];
17302};
17303
17304var properties = function () {
17305 return [
17306 new Property({
17307 name: 'hive',
17308 getter: 'bzz_hive'
17309 }),
17310 new Property({
17311 name: 'info',
17312 getter: 'bzz_info'
17313 })
17314 ];
17315};
17316
17317
17318module.exports = Swarm;
17319
17320
17321/***/ }),
17322/* 149 */
17323/***/ (function(module, exports, __webpack_require__) {
17324
17325/*
17326 This file is part of web3.js.
17327
17328 web3.js is free software: you can redistribute it and/or modify
17329 it under the terms of the GNU Lesser General Public License as published by
17330 the Free Software Foundation, either version 3 of the License, or
17331 (at your option) any later version.
17332
17333 web3.js is distributed in the hope that it will be useful,
17334 but WITHOUT ANY WARRANTY; without even the implied warranty of
17335 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17336 GNU Lesser General Public License for more details.
17337
17338 You should have received a copy of the GNU Lesser General Public License
17339 along with web3.js. If not, see <http://www.gnu.org/licenses/>.
17340*/
17341/**
17342 * @file namereg.js
17343 * @author Marek Kotewicz <marek@ethdev.com>
17344 * @date 2015
17345 */
17346
17347var globalRegistrarAbi = __webpack_require__(120);
17348var icapRegistrarAbi= __webpack_require__(121);
17349
17350var globalNameregAddress = '0xc6d9d2cd449a754c494264e1809c50e34d64562b';
17351var icapNameregAddress = '0xa1a111bc074c9cfa781f0c38e63bd51c91b8af00';
17352
17353module.exports = {
17354 global: {
17355 abi: globalRegistrarAbi,
17356 address: globalNameregAddress
17357 },
17358 icap: {
17359 abi: icapRegistrarAbi,
17360 address: icapNameregAddress
17361 }
17362};
17363
17364
17365
17366/***/ }),
17367/* 150 */
17368/***/ (function(module, exports, __webpack_require__) {
17369
17370/*
17371 This file is part of web3.js.
17372
17373 web3.js is free software: you can redistribute it and/or modify
17374 it under the terms of the GNU Lesser General Public License as published by
17375 the Free Software Foundation, either version 3 of the License, or
17376 (at your option) any later version.
17377
17378 web3.js is distributed in the hope that it will be useful,
17379 but WITHOUT ANY WARRANTY; without even the implied warranty of
17380 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17381 GNU Lesser General Public License for more details.
17382
17383 You should have received a copy of the GNU Lesser General Public License
17384 along with web3.js. If not, see <http://www.gnu.org/licenses/>.
17385*/
17386/**
17387 * @file requestmanager.js
17388 * @author Jeffrey Wilcke <jeff@ethdev.com>
17389 * @author Marek Kotewicz <marek@ethdev.com>
17390 * @author Marian Oancea <marian@ethdev.com>
17391 * @author Fabian Vogelsteller <fabian@ethdev.com>
17392 * @author Gav Wood <g@ethdev.com>
17393 * @date 2014
17394 */
17395
17396var Jsonrpc = __webpack_require__(63);
17397var utils = __webpack_require__(2);
17398var c = __webpack_require__(29);
17399var errors = __webpack_require__(20);
17400
17401/**
17402 * It's responsible for passing messages to providers
17403 * It's also responsible for polling the ethereum node for incoming messages
17404 * Default poll timeout is 1 second
17405 * Singleton
17406 */
17407var RequestManager = function (provider) {
17408 this.provider = provider;
17409 this.polls = {};
17410 this.timeout = null;
17411};
17412
17413/**
17414 * Should be used to synchronously send request
17415 *
17416 * @method send
17417 * @param {Object} data
17418 * @return {Object}
17419 */
17420RequestManager.prototype.send = function (data) {
17421 if (!this.provider) {
17422 console.error(errors.InvalidProvider());
17423 return null;
17424 }
17425
17426 var payload = Jsonrpc.toPayload(data.method, data.params);
17427 var result = this.provider.send(payload);
17428
17429 if (!Jsonrpc.isValidResponse(result)) {
17430 throw errors.InvalidResponse(result);
17431 }
17432
17433 return result.result;
17434};
17435
17436/**
17437 * Should be used to asynchronously send request
17438 *
17439 * @method sendAsync
17440 * @param {Object} data
17441 * @param {Function} callback
17442 */
17443RequestManager.prototype.sendAsync = function (data, callback) {
17444 if (!this.provider) {
17445 return callback(errors.InvalidProvider());
17446 }
17447
17448 var payload = Jsonrpc.toPayload(data.method, data.params);
17449 this.provider.sendAsync(payload, function (err, result) {
17450 if (err) {
17451 return callback(err);
17452 }
17453
17454 if (!Jsonrpc.isValidResponse(result)) {
17455 return callback(errors.InvalidResponse(result));
17456 }
17457
17458 callback(null, result.result);
17459 });
17460};
17461
17462/**
17463 * Should be called to asynchronously send batch request
17464 *
17465 * @method sendBatch
17466 * @param {Array} batch data
17467 * @param {Function} callback
17468 */
17469RequestManager.prototype.sendBatch = function (data, callback) {
17470 if (!this.provider) {
17471 return callback(errors.InvalidProvider());
17472 }
17473
17474 var payload = Jsonrpc.toBatchPayload(data);
17475
17476 this.provider.sendAsync(payload, function (err, results) {
17477 if (err) {
17478 return callback(err);
17479 }
17480
17481 if (!utils.isArray(results)) {
17482 return callback(errors.InvalidResponse(results));
17483 }
17484
17485 callback(err, results);
17486 });
17487};
17488
17489/**
17490 * Should be used to set provider of request manager
17491 *
17492 * @method setProvider
17493 * @param {Object}
17494 */
17495RequestManager.prototype.setProvider = function (p) {
17496 this.provider = p;
17497};
17498
17499/**
17500 * Should be used to start polling
17501 *
17502 * @method startPolling
17503 * @param {Object} data
17504 * @param {Number} pollId
17505 * @param {Function} callback
17506 * @param {Function} uninstall
17507 *
17508 * @todo cleanup number of params
17509 */
17510RequestManager.prototype.startPolling = function (data, pollId, callback, uninstall) {
17511 this.polls[pollId] = {data: data, id: pollId, callback: callback, uninstall: uninstall};
17512
17513
17514 // start polling
17515 if (!this.timeout) {
17516 this.poll();
17517 }
17518};
17519
17520/**
17521 * Should be used to stop polling for filter with given id
17522 *
17523 * @method stopPolling
17524 * @param {Number} pollId
17525 */
17526RequestManager.prototype.stopPolling = function (pollId) {
17527 delete this.polls[pollId];
17528
17529 // stop polling
17530 if(Object.keys(this.polls).length === 0 && this.timeout) {
17531 clearTimeout(this.timeout);
17532 this.timeout = null;
17533 }
17534};
17535
17536/**
17537 * Should be called to reset the polling mechanism of the request manager
17538 *
17539 * @method reset
17540 */
17541RequestManager.prototype.reset = function (keepIsSyncing) {
17542 /*jshint maxcomplexity:5 */
17543
17544 for (var key in this.polls) {
17545 // remove all polls, except sync polls,
17546 // they need to be removed manually by calling syncing.stopWatching()
17547 if(!keepIsSyncing || key.indexOf('syncPoll_') === -1) {
17548 this.polls[key].uninstall();
17549 delete this.polls[key];
17550 }
17551 }
17552
17553 // stop polling
17554 if(Object.keys(this.polls).length === 0 && this.timeout) {
17555 clearTimeout(this.timeout);
17556 this.timeout = null;
17557 }
17558};
17559
17560/**
17561 * Should be called to poll for changes on filter with given id
17562 *
17563 * @method poll
17564 */
17565RequestManager.prototype.poll = function () {
17566 /*jshint maxcomplexity: 6 */
17567 this.timeout = setTimeout(this.poll.bind(this), c.ETH_POLLING_TIMEOUT);
17568
17569 if (Object.keys(this.polls).length === 0) {
17570 return;
17571 }
17572
17573 if (!this.provider) {
17574 console.error(errors.InvalidProvider());
17575 return;
17576 }
17577
17578 var pollsData = [];
17579 var pollsIds = [];
17580 for (var key in this.polls) {
17581 pollsData.push(this.polls[key].data);
17582 pollsIds.push(key);
17583 }
17584
17585 if (pollsData.length === 0) {
17586 return;
17587 }
17588
17589 var payload = Jsonrpc.toBatchPayload(pollsData);
17590
17591 // map the request id to they poll id
17592 var pollsIdMap = {};
17593 payload.forEach(function(load, index){
17594 pollsIdMap[load.id] = pollsIds[index];
17595 });
17596
17597
17598 var self = this;
17599 this.provider.sendAsync(payload, function (error, results) {
17600
17601
17602 // TODO: console log?
17603 if (error) {
17604 return;
17605 }
17606
17607 if (!utils.isArray(results)) {
17608 throw errors.InvalidResponse(results);
17609 }
17610 results.map(function (result) {
17611 var id = pollsIdMap[result.id];
17612
17613 // make sure the filter is still installed after arrival of the request
17614 if (self.polls[id]) {
17615 result.callback = self.polls[id].callback;
17616 return result;
17617 } else
17618 return false;
17619 }).filter(function (result) {
17620 return !!result;
17621 }).filter(function (result) {
17622 var valid = Jsonrpc.isValidResponse(result);
17623 if (!valid) {
17624 result.callback(errors.InvalidResponse(result));
17625 }
17626 return valid;
17627 }).forEach(function (result) {
17628 result.callback(null, result.result);
17629 });
17630 });
17631};
17632
17633module.exports = RequestManager;
17634
17635
17636
17637/***/ }),
17638/* 151 */
17639/***/ (function(module, exports) {
17640
17641
17642
17643var Settings = function () {
17644 this.defaultBlock = 'latest';
17645 this.defaultAccount = undefined;
17646};
17647
17648module.exports = Settings;
17649
17650
17651
17652/***/ }),
17653/* 152 */
17654/***/ (function(module, exports, __webpack_require__) {
17655
17656/*
17657 This file is part of web3.js.
17658
17659 web3.js is free software: you can redistribute it and/or modify
17660 it under the terms of the GNU Lesser General Public License as published by
17661 the Free Software Foundation, either version 3 of the License, or
17662 (at your option) any later version.
17663
17664 web3.js is distributed in the hope that it will be useful,
17665 but WITHOUT ANY WARRANTY; without even the implied warranty of
17666 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17667 GNU Lesser General Public License for more details.
17668
17669 You should have received a copy of the GNU Lesser General Public License
17670 along with web3.js. If not, see <http://www.gnu.org/licenses/>.
17671*/
17672/** @file syncing.js
17673 * @authors:
17674 * Fabian Vogelsteller <fabian@ethdev.com>
17675 * @date 2015
17676 */
17677
17678var formatters = __webpack_require__(5);
17679var utils = __webpack_require__(2);
17680
17681var count = 1;
17682
17683/**
17684Adds the callback and sets up the methods, to iterate over the results.
17685
17686@method pollSyncing
17687@param {Object} self
17688*/
17689var pollSyncing = function(self) {
17690
17691 var onMessage = function (error, sync) {
17692 if (error) {
17693 return self.callbacks.forEach(function (callback) {
17694 callback(error);
17695 });
17696 }
17697
17698 if(utils.isObject(sync) && sync.startingBlock)
17699 sync = formatters.outputSyncingFormatter(sync);
17700
17701 self.callbacks.forEach(function (callback) {
17702 if (self.lastSyncState !== sync) {
17703
17704 // call the callback with true first so the app can stop anything, before receiving the sync data
17705 if(!self.lastSyncState && utils.isObject(sync))
17706 callback(null, true);
17707
17708 // call on the next CPU cycle, so the actions of the sync stop can be processes first
17709 setTimeout(function() {
17710 callback(null, sync);
17711 }, 0);
17712
17713 self.lastSyncState = sync;
17714 }
17715 });
17716 };
17717
17718 self.requestManager.startPolling({
17719 method: 'eth_syncing',
17720 params: [],
17721 }, self.pollId, onMessage, self.stopWatching.bind(self));
17722
17723};
17724
17725var IsSyncing = function (requestManager, callback) {
17726 this.requestManager = requestManager;
17727 this.pollId = 'syncPoll_'+ count++;
17728 this.callbacks = [];
17729 this.addCallback(callback);
17730 this.lastSyncState = false;
17731 pollSyncing(this);
17732
17733 return this;
17734};
17735
17736IsSyncing.prototype.addCallback = function (callback) {
17737 if(callback)
17738 this.callbacks.push(callback);
17739 return this;
17740};
17741
17742IsSyncing.prototype.stopWatching = function () {
17743 this.requestManager.stopPolling(this.pollId);
17744 this.callbacks = [];
17745};
17746
17747module.exports = IsSyncing;
17748
17749
17750
17751/***/ }),
17752/* 153 */
17753/***/ (function(module, exports, __webpack_require__) {
17754
17755/*
17756 This file is part of web3.js.
17757
17758 web3.js is free software: you can redistribute it and/or modify
17759 it under the terms of the GNU Lesser General Public License as published by
17760 the Free Software Foundation, either version 3 of the License, or
17761 (at your option) any later version.
17762
17763 web3.js is distributed in the hope that it will be useful,
17764 but WITHOUT ANY WARRANTY; without even the implied warranty of
17765 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17766 GNU Lesser General Public License for more details.
17767
17768 You should have received a copy of the GNU Lesser General Public License
17769 along with web3.js. If not, see <http://www.gnu.org/licenses/>.
17770*/
17771/**
17772 * @file transfer.js
17773 * @author Marek Kotewicz <marek@ethdev.com>
17774 * @date 2015
17775 */
17776
17777var Iban = __webpack_require__(31);
17778var exchangeAbi = __webpack_require__(122);
17779
17780/**
17781 * Should be used to make Iban transfer
17782 *
17783 * @method transfer
17784 * @param {String} from
17785 * @param {String} to iban
17786 * @param {Value} value to be tranfered
17787 * @param {Function} callback, callback
17788 */
17789var transfer = function (eth, from, to, value, callback) {
17790 var iban = new Iban(to);
17791 if (!iban.isValid()) {
17792 throw new Error('invalid iban address');
17793 }
17794
17795 if (iban.isDirect()) {
17796 return transferToAddress(eth, from, iban.address(), value, callback);
17797 }
17798
17799 if (!callback) {
17800 var address = eth.icapNamereg().addr(iban.institution());
17801 return deposit(eth, from, address, value, iban.client());
17802 }
17803
17804 eth.icapNamereg().addr(iban.institution(), function (err, address) {
17805 return deposit(eth, from, address, value, iban.client(), callback);
17806 });
17807
17808};
17809
17810/**
17811 * Should be used to transfer funds to certain address
17812 *
17813 * @method transferToAddress
17814 * @param {String} from
17815 * @param {String} to
17816 * @param {Value} value to be tranfered
17817 * @param {Function} callback, callback
17818 */
17819var transferToAddress = function (eth, from, to, value, callback) {
17820 return eth.sendTransaction({
17821 address: to,
17822 from: from,
17823 value: value
17824 }, callback);
17825};
17826
17827/**
17828 * Should be used to deposit funds to generic Exchange contract (must implement deposit(bytes32) method!)
17829 *
17830 * @method deposit
17831 * @param {String} from
17832 * @param {String} to
17833 * @param {Value} value to be transfered
17834 * @param {String} client unique identifier
17835 * @param {Function} callback, callback
17836 */
17837var deposit = function (eth, from, to, value, client, callback) {
17838 var abi = exchangeAbi;
17839 return eth.contract(abi).at(to).deposit(client, {
17840 from: from,
17841 value: value
17842 }, callback);
17843};
17844
17845module.exports = transfer;
17846
17847
17848
17849/***/ }),
17850/* 154 */
17851/***/ (function(module, exports) {
17852
17853var g;
17854
17855// This works in non-strict mode
17856g = (function() {
17857 return this;
17858})();
17859
17860try {
17861 // This works if eval is allowed (see CSP)
17862 g = g || Function("return this")() || (1,eval)("this");
17863} catch(e) {
17864 // This works if the window reference is available
17865 if(typeof window === "object")
17866 g = window;
17867}
17868
17869// g can still be undefined, but nothing to do about it...
17870// We return undefined, instead of nothing here, so it's
17871// easier to handle this case. if(!global) { ...}
17872
17873module.exports = g;
17874
17875
17876/***/ }),
17877/* 155 */
17878/***/ (function(module, exports) {
17879
17880module.exports = function(module) {
17881 if(!module.webpackPolyfill) {
17882 module.deprecate = function() {};
17883 module.paths = [];
17884 // module.parent = undefined by default
17885 if(!module.children) module.children = [];
17886 Object.defineProperty(module, "loaded", {
17887 enumerable: true,
17888 get: function() {
17889 return module.l;
17890 }
17891 });
17892 Object.defineProperty(module, "id", {
17893 enumerable: true,
17894 get: function() {
17895 return module.i;
17896 }
17897 });
17898 module.webpackPolyfill = 1;
17899 }
17900 return module;
17901};
17902
17903
17904/***/ }),
17905/* 156 */
17906/***/ (function(module, exports) {
17907
17908module.exports = XMLHttpRequest;
17909
17910
17911/***/ }),
17912/* 157 */
17913/***/ (function(module, exports, __webpack_require__) {
17914
17915"use strict";
17916
17917
17918var _typeof2 = __webpack_require__(64);
17919
17920var _typeof3 = _interopRequireDefault(_typeof2);
17921
17922function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17923
17924var SolidityCoder = __webpack_require__(21);
17925var Web3 = __webpack_require__(65);
17926
17927var state = {
17928 savedABIs: [],
17929 methodIDs: {}
17930};
17931
17932function _getABIs() {
17933 return state.savedABIs;
17934}
17935
17936function _addABI(abiArray) {
17937 if (Array.isArray(abiArray)) {
17938
17939 // Iterate new abi to generate method id's
17940 abiArray.map(function (abi) {
17941 if (abi.name) {
17942 var signature = new Web3().sha3(abi.name + "(" + abi.inputs.map(function (input) {
17943 return input.type;
17944 }).join(",") + ")");
17945 if (abi.type == "event") {
17946 state.methodIDs[signature.slice(2)] = abi;
17947 } else {
17948 state.methodIDs[signature.slice(2, 10)] = abi;
17949 }
17950 }
17951 });
17952
17953 state.savedABIs = state.savedABIs.concat(abiArray);
17954 } else {
17955 throw new Error("Expected ABI array, got " + (typeof abiArray === "undefined" ? "undefined" : (0, _typeof3.default)(abiArray)));
17956 }
17957}
17958
17959function _removeABI(abiArray) {
17960 if (Array.isArray(abiArray)) {
17961
17962 // Iterate new abi to generate method id's
17963 abiArray.map(function (abi) {
17964 if (abi.name) {
17965 var signature = new Web3().sha3(abi.name + "(" + abi.inputs.map(function (input) {
17966 return input.type;
17967 }).join(",") + ")");
17968 if (abi.type == "event") {
17969 if (state.methodIDs[signature.slice(2)]) {
17970 delete state.methodIDs[signature.slice(2)];
17971 }
17972 } else {
17973 if (state.methodIDs[signature.slice(2, 10)]) {
17974 delete state.methodIDs[signature.slice(2, 10)];
17975 }
17976 }
17977 }
17978 });
17979 } else {
17980 throw new Error("Expected ABI array, got " + (typeof abiArray === "undefined" ? "undefined" : (0, _typeof3.default)(abiArray)));
17981 }
17982}
17983
17984function _getMethodIDs() {
17985 return state.methodIDs;
17986}
17987
17988function _decodeMethod(data) {
17989 var methodID = data.slice(2, 10);
17990 var abiItem = state.methodIDs[methodID];
17991 if (abiItem) {
17992 var params = abiItem.inputs.map(function (item) {
17993 return item.type;
17994 });
17995 var decoded = SolidityCoder.decodeParams(params, data.slice(10));
17996 return {
17997 name: abiItem.name,
17998 params: decoded.map(function (param, index) {
17999 var parsedParam = param;
18000 if (abiItem.inputs[index].type.indexOf("uint") !== -1) {
18001 parsedParam = new Web3().toBigNumber(param).toString();
18002 }
18003 return {
18004 name: abiItem.inputs[index].name,
18005 value: parsedParam,
18006 type: abiItem.inputs[index].type
18007 };
18008 })
18009 };
18010 }
18011}
18012
18013function _decodeLogs(logs) {
18014 return logs.map(function (logItem) {
18015 var methodID = logItem.topics[0].slice(2);
18016 var method = state.methodIDs[methodID];
18017 if (method) {
18018 var logData = logItem.data;
18019 var decodedParams = [];
18020 var dataIndex = 0;
18021 var topicsIndex = 1;
18022
18023 var dataTypes = [];
18024 method.inputs.map(function (input) {
18025 if (!input.indexed) {
18026 dataTypes.push(input.type);
18027 }
18028 });
18029 var decodedData = SolidityCoder.decodeParams(dataTypes, logData.slice(2));
18030 // Loop topic and data to get the params
18031 method.inputs.map(function (param) {
18032 var decodedP = {
18033 name: param.name,
18034 type: param.type
18035 };
18036
18037 if (param.indexed) {
18038 decodedP.value = logItem.topics[topicsIndex];
18039 topicsIndex++;
18040 } else {
18041 decodedP.value = decodedData[dataIndex];
18042 dataIndex++;
18043 }
18044
18045 if (param.type == "address") {
18046 decodedP.value = "0x" + new Web3().toBigNumber(decodedP.value).toString(16);
18047 } else if (param.type == "uint256" || param.type == "uint8" || param.type == "int") {
18048 decodedP.value = new Web3().toBigNumber(decodedP.value).toString(10);
18049 }
18050
18051 decodedParams.push(decodedP);
18052 });
18053
18054 return {
18055 name: method.name,
18056 events: decodedParams,
18057 address: logItem.address
18058 };
18059 }
18060 });
18061}
18062
18063module.exports = {
18064 getABIs: _getABIs,
18065 addABI: _addABI,
18066 getMethodIDs: _getMethodIDs,
18067 decodeMethod: _decodeMethod,
18068 decodeLogs: _decodeLogs,
18069 removeABI: _removeABI
18070};
18071
18072/***/ })
18073/******/ ]);
\No newline at end of file