Projekt

Obecné

Profil

Stáhnout (17 KB) Statistiky
| Větev: | Revize:
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

    
11
require.paths = [];
12
require.modules = {};
13
require.extensions = [".js",".coffee"];
14

    
15
require._core = {
16
    'assert': true,
17
    'events': true,
18
    'fs': true,
19
    'path': true,
20
    'vm': true
21
};
22

    
23
require.resolve = (function () {
24
    return function (x, cwd) {
25
        if (!cwd) cwd = '/';
26
        
27
        if (require._core[x]) return x;
28
        var path = require.modules.path();
29
        cwd = path.resolve('/', cwd);
30
        var y = cwd || '/';
31
        
32
        if (x.match(/^(?:\.\.?\/|\/)/)) {
33
            var m = loadAsFileSync(path.resolve(y, x))
34
                || loadAsDirectorySync(path.resolve(y, x));
35
            if (m) return m;
36
        }
37
        
38
        var n = loadNodeModulesSync(x, y);
39
        if (n) return n;
40
        
41
        throw new Error("Cannot find module '" + x + "'");
42
        
43
        function loadAsFileSync (x) {
44
            if (require.modules[x]) {
45
                return x;
46
            }
47
            
48
            for (var i = 0; i < require.extensions.length; i++) {
49
                var ext = require.extensions[i];
50
                if (require.modules[x + ext]) return x + ext;
51
            }
52
        }
53
        
54
        function loadAsDirectorySync (x) {
55
            x = x.replace(/\/+$/, '');
56
            var pkgfile = x + '/package.json';
57
            if (require.modules[pkgfile]) {
58
                var pkg = require.modules[pkgfile]();
59
                var b = pkg.browserify;
60
                if (typeof b === 'object' && b.main) {
61
                    var m = loadAsFileSync(path.resolve(x, b.main));
62
                    if (m) return m;
63
                }
64
                else if (typeof b === 'string') {
65
                    var m = loadAsFileSync(path.resolve(x, b));
66
                    if (m) return m;
67
                }
68
                else if (pkg.main) {
69
                    var m = loadAsFileSync(path.resolve(x, pkg.main));
70
                    if (m) return m;
71
                }
72
            }
73
            
74
            return loadAsFileSync(x + '/index');
75
        }
76
        
77
        function loadNodeModulesSync (x, start) {
78
            var dirs = nodeModulesPathsSync(start);
79
            for (var i = 0; i < dirs.length; i++) {
80
                var dir = dirs[i];
81
                var m = loadAsFileSync(dir + '/' + x);
82
                if (m) return m;
83
                var n = loadAsDirectorySync(dir + '/' + x);
84
                if (n) return n;
85
            }
86
            
87
            var m = loadAsFileSync(x);
88
            if (m) return m;
89
        }
90
        
91
        function nodeModulesPathsSync (start) {
92
            var parts;
93
            if (start === '/') parts = [ '' ];
94
            else parts = path.normalize(start).split('/');
95
            
96
            var dirs = [];
97
            for (var i = parts.length - 1; i >= 0; i--) {
98
                if (parts[i] === 'node_modules') continue;
99
                var dir = parts.slice(0, i + 1).join('/') + '/node_modules';
100
                dirs.push(dir);
101
            }
102
            
103
            return dirs;
104
        }
105
    };
106
})();
107

    
108
require.alias = function (from, to) {
109
    var path = require.modules.path();
110
    var res = null;
111
    try {
112
        res = require.resolve(from + '/package.json', '/');
113
    }
114
    catch (err) {
115
        res = require.resolve(from, '/');
116
    }
117
    var basedir = path.dirname(res);
118
    
119
    var keys = (Object.keys || function (obj) {
120
        var res = [];
121
        for (var key in obj) res.push(key)
122
        return res;
123
    })(require.modules);
124
    
125
    for (var i = 0; i < keys.length; i++) {
126
        var key = keys[i];
127
        if (key.slice(0, basedir.length + 1) === basedir + '/') {
128
            var f = key.slice(basedir.length);
129
            require.modules[to + f] = require.modules[basedir + f];
130
        }
131
        else if (key === basedir) {
132
            require.modules[to] = require.modules[basedir];
133
        }
134
    }
135
};
136

    
137
require.define = function (filename, fn) {
138
    var dirname = require._core[filename]
139
        ? ''
140
        : require.modules.path().dirname(filename)
141
    ;
142
    
143
    var require_ = function (file) {
144
        return require(file, dirname)
145
    };
146
    require_.resolve = function (name) {
147
        return require.resolve(name, dirname);
148
    };
149
    require_.modules = require.modules;
150
    require_.define = require.define;
151
    var module_ = { exports : {} };
152
    
153
    require.modules[filename] = function () {
154
        require.modules[filename]._cached = module_.exports;
155
        fn.call(
156
            module_.exports,
157
            require_,
158
            module_,
159
            module_.exports,
160
            dirname,
161
            filename
162
        );
163
        require.modules[filename]._cached = module_.exports;
164
        return module_.exports;
165
    };
166
};
167

    
168
if (typeof process === 'undefined') process = {};
169

    
170
if (!process.nextTick) process.nextTick = (function () {
171
    var queue = [];
172
    var canPost = typeof window !== 'undefined'
173
        && window.postMessage && window.addEventListener
174
    ;
175
    
176
    if (canPost) {
177
        window.addEventListener('message', function (ev) {
178
            if (ev.source === window && ev.data === 'browserify-tick') {
179
                ev.stopPropagation();
180
                if (queue.length > 0) {
181
                    var fn = queue.shift();
182
                    fn();
183
                }
184
            }
185
        }, true);
186
    }
187
    
188
    return function (fn) {
189
        if (canPost) {
190
            queue.push(fn);
191
            window.postMessage('browserify-tick', '*');
192
        }
193
        else setTimeout(fn, 0);
194
    };
195
})();
196

    
197
if (!process.title) process.title = 'browser';
198

    
199
if (!process.binding) process.binding = function (name) {
200
    if (name === 'evals') return require('vm')
201
    else throw new Error('No such module')
202
};
203

    
204
if (!process.cwd) process.cwd = function () { return '.' };
205

    
206
if (!process.env) process.env = {};
207
if (!process.argv) process.argv = [];
208

    
209
require.define("path", function (require, module, exports, __dirname, __filename) {
210
function filter (xs, fn) {
211
    var res = [];
212
    for (var i = 0; i < xs.length; i++) {
213
        if (fn(xs[i], i, xs)) res.push(xs[i]);
214
    }
215
    return res;
216
}
217

    
218
// resolves . and .. elements in a path array with directory names there
219
// must be no slashes, empty elements, or device names (c:\) in the array
220
// (so also no leading and trailing slashes - it does not distinguish
221
// relative and absolute paths)
222
function normalizeArray(parts, allowAboveRoot) {
223
  // if the path tries to go above the root, `up` ends up > 0
224
  var up = 0;
225
  for (var i = parts.length; i >= 0; i--) {
226
    var last = parts[i];
227
    if (last == '.') {
228
      parts.splice(i, 1);
229
    } else if (last === '..') {
230
      parts.splice(i, 1);
231
      up++;
232
    } else if (up) {
233
      parts.splice(i, 1);
234
      up--;
235
    }
236
  }
237

    
238
  // if the path is allowed to go above the root, restore leading ..s
239
  if (allowAboveRoot) {
240
    for (; up--; up) {
241
      parts.unshift('..');
242
    }
243
  }
244

    
245
  return parts;
246
}
247

    
248
// Regex to split a filename into [*, dir, basename, ext]
249
// posix version
250
var splitPathRe = /^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;
251

    
252
// path.resolve([from ...], to)
253
// posix version
254
exports.resolve = function() {
255
var resolvedPath = '',
256
    resolvedAbsolute = false;
257

    
258
for (var i = arguments.length; i >= -1 && !resolvedAbsolute; i--) {
259
  var path = (i >= 0)
260
      ? arguments[i]
261
      : process.cwd();
262

    
263
  // Skip empty and invalid entries
264
  if (typeof path !== 'string' || !path) {
265
    continue;
266
  }
267

    
268
  resolvedPath = path + '/' + resolvedPath;
269
  resolvedAbsolute = path.charAt(0) === '/';
270
}
271

    
272
// At this point the path should be resolved to a full absolute path, but
273
// handle relative paths to be safe (might happen when process.cwd() fails)
274

    
275
// Normalize the path
276
resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
277
    return !!p;
278
  }), !resolvedAbsolute).join('/');
