replace events and MD5 modules with equivalent Node.js shims

one notable change as a result: you now call emitter.emit() instead of
emitter.fire().
This commit is contained in:
Jeff Williams 2012-10-30 22:49:04 -07:00
parent ddbe0315d4
commit 35ac56fdd0
20 changed files with 599 additions and 391 deletions

View File

@ -18,10 +18,10 @@
],
"dependencies": {
"async": "0.1.22",
"crypto-browserify": "git://github.com/dominictarr/crypto-browserify.git#95c5d505",
"github-flavored-markdown": "git://github.com/hegemonic/github-flavored-markdown.git",
"js2xmlparser": "0.1.0",
"jshint": "0.9.1",
"jsMD5": "git://github.com/hegemonic/jsMD5.git",
"markdown": "0.4.0",
"taffydb": "git://github.com/hegemonic/taffydb.git",
"underscore": "1.4.2",

View File

@ -66,6 +66,16 @@ The source code for Async.js is available at:
https://github.com/caolan/async
## crypto-browserify ##
License information for crypto-browserify is not available. It is assumed that
the package is distributed under the MIT license or a similar open source
license.
The source code for crypto-browserify is available at:
https://github.com/dominictarr/crypto-browserify
## github-flavored-markdown ##
github-flavored-markdown is distributed under the BSD 3-clause license:
@ -168,38 +178,6 @@ The source code for JSHint is available at:
https://github.com/jshint/jshint
## jsMD5 ##
jsMD5 is distributed under the BSD 2-clause license:
> Copyright (c) 2011, Yoshinori Kohyama (http://algobit.jp/) All rights
> reserved.
>
> Redistribution and use in source and binary forms, with or without
> modification, are permitted provided that the following conditions are met:
>
> - Redistributions of source code must retain the above copyright notice,
> this list of conditions and the following disclaimer.
>
> - Redistributions in binary form must reproduce the above copyright notice,
> this list of conditions and the following disclaimer in the documentation
> and/or other materials provided with the distribution.
>
> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
> AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
> DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
> FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
> DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
> SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
> CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
> OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
> OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The source code for jsMD5 is available at:
https://github.com/hegemonic/jsMD5
## markdown-js ##
markdown-js is distributed under the MIT license, which is reproduced above.
@ -228,6 +206,20 @@ The source code for Node.js is available at:
https://github.com/joyent/node
## node-browserify ##
Portions of the node-browserify source code are incorporated into the following
files:
- `rhino_modules/events.js`
node-browserify is distributed under the MIT license, which is reproduced above.
The source code for node-browserify is available at:
https://github.com/substack/node-browserify
## TaffyDB ##
TaffyDB is distributed under a modified BSD license:

68
node_modules/crypto-browserify/index.js generated vendored Normal file
View File

@ -0,0 +1,68 @@
var sha = require('./sha')
var rng = require('./rng')
var algorithms = {
sha1: {
hex: sha.hex_sha1,
binary: sha.b64_sha1,
ascii: sha.str_sha1
}
}
function error () {
var m = [].slice.call(arguments).join(' ')
throw new Error([
m,
'we accept pull requests',
'http://github.com/dominictarr/crypto-browserify'
].join('\n'))
}
exports.createHash = function (alg) {
alg = alg || 'sha1'
if(!algorithms[alg])
error('algorithm:', alg, 'is not yet supported')
var s = ''
var _alg = algorithms[alg]
return {
update: function (data) {
s += data
return this
},
digest: function (enc) {
enc = enc || 'binary'
var fn
if(!(fn = _alg[enc]))
error('encoding:', enc , 'is not yet supported for algorithm', alg)
var r = fn(s)
s = null //not meant to use the hash after you've called digest.
return r
}
}
}
exports.randomBytes = function(size, callback) {
if (callback && callback.call) {
try {
callback.call(this, undefined, rng(size));
} catch (err) { callback(err); }
} else {
return rng(size);
}
}
// the least I can do is make error messages for the rest of the node.js/crypto api.
;['createCredentials'
, 'createHmac'
, 'createCypher'
, 'createCypheriv'
, 'createDecipher'
, 'createDecipheriv'
, 'createSign'
, 'createVerify'
, 'createDeffieHellman'
, 'pbkdf2'].forEach(function (name) {
exports[name] = function () {
error('sorry,', name, 'is not implemented yet')
}
})

29
node_modules/crypto-browserify/package.json generated vendored Normal file
View File

@ -0,0 +1,29 @@
{
"author": {
"name": "Dominic Tarr",
"email": "dominic.tarr@gmail.com",
"url": "dominictarr.com"
},
"name": "crypto-browserify",
"description": "partial implementation of crypto for the browser",
"version": "0.1.1",
"homepage": "https://github.com/dominictarr/crypto-browserify",
"repository": {
"url": ""
},
"scripts": {
"test": "node test/simple.js"
},
"engines": {
"node": "*"
},
"dependencies": {},
"devDependencies": {},
"optionalDependencies": {},
"readme": "# crypto-browserify\n\nA (partial) port of `crypto` to the browser.\n\nBasically, I found some crypto implemented in JS lieing on the internet somewhere\nand wrapped it in the part of the `crypto` api that I am currently using.\n\nIn a way that will be compatible with [browserify](https://github.com/substack/node-browserify/).\n\nI will extend this if I need more features, or if anyone else wants to extend this,\nI will add you as a maintainer.\n\nProvided that you agree that it should replicate the [node.js/crypto](http://nodejs.org/api/crypto.html) api exactly, of course.\n\n",
"_id": "crypto-browserify@0.1.1",
"dist": {
"shasum": "251b240c6bd0e95db0654fbc8b178b855cbef45e"
},
"_from": "crypto-browserify@git://github.com/dominictarr/crypto-browserify.git#95c5d505"
}

37
node_modules/crypto-browserify/rng.js generated vendored Normal file
View File

@ -0,0 +1,37 @@
// Original code adapted from Robert Kieffer.
// details at https://github.com/broofa/node-uuid
(function() {
var _global = this;
var mathRNG, whatwgRNG;
// NOTE: Math.random() does not guarantee "cryptographic quality"
mathRNG = function(size) {
var bytes = new Array(size);
var r;
for (var i = 0, r; i < size; i++) {
if ((i & 0x03) == 0) r = Math.random() * 0x100000000;
bytes[i] = r >>> ((i & 0x03) << 3) & 0xff;
}
return bytes;
}
// currently only available in webkit-based browsers.
if (_global.crypto && crypto.getRandomValues) {
var _rnds = new Uint32Array(4);
whatwgRNG = function(size) {
var bytes = new Array(size);
crypto.getRandomValues(_rnds);
for (var c = 0 ; c < size; c++) {
bytes[c] = _rnds[c >> 2] >>> ((c & 0x03) * 8) & 0xff;
}
return bytes;
}
}
module.exports = whatwgRNG || mathRNG;
}())

210
node_modules/crypto-browserify/sha.js generated vendored Normal file
View File

@ -0,0 +1,210 @@
/*
* A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
* in FIPS PUB 180-1
* Version 2.1a Copyright Paul Johnston 2000 - 2002.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* Distributed under the BSD License
* See http://pajhome.org.uk/crypt/md5 for details.
*/
exports.hex_sha1 = hex_sha1;
exports.b64_sha1 = b64_sha1;
exports.str_sha1 = str_sha1;
exports.hex_hmac_sha1 = hex_hmac_sha1;
exports.b64_hmac_sha1 = b64_hmac_sha1;
exports.str_hmac_sha1 = str_hmac_sha1;
/*
* Configurable variables. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
*/
var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
/*
* These are the functions you'll usually want to call
* They take string arguments and return either hex or base-64 encoded strings
*/
function hex_sha1(s){return binb2hex(core_sha1(str2binb(s),s.length * chrsz));}
function b64_sha1(s){return binb2b64(core_sha1(str2binb(s),s.length * chrsz));}
function str_sha1(s){return binb2str(core_sha1(str2binb(s),s.length * chrsz));}
function hex_hmac_sha1(key, data){ return binb2hex(core_hmac_sha1(key, data));}
function b64_hmac_sha1(key, data){ return binb2b64(core_hmac_sha1(key, data));}
function str_hmac_sha1(key, data){ return binb2str(core_hmac_sha1(key, data));}
/*
* Perform a simple self-test to see if the VM is working
*/
function sha1_vm_test()
{
return hex_sha1("abc") == "a9993e364706816aba3e25717850c26c9cd0d89d";
}
/*
* Calculate the SHA-1 of an array of big-endian words, and a bit length
*/
function core_sha1(x, len)
{
/* append padding */
x[len >> 5] |= 0x80 << (24 - len % 32);
x[((len + 64 >> 9) << 4) + 15] = len;
var w = Array(80);
var a = 1732584193;
var b = -271733879;
var c = -1732584194;
var d = 271733878;
var e = -1009589776;
for(var i = 0; i < x.length; i += 16)
{
var olda = a;
var oldb = b;
var oldc = c;
var oldd = d;
var olde = e;
for(var j = 0; j < 80; j++)
{
if(j < 16) w[j] = x[i + j];
else w[j] = rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1);
var t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)),
safe_add(safe_add(e, w[j]), sha1_kt(j)));
e = d;
d = c;
c = rol(b, 30);
b = a;
a = t;
}
a = safe_add(a, olda);
b = safe_add(b, oldb);
c = safe_add(c, oldc);
d = safe_add(d, oldd);
e = safe_add(e, olde);
}
return Array(a, b, c, d, e);
}
/*
* Perform the appropriate triplet combination function for the current
* iteration
*/
function sha1_ft(t, b, c, d)
{
if(t < 20) return (b & c) | ((~b) & d);
if(t < 40) return b ^ c ^ d;
if(t < 60) return (b & c) | (b & d) | (c & d);
return b ^ c ^ d;
}
/*
* Determine the appropriate additive constant for the current iteration
*/
function sha1_kt(t)
{
return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 :
(t < 60) ? -1894007588 : -899497514;
}
/*
* Calculate the HMAC-SHA1 of a key and some data
*/
function core_hmac_sha1(key, data)
{
var bkey = str2binb(key);
if(bkey.length > 16) bkey = core_sha1(bkey, key.length * chrsz);
var ipad = Array(16), opad = Array(16);
for(var i = 0; i < 16; i++)
{
ipad[i] = bkey[i] ^ 0x36363636;
opad[i] = bkey[i] ^ 0x5C5C5C5C;
}
var hash = core_sha1(ipad.concat(str2binb(data)), 512 + data.length * chrsz);
return core_sha1(opad.concat(hash), 512 + 160);
}
/*
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
* to work around bugs in some JS interpreters.
*/
function safe_add(x, y)
{
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);
}
/*
* Bitwise rotate a 32-bit number to the left.
*/
function rol(num, cnt)
{
return (num << cnt) | (num >>> (32 - cnt));
}
/*
* Convert an 8-bit or 16-bit string to an array of big-endian words
* In 8-bit function, characters >255 have their hi-byte silently ignored.
*/
function str2binb(str)
{
var bin = Array();
var mask = (1 << chrsz) - 1;
for(var i = 0; i < str.length * chrsz; i += chrsz)
bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (32 - chrsz - i%32);
return bin;
}
/*
* Convert an array of big-endian words to a string
*/
function binb2str(bin)
{
var str = "";
var mask = (1 << chrsz) - 1;
for(var i = 0; i < bin.length * 32; i += chrsz)
str += String.fromCharCode((bin[i>>5] >>> (32 - chrsz - i%32)) & mask);
return str;
}
/*
* Convert an array of big-endian words to a hex string.
*/
function binb2hex(binarray)
{
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
var str = "";
for(var i = 0; i < binarray.length * 4; i++)
{
str += hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) +
hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8 )) & 0xF);
}
return str;
}
/*
* Convert an array of big-endian words to a base-64 string
*/
function binb2b64(binarray)
{
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var str = "";
for(var i = 0; i < binarray.length * 4; i += 3)
{
var triplet = (((binarray[i >> 2] >> 8 * (3 - i %4)) & 0xFF) << 16)
| (((binarray[i+1 >> 2] >> 8 * (3 - (i+1)%4)) & 0xFF) << 8 )
| ((binarray[i+2 >> 2] >> 8 * (3 - (i+2)%4)) & 0xFF);
for(var j = 0; j < 4; j++)
{
if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
}
}
return str;
}

