bundle.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. var require = function (file, cwd) {
  2. var resolved = require.resolve(file, cwd || '/');
  3. var mod = require.modules[resolved];
  4. if (!mod) throw new Error(
  5. 'Failed to resolve module ' + file + ', tried ' + resolved
  6. );
  7. var res = mod._cached ? mod._cached : mod();
  8. return res;
  9. }
  10. require.paths = [];
  11. require.modules = {};
  12. require.extensions = [".js",".coffee"];
  13. require._core = {
  14. 'assert': true,
  15. 'events': true,
  16. 'fs': true,
  17. 'path': true,
  18. 'vm': true
  19. };
  20. require.resolve = (function () {
  21. return function (x, cwd) {
  22. if (!cwd) cwd = '/';
  23. if (require._core[x]) return x;
  24. var path = require.modules.path();
  25. cwd = path.resolve('/', cwd);
  26. var y = cwd || '/';
  27. if (x.match(/^(?:\.\.?\/|\/)/)) {
  28. var m = loadAsFileSync(path.resolve(y, x))
  29. || loadAsDirectorySync(path.resolve(y, x));
  30. if (m) return m;
  31. }
  32. var n = loadNodeModulesSync(x, y);
  33. if (n) return n;
  34. throw new Error("Cannot find module '" + x + "'");
  35. function loadAsFileSync (x) {
  36. if (require.modules[x]) {
  37. return x;
  38. }
  39. for (var i = 0; i < require.extensions.length; i++) {
  40. var ext = require.extensions[i];
  41. if (require.modules[x + ext]) return x + ext;
  42. }
  43. }
  44. function loadAsDirectorySync (x) {
  45. x = x.replace(/\/+$/, '');
  46. var pkgfile = x + '/package.json';
  47. if (require.modules[pkgfile]) {
  48. var pkg = require.modules[pkgfile]();
  49. var b = pkg.browserify;
  50. if (typeof b === 'object' && b.main) {
  51. var m = loadAsFileSync(path.resolve(x, b.main));
  52. if (m) return m;
  53. }
  54. else if (typeof b === 'string') {
  55. var m = loadAsFileSync(path.resolve(x, b));
  56. if (m) return m;
  57. }
  58. else if (pkg.main) {
  59. var m = loadAsFileSync(path.resolve(x, pkg.main));
  60. if (m) return m;
  61. }
  62. }
  63. return loadAsFileSync(x + '/index');
  64. }
  65. function loadNodeModulesSync (x, start) {
  66. var dirs = nodeModulesPathsSync(start);
  67. for (var i = 0; i < dirs.length; i++) {
  68. var dir = dirs[i];
  69. var m = loadAsFileSync(dir + '/' + x);
  70. if (m) return m;
  71. var n = loadAsDirectorySync(dir + '/' + x);
  72. if (n) return n;
  73. }
  74. var m = loadAsFileSync(x);
  75. if (m) return m;
  76. }
  77. function nodeModulesPathsSync (start) {
  78. var parts;
  79. if (start === '/') parts = [ '' ];
  80. else parts = path.normalize(start).split('/');
  81. var dirs = [];
  82. for (var i = parts.length - 1; i >= 0; i--) {
  83. if (parts[i] === 'node_modules') continue;
  84. var dir = parts.slice(0, i + 1).join('/') + '/node_modules';
  85. dirs.push(dir);
  86. }
  87. return dirs;
  88. }
  89. };
  90. })();
  91. require.alias = function (from, to) {
  92. var path = require.modules.path();
  93. var res = null;
  94. try {
  95. res = require.resolve(from + '/package.json', '/');
  96. }
  97. catch (err) {
  98. res = require.resolve(from, '/');
  99. }
  100. var basedir = path.dirname(res);
  101. var keys = (Object.keys || function (obj) {
  102. var res = [];
  103. for (var key in obj) res.push(key)
  104. return res;
  105. })(require.modules);
  106. for (var i = 0; i < keys.length; i++) {
  107. var key = keys[i];
  108. if (key.slice(0, basedir.length + 1) === basedir + '/') {
  109. var f = key.slice(basedir.length);
  110. require.modules[to + f] = require.modules[basedir + f];
  111. }
  112. else if (key === basedir) {
  113. require.modules[to] = require.modules[basedir];
  114. }
  115. }
  116. };
  117. require.define = function (filename, fn) {
  118. var dirname = require._core[filename]
  119. ? ''
  120. : require.modules.path().dirname(filename)
  121. ;
  122. var require_ = function (file) {
  123. return require(file, dirname)
  124. };
  125. require_.resolve = function (name) {
  126. return require.resolve(name, dirname);
  127. };
  128. require_.modules = require.modules;
  129. require_.define = require.define;
  130. var module_ = { exports : {} };
  131. require.modules[filename] = function () {
  132. require.modules[filename]._cached = module_.exports;
  133. fn.call(
  134. module_.exports,
  135. require_,
  136. module_,
  137. module_.exports,
  138. dirname,
  139. filename
  140. );
  141. require.modules[filename]._cached = module_.exports;
  142. return module_.exports;
  143. };
  144. };
  145. if (typeof process === 'undefined') process = {};
  146. if (!process.nextTick) process.nextTick = (function () {
  147. var queue = [];
  148. var canPost = typeof window !== 'undefined'
  149. && window.postMessage && window.addEventListener
  150. ;
  151. if (canPost) {
  152. window.addEventListener('message', function (ev) {
  153. if (ev.source === window && ev.data === 'browserify-tick') {
  154. ev.stopPropagation();
  155. if (queue.length > 0) {
  156. var fn = queue.shift();
  157. fn();
  158. }
  159. }
  160. }, true);
  161. }
  162. return function (fn) {
  163. if (canPost) {
  164. queue.push(fn);
  165. window.postMessage('browserify-tick', '*');
  166. }
  167. else setTimeout(fn, 0);
  168. };
  169. })();
  170. if (!process.title) process.title = 'browser';
  171. if (!process.binding) process.binding = function (name) {
  172. if (name === 'evals') return require('vm')
  173. else throw new Error('No such module')
  174. };
  175. if (!process.cwd) process.cwd = function () { return '.' };
  176. if (!process.env) process.env = {};
  177. if (!process.argv) process.argv = [];
  178. require.define("path", function (require, module, exports, __dirname, __filename) {
  179. function filter (xs, fn) {
  180. var res = [];
  181. for (var i = 0; i < xs.length; i++) {
  182. if (fn(xs[i], i, xs)) res.push(xs[i]);
  183. }
  184. return res;
  185. }
  186. // resolves . and .. elements in a path array with directory names there
  187. // must be no slashes, empty elements, or device names (c:\) in the array
  188. // (so also no leading and trailing slashes - it does not distinguish
  189. // relative and absolute paths)
  190. function normalizeArray(parts, allowAboveRoot) {
  191. // if the path tries to go above the root, `up` ends up > 0
  192. var up = 0;
  193. for (var i = parts.length; i >= 0; i--) {
  194. var last = parts[i];
  195. if (last == '.') {
  196. parts.splice(i, 1);
  197. } else if (last === '..') {
  198. parts.splice(i, 1);
  199. up++;
  200. } else if (up) {
  201. parts.splice(i, 1);
  202. up--;
  203. }
  204. }
  205. // if the path is allowed to go above the root, restore leading ..s
  206. if (allowAboveRoot) {
  207. for (; up--; up) {
  208. parts.unshift('..');
  209. }
  210. }
  211. return parts;
  212. }
  213. // Regex to split a filename into [*, dir, basename, ext]
  214. // posix version
  215. var splitPathRe = /^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;
  216. // path.resolve([from ...], to)
  217. // posix version
  218. exports.resolve = function() {
  219. var resolvedPath = '',
  220. resolvedAbsolute = false;
  221. for (var i = arguments.length; i >= -1 && !resolvedAbsolute; i--) {
  222. var path = (i >= 0)
  223. ? arguments[i]
  224. : process.cwd();
  225. // Skip empty and invalid entries
  226. if (typeof path !== 'string' || !path) {
  227. continue;
  228. }
  229. resolvedPath = path + '/' + resolvedPath;
  230. resolvedAbsolute = path.charAt(0) === '/';
  231. }
  232. // At this point the path should be resolved to a full absolute path, but
  233. // handle relative paths to be safe (might happen when process.cwd() fails)
  234. // Normalize the path
  235. resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
  236. return !!p;
  237. }), !resolvedAbsolute).join('/');
  238. return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
  239. };
  240. // path.normalize(path)
  241. // posix version
  242. exports.normalize = function(path) {
  243. var isAbsolute = path.charAt(0) === '/',
  244. trailingSlash = path.slice(-1) === '/';
  245. // Normalize the path
  246. path = normalizeArray(filter(path.split('/'), function(p) {
  247. return !!p;
  248. }), !isAbsolute).join('/');
  249. if (!path && !isAbsolute) {
  250. path = '.';
  251. }
  252. if (path && trailingSlash) {
  253. path += '/';
  254. }
  255. return (isAbsolute ? '/' : '') + path;
  256. };
  257. // posix version
  258. exports.join = function() {
  259. var paths = Array.prototype.slice.call(arguments, 0);
  260. return exports.normalize(filter(paths, function(p, index) {
  261. return p && typeof p === 'string';
  262. }).join('/'));
  263. };
  264. exports.dirname = function(path) {
  265. var dir = splitPathRe.exec(path)[1] || '';
  266. var isWindows = false;
  267. if (!dir) {
  268. // No dirname
  269. return '.';
  270. } else if (dir.length === 1 ||
  271. (isWindows && dir.length <= 3 && dir.charAt(1) === ':')) {
  272. // It is just a slash or a drive letter with a slash
  273. return dir;
  274. } else {
  275. // It is a full dirname, strip trailing slash
  276. return dir.substring(0, dir.length - 1);
  277. }
  278. };
  279. exports.basename = function(path, ext) {
  280. var f = splitPathRe.exec(path)[2] || '';
  281. // TODO: make this comparison case-insensitive on windows?
  282. if (ext && f.substr(-1 * ext.length) === ext) {
  283. f = f.substr(0, f.length - ext.length);
  284. }
  285. return f;
  286. };
  287. exports.extname = function(path) {
  288. return splitPathRe.exec(path)[3] || '';
  289. };
  290. });
  291. require.define("crypto", function (require, module, exports, __dirname, __filename) {
  292. module.exports = require("crypto-browserify")
  293. });
  294. require.define("/node_modules/crypto-browserify/package.json", function (require, module, exports, __dirname, __filename) {
  295. module.exports = {}
  296. });
  297. require.define("/node_modules/crypto-browserify/index.js", function (require, module, exports, __dirname, __filename) {
  298. var sha = require('./sha')
  299. var algorithms = {
  300. sha1: {
  301. hex: sha.hex_sha1,
  302. binary: sha.b64_sha1,
  303. ascii: sha.str_sha1
  304. }
  305. }
  306. function error () {
  307. var m = [].slice.call(arguments).join(' ')
  308. throw new Error([
  309. m,
  310. 'we accept pull requests',
  311. 'http://github.com/dominictarr/crypto-browserify'
  312. ].join('\n'))
  313. }
  314. exports.createHash = function (alg) {
  315. alg = alg || 'sha1'
  316. if(!algorithms[alg])
  317. error('algorithm:', alg, 'is not yet supported')
  318. var s = ''
  319. _alg = algorithms[alg]
  320. return {
  321. update: function (data) {
  322. s += data
  323. return this
  324. },
  325. digest: function (enc) {
  326. enc = enc || 'binary'
  327. var fn
  328. if(!(fn = _alg[enc]))
  329. error('encoding:', enc , 'is not yet supported for algorithm', alg)
  330. var r = fn(s)
  331. s = null //not meant to use the hash after you've called digest.
  332. return r
  333. }
  334. }
  335. }
  336. // the least I can do is make error messages for the rest of the node.js/crypto api.
  337. ;['createCredentials'
  338. , 'createHmac'
  339. , 'createCypher'
  340. , 'createCypheriv'
  341. , 'createDecipher'
  342. , 'createDecipheriv'
  343. , 'createSign'
  344. , 'createVerify'
  345. , 'createDeffieHellman',
  346. , 'pbkdf2',
  347. , 'randomBytes' ].forEach(function (name) {
  348. exports[name] = function () {
  349. error('sorry,', name, 'is not implemented yet')
  350. }
  351. })
  352. });
  353. require.define("/node_modules/crypto-browserify/sha.js", function (require, module, exports, __dirname, __filename) {
  354. /*
  355. * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
  356. * in FIPS PUB 180-1
  357. * Version 2.1a Copyright Paul Johnston 2000 - 2002.
  358. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  359. * Distributed under the BSD License
  360. * See http://pajhome.org.uk/crypt/md5 for details.
  361. */
  362. exports.hex_sha1 = hex_sha1;
  363. exports.b64_sha1 = b64_sha1;
  364. exports.str_sha1 = str_sha1;
  365. exports.hex_hmac_sha1 = hex_hmac_sha1;
  366. exports.b64_hmac_sha1 = b64_hmac_sha1;
  367. exports.str_hmac_sha1 = str_hmac_sha1;
  368. /*
  369. * Configurable variables. You may need to tweak these to be compatible with
  370. * the server-side, but the defaults work in most cases.
  371. */
  372. var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
  373. var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
  374. var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
  375. /*
  376. * These are the functions you'll usually want to call
  377. * They take string arguments and return either hex or base-64 encoded strings
  378. */
  379. function hex_sha1(s){return binb2hex(core_sha1(str2binb(s),s.length * chrsz));}
  380. function b64_sha1(s){return binb2b64(core_sha1(str2binb(s),s.length * chrsz));}
  381. function str_sha1(s){return binb2str(core_sha1(str2binb(s),s.length * chrsz));}
  382. function hex_hmac_sha1(key, data){ return binb2hex(core_hmac_sha1(key, data));}
  383. function b64_hmac_sha1(key, data){ return binb2b64(core_hmac_sha1(key, data));}
  384. function str_hmac_sha1(key, data){ return binb2str(core_hmac_sha1(key, data));}
  385. /*
  386. * Perform a simple self-test to see if the VM is working
  387. */
  388. function sha1_vm_test()
  389. {
  390. return hex_sha1("abc") == "a9993e364706816aba3e25717850c26c9cd0d89d";
  391. }
  392. /*
  393. * Calculate the SHA-1 of an array of big-endian words, and a bit length
  394. */
  395. function core_sha1(x, len)
  396. {
  397. /* append padding */
  398. x[len >> 5] |= 0x80 << (24 - len % 32);
  399. x[((len + 64 >> 9) << 4) + 15] = len;
  400. var w = Array(80);
  401. var a = 1732584193;
  402. var b = -271733879;
  403. var c = -1732584194;
  404. var d = 271733878;
  405. var e = -1009589776;
  406. for(var i = 0; i < x.length; i += 16)
  407. {
  408. var olda = a;
  409. var oldb = b;
  410. var oldc = c;
  411. var oldd = d;
  412. var olde = e;
  413. for(var j = 0; j < 80; j++)
  414. {
  415. if(j < 16) w[j] = x[i + j];
  416. else w[j] = rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1);
  417. var t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)),
  418. safe_add(safe_add(e, w[j]), sha1_kt(j)));
  419. e = d;
  420. d = c;
  421. c = rol(b, 30);
  422. b = a;
  423. a = t;
  424. }
  425. a = safe_add(a, olda);
  426. b = safe_add(b, oldb);
  427. c = safe_add(c, oldc);
  428. d = safe_add(d, oldd);
  429. e = safe_add(e, olde);
  430. }
  431. return Array(a, b, c, d, e);
  432. }
  433. /*
  434. * Perform the appropriate triplet combination function for the current
  435. * iteration
  436. */
  437. function sha1_ft(t, b, c, d)
  438. {
  439. if(t < 20) return (b & c) | ((~b) & d);
  440. if(t < 40) return b ^ c ^ d;
  441. if(t < 60) return (b & c) | (b & d) | (c & d);
  442. return b ^ c ^ d;
  443. }
  444. /*
  445. * Determine the appropriate additive constant for the current iteration
  446. */
  447. function sha1_kt(t)
  448. {
  449. return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 :
  450. (t < 60) ? -1894007588 : -899497514;
  451. }
  452. /*
  453. * Calculate the HMAC-SHA1 of a key and some data
  454. */
  455. function core_hmac_sha1(key, data)
  456. {
  457. var bkey = str2binb(key);
  458. if(bkey.length > 16) bkey = core_sha1(bkey, key.length * chrsz);
  459. var ipad = Array(16), opad = Array(16);
  460. for(var i = 0; i < 16; i++)
  461. {
  462. ipad[i] = bkey[i] ^ 0x36363636;
  463. opad[i] = bkey[i] ^ 0x5C5C5C5C;
  464. }
  465. var hash = core_sha1(ipad.concat(str2binb(data)), 512 + data.length * chrsz);
  466. return core_sha1(opad.concat(hash), 512 + 160);
  467. }
  468. /*
  469. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  470. * to work around bugs in some JS interpreters.
  471. */
  472. function safe_add(x, y)
  473. {
  474. var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  475. var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  476. return (msw << 16) | (lsw & 0xFFFF);
  477. }
  478. /*
  479. * Bitwise rotate a 32-bit number to the left.
  480. */
  481. function rol(num, cnt)
  482. {
  483. return (num << cnt) | (num >>> (32 - cnt));
  484. }
  485. /*
  486. * Convert an 8-bit or 16-bit string to an array of big-endian words
  487. * In 8-bit function, characters >255 have their hi-byte silently ignored.
  488. */
  489. function str2binb(str)
  490. {
  491. var bin = Array();
  492. var mask = (1 << chrsz) - 1;
  493. for(var i = 0; i < str.length * chrsz; i += chrsz)
  494. bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (32 - chrsz - i%32);
  495. return bin;
  496. }
  497. /*
  498. * Convert an array of big-endian words to a string
  499. */
  500. function binb2str(bin)
  501. {
  502. var str = "";
  503. var mask = (1 << chrsz) - 1;
  504. for(var i = 0; i < bin.length * 32; i += chrsz)
  505. str += String.fromCharCode((bin[i>>5] >>> (32 - chrsz - i%32)) & mask);
  506. return str;
  507. }
  508. /*
  509. * Convert an array of big-endian words to a hex string.
  510. */
  511. function binb2hex(binarray)
  512. {
  513. var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
  514. var str = "";
  515. for(var i = 0; i < binarray.length * 4; i++)
  516. {
  517. str += hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) +
  518. hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8 )) & 0xF);
  519. }
  520. return str;
  521. }
  522. /*
  523. * Convert an array of big-endian words to a base-64 string
  524. */
  525. function binb2b64(binarray)
  526. {
  527. var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  528. var str = "";
  529. for(var i = 0; i < binarray.length * 4; i += 3)
  530. {
  531. var triplet = (((binarray[i >> 2] >> 8 * (3 - i %4)) & 0xFF) << 16)
  532. | (((binarray[i+1 >> 2] >> 8 * (3 - (i+1)%4)) & 0xFF) << 8 )
  533. | ((binarray[i+2 >> 2] >> 8 * (3 - (i+2)%4)) & 0xFF);
  534. for(var j = 0; j < 4; j++)
  535. {
  536. if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
  537. else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
  538. }
  539. }
  540. return str;
  541. }
  542. });
  543. require.define("/test.js", function (require, module, exports, __dirname, __filename) {
  544. var crypto = require('crypto')
  545. var abc = crypto.createHash('sha1').update('abc').digest('hex')
  546. console.log(abc)
  547. //require('hello').inlineCall().call2()
  548. });
  549. require("/test.js");