279

    
280
  return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
281
};
282

    
283
// path.normalize(path)
284
// posix version
285
exports.normalize = function(path) {
286
var isAbsolute = path.charAt(0) === '/',
287
    trailingSlash = path.slice(-1) === '/';
288

    
289
// Normalize the path
290
path = normalizeArray(filter(path.split('/'), function(p) {
291
    return !!p;
292
  }), !isAbsolute).join('/');
293

    
294
  if (!path && !isAbsolute) {
295
    path = '.';
296
  }
297
  if (path && trailingSlash) {
298
    path += '/';
299
  }
300
  
301
  return (isAbsolute ? '/' : '') + path;
302
};
303

    
304

    
305
// posix version
306
exports.join = function() {
307
  var paths = Array.prototype.slice.call(arguments, 0);
308
  return exports.normalize(filter(paths, function(p, index) {
309
    return p && typeof p === 'string';
310
  }).join('/'));
311
};
312

    
313

    
314
exports.dirname = function(path) {
315
  var dir = splitPathRe.exec(path)[1] || '';
316
  var isWindows = false;
317
  if (!dir) {
318
    // No dirname
319
    return '.';
320
  } else if (dir.length === 1 ||
321
      (isWindows && dir.length <= 3 && dir.charAt(1) === ':')) {
322
    // It is just a slash or a drive letter with a slash
323
    return dir;
324
  } else {
325
    // It is a full dirname, strip trailing slash
326
    return dir.substring(0, dir.length - 1);
327
  }
328
};
329

    
330

    
331
exports.basename = function(path, ext) {
332
  var f = splitPathRe.exec(path)[2] || '';
333
  // TODO: make this comparison case-insensitive on windows?
334
  if (ext && f.substr(-1 * ext.length) === ext) {
335
    f = f.substr(0, f.length - ext.length);
336
  }
337
  return f;
338
};
339

    
340

    
341
exports.extname = function(path) {
342
  return splitPathRe.exec(path)[3] || '';
343
};
344

    
345
});
346

    
347
require.define("crypto", function (require, module, exports, __dirname, __filename) {
348
module.exports = require("crypto-browserify")
349
});
350

    
351
require.define("/node_modules/crypto-browserify/package.json", function (require, module, exports, __dirname, __filename) {
352
module.exports = {}
353
});
354

    
355
require.define("/node_modules/crypto-browserify/index.js", function (require, module, exports, __dirname, __filename) {
356
var sha = require('./sha')
357

    
358
var algorithms = {
359
  sha1: {
360
    hex: sha.hex_sha1,
361
    binary: sha.b64_sha1,
362
    ascii: sha.str_sha1
363
  }
364
}
365

    
366
function error () {
367
  var m = [].slice.call(arguments).join(' ')
368
  throw new Error([
369
    m,
370
    'we accept pull requests',
371
    'http://github.com/dominictarr/crypto-browserify'
372
    ].join('\n'))
373
}
374

    
375
exports.createHash = function (alg) {
376
  alg = alg || 'sha1'
377
  if(!algorithms[alg])
378
    error('algorithm:', alg, 'is not yet supported')
379
  var s = ''
380
  _alg = algorithms[alg]
381
  return {
382
    update: function (data) {
383
      s += data
384
      return this
385
    },
386
    digest: function (enc) {
387
      enc = enc || 'binary'
388
      var fn 
389
      if(!(fn = _alg[enc]))
390
        error('encoding:', enc , 'is not yet supported for algorithm', alg)
391
      var r = fn(s)
392
      s = null //not meant to use the hash after you've called digest.
393
      return r
394
    }
395
  }
396
}
397
// the least I can do is make error messages for the rest of the node.js/crypto api.
398
;['createCredentials'
399
, 'createHmac'
400
, 'createCypher'
401
, 'createCypheriv'
402
, 'createDecipher'
403
, 'createDecipheriv'
404
, 'createSign'
405
, 'createVerify'
406
, 'createDeffieHellman',
407
, 'pbkdf2',
408
, 'randomBytes' ].forEach(function (name) {
409
  exports[name] = function () {
410
    error('sorry,', name, 'is not implemented yet')
411
  }
412
})
413

    
414
});
415

    
416
require.define("/node_modules/crypto-browserify/sha.js", function (require, module, exports, __dirname, __filename) {
417
/*
418
 * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
419
 * in FIPS PUB 180-1
420
 * Version 2.1a Copyright Paul Johnston 2000 - 2002.
421
 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
422
 * Distributed under the BSD License
423
 * See http://pajhome.org.uk/crypt/md5 for details.
424
 */
425

    
426
exports.hex_sha1 = hex_sha1;
427
exports.b64_sha1 = b64_sha1;
428
exports.str_sha1 = str_sha1;
429
exports.hex_hmac_sha1 = hex_hmac_sha1;
430
exports.b64_hmac_sha1 = b64_hmac_sha1;
431
exports.str_hmac_sha1 = str_hmac_sha1;
432

    
433
/*
434
 * Configurable variables. You may need to tweak these to be compatible with
435
 * the server-side, but the defaults work in most cases.
436
 */
437
var hexcase = 0;  /* hex output format. 0 - lowercase; 1 - uppercase        */
438
var b64pad  = ""; /* base-64 pad character. "=" for strict RFC compliance   */
439
var chrsz   = 8;  /* bits per input character. 8 - ASCII; 16 - Unicode      */
440

    
441
/*
442
 * These are the functions you'll usually want to call
443
 * They take string arguments and return either hex or base-64 encoded strings
444
 */
445
function hex_sha1(s){return binb2hex(core_sha1(str2binb(s),s.length * chrsz));}
446
function b64_sha1(s){return binb2b64(core_sha1(str2binb(s),s.length * chrsz));}
447
function str_sha1(s){return binb2str(core_sha1(str2binb(s),s.length * chrsz));}
448
function hex_hmac_sha1(key, data){ return binb2hex(core_hmac_sha1(key, data));}
449
function b64_hmac_sha1(key, data){ return binb2b64(core_hmac_sha1(key, data));}
450
function str_hmac_sha1(key, data){ return binb2str(core_hmac_sha1(key, data));}
451

    
452
/*
453
 * Perform a simple self-test to see if the VM is working
454
 */
455
function sha1_vm_test()
456
{
457
  return hex_sha1("abc") == "a9993e364706816aba3e25717850c26c9cd0d89d";
458
}
459

    
460
/*
461
 * Calculate the SHA-1 of an array of big-endian words, and a bit length
462
 */
463
function core_sha1(x, len)
464
{
465
  /* append padding */
466
  x[len >> 5] |= 0x80 << (24 - len % 32);
467
  x[((len + 64 >> 9) << 4) + 15] = len;
468

    
469
  var w = Array(80);
470
  var a =  1732584193;
471
  var b = -271733879;
472
  var c = -1732584194;
473
  var d =  271733878;
474
  var e = -1009589776;
475

    
476
  for(var i = 0; i < x.length; i += 16)
477
  {
478
    var olda = a;
479
    var oldb = b;
480
    var oldc = c;
481
    var oldd = d;
482
    var olde = e;
483

    
484
    for(var j = 0; j < 80; j++)
485
    {
486
      if(j < 16) w[j] = x[i + j];
487
      else w[j] = rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1);
488
      var t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)),
489
                       safe_add(safe_add(e, w[j]), sha1_kt(j)));
490
      e = d;
491
      d = c;
492
      c = rol(b, 30);
493
      b = a;
494
      a = t;
495
    }