26
node_modules/jsMD5/LICENSE generated vendored
View File

@ -1,26 +0,0 @@
Copyright (c) 2011, Yoshinori Kohyama (http://algobit.jp/)
All rights reserved.
Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the following
conditions are met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.

167
node_modules/jsMD5/md5.js generated vendored
View File

@ -1,167 +0,0 @@
/**
* md5.js
* Copyright (c) 2011, Yoshinori Kohyama (http://algobit.jp/)
* all rights reserved.
*/
exports.digest = function (M) {
function F(x, y, z) { return (x & y) | (~x & z); }
function G(x, y, z) { return (x & z) | (y & ~z); }
function H(x, y, z) { return x ^ y ^ z; }
function I(x, y, z) { return y ^ (x | ~z); }
function to4bytes(n) {
return [n&0xff, (n>>>8)&0xff, (n>>>16)&0xff, (n>>>24)&0xff];
}
var originalLength = M.length; // for Step.2
// 3.1 Step 1. Append Padding Bits
M.push(0x80);
var l = (56 - M.length)&0x3f;
for (var i = 0; i < l; i++)
M.push(0);
// 3.2 Step 2. Append Length
to4bytes(8*originalLength).forEach(function (e) { M.push(e); });
[0, 0, 0, 0].forEach(function (e) { M.push(e); });
// 3.3 Step 3. Initialize MD Buffer
var A = [0x67452301];
var B = [0xefcdab89];
var C = [0x98badcfe];
var D = [0x10325476];
var AA, BB, CC, DD;
// 3.4 Step 4. Process Message in 16-Word Blocks
function rounds(a, b, c, d, k, s, t, f) {
a[0] += f(b[0], c[0], d[0]) + X[k] + t;
a[0] = ((a[0]<<s)|(a[0]>>>(32 - s)));
a[0] += b[0];
}
var X;
for (var i = 0; i < M.length; i += 64) {
X = [];
for (var j = 0; j < 64; j += 4) {
k = i + j;
X.push(M[k]|(M[k + 1]<<8)|(M[k + 2]<<16)|(M[k + 3]<<24));
}
AA = A[0];
BB = B[0];
CC = C[0];
DD = D[0];
// Round 1.
rounds(A, B, C, D, 0, 7, 0xd76aa478, F);
rounds(D, A, B, C, 1, 12, 0xe8c7b756, F);
rounds(C, D, A, B, 2, 17, 0x242070db, F);
rounds(B, C, D, A, 3, 22, 0xc1bdceee, F);
rounds(A, B, C, D, 4, 7, 0xf57c0faf, F);
rounds(D, A, B, C, 5, 12, 0x4787c62a, F);
rounds(C, D, A, B, 6, 17, 0xa8304613, F);
rounds(B, C, D, A, 7, 22, 0xfd469501, F);
rounds(A, B, C, D, 8, 7, 0x698098d8, F);
rounds(D, A, B, C, 9, 12, 0x8b44f7af, F);
rounds(C, D, A, B, 10, 17, 0xffff5bb1, F);
rounds(B, C, D, A, 11, 22, 0x895cd7be, F);
rounds(A, B, C, D, 12, 7, 0x6b901122, F);
rounds(D, A, B, C, 13, 12, 0xfd987193, F);
rounds(C, D, A, B, 14, 17, 0xa679438e, F);
rounds(B, C, D, A, 15, 22, 0x49b40821, F);
// Round 2.
rounds(A, B, C, D, 1, 5, 0xf61e2562, G);
rounds(D, A, B, C, 6, 9, 0xc040b340, G);
rounds(C, D, A, B, 11, 14, 0x265e5a51, G);
rounds(B, C, D, A, 0, 20, 0xe9b6c7aa, G);
rounds(A, B, C, D, 5, 5, 0xd62f105d, G);
rounds(D, A, B, C, 10, 9, 0x02441453, G);
rounds(C, D, A, B, 15, 14, 0xd8a1e681, G);
rounds(B, C, D, A, 4, 20, 0xe7d3fbc8, G);
rounds(A, B, C, D, 9, 5, 0x21e1cde6, G);
rounds(D, A, B, C, 14, 9, 0xc33707d6, G);
rounds(C, D, A, B, 3, 14, 0xf4d50d87, G);
rounds(B, C, D, A, 8, 20, 0x455a14ed, G);
rounds(A, B, C, D, 13, 5, 0xa9e3e905, G);
rounds(D, A, B, C, 2, 9, 0xfcefa3f8, G);
rounds(C, D, A, B, 7, 14, 0x676f02d9, G);
rounds(B, C, D, A, 12, 20, 0x8d2a4c8a, G);
// Round 3.
rounds(A, B, C, D, 5, 4, 0xfffa3942, H);
rounds(D, A, B, C, 8, 11, 0x8771f681, H);
rounds(C, D, A, B, 11, 16, 0x6d9d6122, H);
rounds(B, C, D, A, 14, 23, 0xfde5380c, H);
rounds(A, B, C, D, 1, 4, 0xa4beea44, H);
rounds(D, A, B, C, 4, 11, 0x4bdecfa9, H);
rounds(C, D, A, B, 7, 16, 0xf6bb4b60, H);
rounds(B, C, D, A, 10, 23, 0xbebfbc70, H);
rounds(A, B, C, D, 13, 4, 0x289b7ec6, H);
rounds(D, A, B, C, 0, 11, 0xeaa127fa, H);
rounds(C, D, A, B, 3, 16, 0xd4ef3085, H);
rounds(B, C, D, A, 6, 23, 0x04881d05, H);
rounds(A, B, C, D, 9, 4, 0xd9d4d039, H);
rounds(D, A, B, C, 12, 11, 0xe6db99e5, H);
rounds(C, D, A, B, 15, 16, 0x1fa27cf8, H);
rounds(B, C, D, A, 2, 23, 0xc4ac5665, H);
// Round 4.
rounds(A, B, C, D, 0, 6, 0xf4292244, I);
rounds(D, A, B, C, 7, 10, 0x432aff97, I);
rounds(C, D, A, B, 14, 15, 0xab9423a7, I);
rounds(B, C, D, A, 5, 21, 0xfc93a039, I);
rounds(A, B, C, D, 12, 6, 0x655b59c3, I);
rounds(D, A, B, C, 3, 10, 0x8f0ccc92, I);
rounds(C, D, A, B, 10, 15, 0xffeff47d, I);
rounds(B, C, D, A, 1, 21, 0x85845dd1, I);
rounds(A, B, C, D, 8, 6, 0x6fa87e4f, I);
rounds(D, A, B, C, 15, 10, 0xfe2ce6e0, I);
rounds(C, D, A, B, 6, 15, 0xa3014314, I);
rounds(B, C, D, A, 13, 21, 0x4e0811a1, I);
rounds(A, B, C, D, 4, 6, 0xf7537e82, I);
rounds(D, A, B, C, 11, 10, 0xbd3af235, I);
rounds(C, D, A, B, 2, 15, 0x2ad7d2bb, I);
rounds(B, C, D, A, 9, 21, 0xeb86d391, I);
A[0] += AA;
B[0] += BB;
C[0] += CC;
D[0] += DD;
}
var rval = [];
to4bytes(A[0]).forEach(function (e) { rval.push(e); });
to4bytes(B[0]).forEach(function (e) { rval.push(e); });
to4bytes(C[0]).forEach(function (e) { rval.push(e); });
to4bytes(D[0]).forEach(function (e) { rval.push(e); });
return rval;
}
exports.digest_s = function (s) {
var M = [];
for (var i = 0; i < s.length; i++)
M.push(s.charCodeAt(i));
var d = exports.digest(M);
var rstr = '';
d.forEach(function (e) {
var s = e.toString(16);
while (s.length < 2)
s = '0' + s;
rstr += s;
});
return rstr;
}
// to test
/*
function test(s) {
console.log('MD5 ("' + s + '") = ' + exports.digest_s(s));
}
test('');
test('a');
test('abc');
test('message digest');
test('abcdefghijklmnopqrstuvwxyz');
test('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789');
test('12345678901234567890123456789012345678901234567890123456789012345678901234567890');
*/

24
node_modules/jsMD5/package.json generated vendored
View File

@ -1,24 +0,0 @@
{
"name": "jsMD5",
"version": "0.1.0",
"description": "An implementation of RFC 1321 - The MD5 Message-Digest Algorithm in JavaScript.",
"main": "md5.js",
"repository": {
"type": "git",
"url": "git://github.com/hegemonic/jsMD5.git"
},
"keywords": [
"javascript",
"md5"
],
"author": {
"name": "Yoshinori Kohyama"
},
"license": "MIT",
"readme": "English\n=======\n\nWhat is this\n------------\n\njsMD5 is an implementation of [RFC 1321 - The MD5 Message-Digest Algorithm] (http://tools.ietf.org/html/rfc1321) in JavaScript.\n\nUsage\n-----\n\nTo use this do as below:\n\n var md5 = require('./md5');\n var na = md5.digest(<array of numbers>);\n // na is an array of numbers\n var str = md5.digest_s(<string>);\n // str is an string\n\n\"array of numbers\" is an array of unsigned integer of each bytes to digest or of each bytes of digested.\n\nLicense\n-------\n\nCopyright (c) 2011, Yoshinori Kohyama (http://algobit.jp/) \nAll rights reserved. \n\nRedistribution and use in source and binary forms, with or \nwithout modification, are permitted provided that the following \nconditions are met: \n\nRedistributions of source code must retain the above copyright \nnotice, this list of conditions and the following disclaimer. \nRedistributions in binary form must reproduce the above \ncopyright notice, this list of conditions and the following \ndisclaimer in the documentation and/or other materials provided \nwith the distribution. \nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND \nCONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, \nINCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF \nMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE \nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR \nCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF \nUSE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED \nAND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT \nLIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING \nIN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF \nTHE POSSIBILITY OF SUCH DAMAGE. \n\n\nJapanese\n========\n\nこれは何\n--------\n\njsMD5 は [RFC 1321 - The MD5 Message-Digest Algorithm] (http://tools.ietf.org/html/rfc1321) の JavaScript による実装です.\n\n使い方\n------\n\n利用するには\n\n var md5 = require('./md5'); \n var na = md5.digest(数値の配列); \n // na は数値配列\n var str = md5.digest_s(文字列);\n // str は文字列\n\nのようにします.\n数値の配列はダイジェストを取りたいバイト列およびダイジェスト計算を行った後のバイト列の, 各バイトを非符号整数にしたものの配列です.\n\nライセンス\n----------\n\n修正 BSD ライセンスです.\n上記英文だけが法律的に有効です.\n参考のため以下に日本語訳を掲載します.\n\nCopyright (c) 2011, Yoshinori Kohyama (http://algobit.jp/) \nAll rights reserved. \n\nソースコード形式であれバイナリ形式であれ、変更の有無に関わらず、 \n以下の条件を満たす限りにおいて、再配布および使用を許可します: \n\nソースコード形式で再配布する場合、上記著作権表示、 本条件書およ \nび下記責任限定規定を必ず含めてください。 \nバイナリ形式で再配布する場合、上記著作権表示、 本条件書および下 \n記責任限定規定を、配布物とともに提供される文書 および/または \n他の資料に必ず含めてください。 \n本ソフトウェアは著作権保持者によって、”現状のまま” 提供される \nものとします。 本ソフトウェアについては、明示黙示を問わず、 商 \n用品として通常そなえるべき品質をそなえているとの保証も、 特定の \n目的に適合するとの保証を含め、何の保証もなされません。 事由のい \nかんを問わず、 損害発生の原因いかんを問わず、且つ、 責任の根拠 \nが契約であるか厳格責任であるか (過失その他) 不法行為であるか \nを問わず、 著作権保持者も寄与者も、 仮にそのような損害が発生す \nる可能性を知らされていたとしても、 本ソフトウェアの使用から発生 \nした直接損害、間接損害、偶発的な損害、 特別損害、懲罰的損害また \nは結果損害のいずれに対しても (代替品またはサービスの提供; 使 \n用機会、データまたは利益の損失の補償; または、業務の中断に対す \nる補償を含め) 責任をいっさい負いません。 \n\nこのソフトウェアと文書に含まれる意見や結論はそれらの著作者による \nものであって、 著作者の公式な方針を、明示黙示を問わず、 あらわ \nしているものととってはならない。 \n",
"_id": "jsMD5@0.1.0",
"dist": {
"shasum": "3bc75f1c6d183eb3cc545ca473c34b7242845ba3"
},
"_from": "git://github.com/hegemonic/jsMD5.git"
}

View File

@ -1,7 +1,7 @@
{
"name": "jsdoc",
"version": "3.0.0",
"revision": "1351054863206",
"revision": "1351661862323",
"description": "An automatic documentation generator for javascript.",
"keywords": [ "documentation", "javascript" ],
"licenses": [
@ -18,10 +18,10 @@
],
"dependencies": {
"async": "0.1.22",
"crypto-browserify": "git://github.com/dominictarr/crypto-browserify.git#95c5d505",
"github-flavored-markdown": "git://github.com/hegemonic/github-flavored-markdown.git",
"js2xmlparser": "0.1.0",
"jshint": "0.9.1",
"jsMD5": "git://github.com/hegemonic/jsMD5.git",
"markdown": "0.4.0",
"taffydb": "git://github.com/hegemonic/taffydb.git",
"underscore": "1.4.2",

View File

@ -1,71 +0,0 @@
/**
Functions related to events. Designed to be mixed into other classes.
@exports common/events
@author Michael Mathews <micmath@gmail.com>
@license Apache License 2.0 - See file 'LICENSE.md' in this project.
*/
module.exports = {
/**
@param {string} type
@param {function} handler
@returns {this}
*/
on: function(type, handler, context) {
if ( !type || !handler ) {
return;
}
if ( !context ) { context = this; }
if ( !this.__bindings ) { this.__bindings = {}; }
// TODO check here for hasOwnProperty?
if ( !this.__bindings[type] ) { this.__bindings[type] = []; }
var call = function(e) {
return handler.call(context, e);
};
this.__bindings[type].push( {handler: handler, call: call} );
return this; // chainable
},
/**
@param {string} type
@param {object} [eventData]
@returns {this}
*/
fire: function(eventType, eventData) {
if ( !eventType || !this.__bindings || !this.__bindings[eventType] ) {
return;
}
// run handlers in first-in-first-run order
for (var i = 0, leni = this.__bindings[eventType].length; i < leni; i++) {
if ( false === this.__bindings[eventType][i].call(eventData) ) {
if (eventData) { eventData.defaultPrevented = true; }
}
}
return this; // chainable
},
/**
@param {string} type
@param {function} handler
*/
removeListener: function(type, handler) {
if ( !type || !handler || !this.__bindings || !this.__bindings[type] ) {
return;
}
var i = this.__bindings[type].length;
while ( i-- ) {
if ( this.__bindings[type][i].handler === handler ) {
this.__bindings[type].splice(i, 1);
}
}
if (this.__bindings[type].length === 0) {
delete this.__bindings[type];
}
}
};

1
rhino_modules/crypto.js Normal file
View File

@ -0,0 +1 @@
module.exports = require('crypto-browserify');

200
rhino_modules/events.js Normal file
View File

@ -0,0 +1,200 @@
/**
* Shim for Node.js `events` module. Adapted from `node-browserify`.
* @see https://github.com/substack/node-browserify
* @license MIT
*/
if (!process.EventEmitter) {
process.EventEmitter = function () {};
}
var EventEmitter = exports.EventEmitter = process.EventEmitter;
var isArray = typeof Array.isArray === 'function' ?
Array.isArray :
function (xs) {
return Object.prototype.toString.call(xs) === '[object Array]';
}
;
// By default EventEmitters will print a warning if more than
// 10 listeners are added to it. This is a useful default which
// helps finding memory leaks.
//
// Obviously not all Emitters should be limited to 10. This function allows
// that to be increased. Set to zero for unlimited.
var defaultMaxListeners = 10;
EventEmitter.prototype.setMaxListeners = function(n) {
if (!this._events) {
this._events = {};
}
this._events.maxListeners = n;
};
EventEmitter.prototype.emit = function(type) {
var args;
// If there is no 'error' event listener then throw.
if (type === 'error') {
if (!this._events || !this._events.error ||
(isArray(this._events.error) && !this._events.error.length))
{
if (arguments[1] instanceof Error) {
throw arguments[1]; // Unhandled 'error' event
} else {
throw new Error("Uncaught, unspecified 'error' event.");
}
return false;
}
}
if (!this._events) {
return false;
}
var handler = this._events[type];
if (!handler) {
return false;
}
if (typeof handler == 'function') {
switch (arguments.length) {
// fast cases
case 1:
handler.call(this);
break;
case 2:
handler.call(this, arguments[1]);
break;
case 3:
handler.call(this, arguments[1], arguments[2]);
break;
// slower
default:
args = Array.prototype.slice.call(arguments, 1);
handler.apply(this, args);
}
return true;
} else if (isArray(handler)) {
args = Array.prototype.slice.call(arguments, 1);
var listeners = handler.slice();
for (var i = 0, l = listeners.length; i < l; i++) {
listeners[i].apply(this, args);
}
return true;
} else {
return false;
}
};
// EventEmitter is defined in src/node_events.cc
// EventEmitter.prototype.emit() is also defined there.
EventEmitter.prototype.addListener = function(type, listener) {
if ('function' !== typeof listener) {
throw new Error('addListener only takes instances of Function');
}
if (!this._events) {
this._events = {};
}
// To avoid recursion in the case that type == "newListeners"! Before
// adding it to the listeners, first emit "newListeners".
this.emit('newListener', type, listener);
if (!this._events[type]) {
// Optimize the case of one listener. Don't need the extra array object.
this._events[type] = listener;
} else if (isArray(this._events[type])) {
// Check for listener leak
if (!this._events[type].warned) {
var m;
if (this._events.maxListeners !== undefined) {
m = this._events.maxListeners;
} else {
m = defaultMaxListeners;
}
if (m && m > 0 && this._events[type].length > m) {
this._events[type].warned = true;
console.error('(node) warning: possible EventEmitter memory ' +
'leak detected. %d listeners added. ' +
'Use emitter.setMaxListeners() to increase limit.',
this._events[type].length);
console.trace();
}
}
// If we've already got an array, just append.
this._events[type].push(listener);
} else {
// Adding the second element, need to change to array.
this._events[type] = [this._events[type], listener];
}
return this;
};
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
EventEmitter.prototype.once = function(type, listener) {
var self = this;
self.on(type, function g() {
self.removeListener(type, g);
listener.apply(this, arguments);
});
return this;
};
EventEmitter.prototype.removeListener = function(type, listener) {
if ('function' !== typeof listener) {
throw new Error('removeListener only takes instances of Function');
}
// does not use listeners(), so no side effect of creating _events[type]
if (!this._events || !this._events[type]) {
return this;
}
var list = this._events[type];
if (isArray(list)) {
var i = list.indexOf(listener);
if (i < 0) {
return this;
}
list.splice(i, 1);
if (list.length === 0) {
delete this._events[type];
}
} else if (this._events[type] === listener) {
delete this._events[type];
}
return this;
};
EventEmitter.prototype.removeAllListeners = function(type) {
// does not use listeners(), so no side effect of creating _events[type]
if (type && this._events && this._events[type]) {
this._events[type] = null;
}
return this;
};
EventEmitter.prototype.listeners = function(type) {
if (!this._events) {
this._events = {};
}
if (!this._events[type]) {
this._events[type] = [];
}
if (!isArray(this._events[type])) {
this._events[type] = [this._events[type]];
}
return this._events[type];
};

View File

@ -149,7 +149,7 @@ exports.attachTo = function(parser) {
var e;
if (newDoclet) {
e = { doclet: newDoclet };
this.fire('newDoclet', e);
this.emit('newDoclet', e);
if (!e.defaultPrevented) {
if ( !filter(newDoclet) ) {

View File

@ -2,8 +2,8 @@
/**
* @module jsdoc/src/parser
* @requires common/util
* @requires common/fs
* @requires common/events
* @requires fs
* @requires events
*/
var Token = Packages.org.mozilla.javascript.Token,
@ -13,7 +13,7 @@ var Token = Packages.org.mozilla.javascript.Token,
/**
* @class
* @mixes module:common/events
* @mixes module:events
*
* @example <caption>Create a new parser.</caption>
* var jsdocParser = new (require('jsdoc/src/parser').Parser)();
@ -28,7 +28,7 @@ exports.Parser = function() {
};
this._visitors = [];
};
require('common/util').mixin(exports.Parser.prototype, require('common/events'));
exports.Parser.prototype = Object.create( require('events').EventEmitter.prototype );
/**
* Parse the given source files for JSDoc comments.
@ -335,7 +335,7 @@ function visitNode(node) {
filename: currentSourceName
};
currentParser.fire('jsdocCommentFound', e, currentParser);
currentParser.emit('jsdocCommentFound', e, currentParser);
}
}
e = null;
@ -457,7 +457,7 @@ function visitNode(node) {
}
if (!e.preventDefault && isValidJsdoc(e.comment)) {
currentParser.fire(e.event, e, currentParser);
currentParser.emit(e.event, e, currentParser);
}
for (i = 0, l = e.finishers.length; i < l; i++) {
@ -470,11 +470,11 @@ function visitNode(node) {
/** @private */
exports.Parser.prototype._parseSourceCode = function(sourceCode, sourceName) {
var e = {filename: sourceName};
this.fire('fileBegin', e);
this.emit('fileBegin', e);
if (!e.defaultPrevented) {
e = {filename: sourceName, source: sourceCode};
this.fire('beforeParse', e);
this.emit('beforeParse', e);
sourceCode = e.source;
currentSourceName = sourceName = e.filename;
@ -488,7 +488,7 @@ exports.Parser.prototype._parseSourceCode = function(sourceCode, sourceName) {
);
}
this.fire('fileComplete', e);
this.emit('fileComplete', e);
currentSourceName = '';
};

View File

@ -1,26 +1,20 @@
/**
@module jsdoc/src/scanner
@requires module:common/fs
@requires module:fs
@author Michael Mathews <micmath@gmail.com>
@license Apache License 2.0 - See file 'LICENSE.md' in this project.
*/
var common = {
mixin: require('common/util').mixin,
events: require('common/events')
};
var fs = require('fs');
/**
@constructor
@mixes module:common.events
@mixes module:events
*/
exports.Scanner = function() {
};
common.mixin(exports.Scanner.prototype, common.events);
exports.Scanner = function() {};
exports.Scanner.prototype = Object.create( require('events').EventEmitter.prototype );
/**
Recursively searches the given searchPaths for js files.
@ -30,7 +24,7 @@ common.mixin(exports.Scanner.prototype, common.events);
*/
exports.Scanner.prototype.scan = function(searchPaths, depth, filter) {
var filePaths = [],
that = this;
self = this;
searchPaths = searchPaths || [];
depth = depth || 1;
@ -51,7 +45,7 @@ exports.Scanner.prototype.scan = function(searchPaths, depth, filter) {
filePaths = filePaths.filter(function($) {
var e = { fileName: $ };
that.fire('sourceFileFound', e);
self.emit('sourceFileFound', e);
return !e.defaultPrevented;
});

View File

@ -3,7 +3,7 @@
* @module jsdoc/util/templateHelper
*/
var md5 = require('jsMD5').digest_s;
var crypto = require('crypto');
var dictionary = require('jsdoc/tag/dictionary');
var files = {};
@ -49,7 +49,7 @@ function strToFilename(str) {
var basename = str.replace(nsprefix, '$1-');
if ( /[^$a-z0-9._\-]/i.test(basename) ) {
return md5(str).substr(0, 10);
return crypto.createHash('sha1').update(str).digest('hex').substr(0, 10);
}
return makeFilenameUnique(basename, str);
}

View File

@ -1,36 +0,0 @@
describe("common/events", function() {
var common = {events: require('common/events')};
it('should exist', function() {
expect(common.events).toBeDefined();
expect(typeof common.events).toEqual("object");
});
it('should export a "on" function.', function() {
expect(common.events.on).toBeDefined();
expect(typeof common.events.on).toEqual("function");
});
it('should export a "fire" function.', function() {
expect(common.events.fire).toBeDefined();
expect(typeof common.events.fire).toEqual("function");
});
it('should export a "removeListener" function.', function() {
expect(common.events.removeListener).toBeDefined();
expect(typeof common.events.removeListener).toEqual("function");
});
it('The "on" function attaches a handler to an object that can be fired.', function() {
var target = {},
result = false;
target.on = common.events.on;
target.fire = common.events.fire;
target.on('test', function() { result = true; });
target.fire('test');
expect(result).toEqual(true);
});
});

View File

@ -1,3 +1,4 @@
/*global describe: true, expect: true, it: true */
describe("jsdoc/src/handlers", function() {
var jsdoc = {src: { parser: require('jsdoc/src/parser')}},
testParser = new jsdoc.src.parser.Parser(),
@ -17,24 +18,24 @@ describe("jsdoc/src/handlers", function() {
describe("attachTo", function() {
it("should attach a 'jsdocCommentFound' handler to the parser", function() {
var callbacks = testParser.__bindings['jsdocCommentFound'];
var callbacks = testParser.listeners("jsdocCommentFound");
expect(callbacks).toBeDefined();
expect(callbacks.length).toEqual(1);
expect(typeof callbacks[0].handler).toEqual("function");
expect(typeof callbacks[0]).toEqual("function");
});
it("should attach a 'symbolFound' handler to the parser", function() {
var callbacks = testParser.__bindings['symbolFound'];
var callbacks = testParser.listeners("symbolFound");
expect(callbacks).toBeDefined();
expect(callbacks.length).toEqual(1);
expect(typeof callbacks[0].handler).toEqual("function");
expect(typeof callbacks[0]).toEqual("function");
});
it("should attach a 'fileComplete' handler to the parser", function() {
var callbacks = testParser.__bindings['fileComplete'];
var callbacks = testParser.listeners("fileComplete");
expect(callbacks).toBeDefined();
expect(callbacks.length).toEqual(1);
expect(typeof callbacks[0].handler).toEqual("function");
expect(typeof callbacks[0]).toEqual("function");
});
});

View File

@ -1,4 +1,4 @@
/*global describe: true, env: true, it: true */
/*global afterEach: true, beforeEach: true, describe: true, expect: true, env: true, it: true, xdescribe: true */
describe("jsdoc/util/templateHelper", function() {
var helper = require('jsdoc/util/templateHelper');
helper.registerLink('test', 'path/to/test.html');
@ -134,7 +134,7 @@ describe("jsdoc/util/templateHelper", function() {
},
url = helper.createLink(mockDoclet);
expect(url).toEqual('9305caaec5.html#"*foo"');
expect(url).toEqual('be9d9563a3.html#"*foo"');
});
});