496

    
497
    a = safe_add(a, olda);
498
    b = safe_add(b, oldb);
499
    c = safe_add(c, oldc);
500
    d = safe_add(d, oldd);
501
    e = safe_add(e, olde);
502
  }
503
  return Array(a, b, c, d, e);
504

    
505
}
506

    
507
/*
508
 * Perform the appropriate triplet combination function for the current
509
 * iteration
510
 */
511
function sha1_ft(t, b, c, d)
512
{
513
  if(t < 20) return (b & c) | ((~b) & d);
514
  if(t < 40) return b ^ c ^ d;
515
  if(t < 60) return (b & c) | (b & d) | (c & d);
516
  return b ^ c ^ d;
517
}
518

    
519
/*
520
 * Determine the appropriate additive constant for the current iteration
521
 */
522
function sha1_kt(t)
523
{
524
  return (t < 20) ?  1518500249 : (t < 40) ?  1859775393 :
525
         (t < 60) ? -1894007588 : -899497514;
526
}
527

    
528
/*
529
 * Calculate the HMAC-SHA1 of a key and some data
530
 */
531
function core_hmac_sha1(key, data)
532
{
533
  var bkey = str2binb(key);
534
  if(bkey.length > 16) bkey = core_sha1(bkey, key.length * chrsz);
535

    
536
  var ipad = Array(16), opad = Array(16);
537
  for(var i = 0; i < 16; i++)
538
  {
539
    ipad[i] = bkey[i] ^ 0x36363636;
540
    opad[i] = bkey[i] ^ 0x5C5C5C5C;
541
  }
542

    
543
  var hash = core_sha1(ipad.concat(str2binb(data)), 512 + data.length * chrsz);
544
  return core_sha1(opad.concat(hash), 512 + 160);
545
}
546

    
547
/*
548
 * Add integers, wrapping at 2^32. This uses 16-bit operations internally
549
 * to work around bugs in some JS interpreters.
550
 */
551
function safe_add(x, y)
552
{
553
  var lsw = (x & 0xFFFF) + (y & 0xFFFF);
554
  var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
555
  return (msw << 16) | (lsw & 0xFFFF);
556
}
557

    
558
/*
559
 * Bitwise rotate a 32-bit number to the left.
560
 */
561
function rol(num, cnt)
562
{
563
  return (num << cnt) | (num >>> (32 - cnt));
564
}
565

    
566
/*
567
 * Convert an 8-bit or 16-bit string to an array of big-endian words
568
 * In 8-bit function, characters >255 have their hi-byte silently ignored.
569
 */
570
function str2binb(str)
571
{
572
  var bin = Array();
573
  var mask = (1 << chrsz) - 1;
574
  for(var i = 0; i < str.length * chrsz; i += chrsz)
575
    bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (32 - chrsz - i%32);
576
  return bin;
577
}
578

    
579
/*
580
 * Convert an array of big-endian words to a string
581
 */
582
function binb2str(bin)
583
{
584
  var str = "";
585
  var mask = (1 << chrsz) - 1;
586
  for(var i = 0; i < bin.length * 32; i += chrsz)
587
    str += String.fromCharCode((bin[i>>5] >>> (32 - chrsz - i%32)) & mask);
588
  return str;
589
}
590

    
591
/*
592
 * Convert an array of big-endian words to a hex string.
593
 */
594
function binb2hex(binarray)
595
{
596
  var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
597
  var str = "";
598
  for(var i = 0; i < binarray.length * 4; i++)
599
  {
600
    str += hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) +
601
           hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8  )) & 0xF);
602
  }
603
  return str;
604
}
605

    
606
/*
607
 * Convert an array of big-endian words to a base-64 string
608
 */
609
function binb2b64(binarray)
610
{
611
  var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
612
  var str = "";
613
  for(var i = 0; i < binarray.length * 4; i += 3)
614
  {
615
    var triplet = (((binarray[i   >> 2] >> 8 * (3 -  i   %4)) & 0xFF) << 16)
616
                | (((binarray[i+1 >> 2] >> 8 * (3 - (i+1)%4)) & 0xFF) << 8 )
617
                |  ((binarray[i+2 >> 2] >> 8 * (3 - (i+2)%4)) & 0xFF);
618
    for(var j = 0; j < 4; j++)
619
    {
620
      if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
621
      else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
622
    }
623
  }
624
  return str;
625
}
626

    
627

    
628
});
629

    
630
require.define("/test.js", function (require, module, exports, __dirname, __filename) {
631
    var crypto = require('crypto')
632
var abc = crypto.createHash('sha1').update('abc').digest('hex')
633
console.log(abc)
634
//require('hello').inlineCall().call2()
635

    
636
});
637
require("/test.js");
(1-1/3)