meteor-node-stubs 1.2.22 → 1.2.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/node_modules/sha.js/.eslintrc +76 -0
- package/node_modules/sha.js/CHANGELOG.md +423 -0
- package/node_modules/sha.js/README.md +1 -1
- package/node_modules/sha.js/bin.js +30 -27
- package/node_modules/sha.js/hash.js +65 -62
- package/node_modules/sha.js/index.js +16 -12
- package/node_modules/sha.js/package.json +56 -28
- package/node_modules/sha.js/sha.js +73 -63
- package/node_modules/sha.js/sha1.js +75 -65
- package/node_modules/sha.js/sha224.js +34 -32
- package/node_modules/sha.js/sha256.js +159 -105
- package/node_modules/sha.js/sha384.js +46 -44
- package/node_modules/sha.js/sha512.js +355 -233
- package/node_modules/sha.js/test/hash.js +63 -58
- package/node_modules/sha.js/test/test.js +120 -82
- package/node_modules/sha.js/test/vectors.js +58 -58
- package/package.json +3 -1
- package/node_modules/sha.js/.travis.yml +0 -17
|
@@ -1,75 +1,80 @@
|
|
|
1
|
-
|
|
2
|
-
var Hash = require('../hash')
|
|
3
|
-
var hex = '0A1B2C3D4E5F6G7H'
|
|
1
|
+
'use strict';
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
var tape = require('tape');
|
|
4
|
+
var Buffer = require('safe-buffer').Buffer;
|
|
5
|
+
|
|
6
|
+
var Hash = require('../hash');
|
|
7
|
+
|
|
8
|
+
var hex = '0A1B2C3D4E5F6G7H';
|
|
9
|
+
|
|
10
|
+
function equal(t, a, b) {
|
|
11
|
+
t.equal(a.length, b.length);
|
|
12
|
+
t.equal(a.toString('hex'), b.toString('hex'));
|
|
8
13
|
}
|
|
9
14
|
|
|
10
|
-
var hexBuf = Buffer.from('0A1B2C3D4E5F6G7H', 'utf8')
|
|
15
|
+
var hexBuf = Buffer.from('0A1B2C3D4E5F6G7H', 'utf8');
|
|
11
16
|
var count16 = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
17
|
+
strings: ['0A1B2C3D4E5F6G7H'],
|
|
18
|
+
buffers: [
|
|
19
|
+
hexBuf,
|
|
20
|
+
Buffer.from('80000000000000000000000000000080', 'hex')
|
|
21
|
+
]
|
|
22
|
+
};
|
|
18
23
|
|
|
19
24
|
var empty = {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
+
strings: [''],
|
|
26
|
+
buffers: [
|
|
27
|
+
Buffer.from('80000000000000000000000000000000', 'hex')
|
|
28
|
+
]
|
|
29
|
+
};
|
|
25
30
|
|
|
26
31
|
var multi = {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
32
|
+
strings: ['abcd', 'efhijk', 'lmnopq'],
|
|
33
|
+
buffers: [
|
|
34
|
+
Buffer.from('abcdefhijklmnopq', 'ascii'),
|
|
35
|
+
Buffer.from('80000000000000000000000000000080', 'hex')
|
|
36
|
+
]
|
|
37
|
+
};
|
|
33
38
|
|
|
34
39
|
var long = {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
40
|
+
strings: [hex + hex],
|
|
41
|
+
buffers: [
|
|
42
|
+
hexBuf,
|
|
43
|
+
hexBuf,
|
|
44
|
+
Buffer.from('80000000000000000000000000000100', 'hex')
|
|
45
|
+
]
|
|
46
|
+
};
|
|
42
47
|
|
|
43
|
-
function makeTest
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
function makeTest(name, data) {
|
|
49
|
+
tape(name, function (t) {
|
|
50
|
+
var h = new Hash(16, 8);
|
|
51
|
+
var hash = Buffer.alloc(20);
|
|
52
|
+
var n = 2;
|
|
53
|
+
var expected = data.buffers.slice();
|
|
54
|
+
// t.plan(expected.length + 1)
|
|
50
55
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
56
|
+
h._update = function (block) {
|
|
57
|
+
var e = expected.shift();
|
|
58
|
+
equal(t, block, e);
|
|
54
59
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
if (n < 0) {
|
|
61
|
+
throw new Error('expecting only 2 calls to _update');
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
h._hash = function () {
|
|
65
|
+
return hash;
|
|
66
|
+
};
|
|
62
67
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
68
|
+
data.strings.forEach(function (string) {
|
|
69
|
+
h.update(string, 'ascii');
|
|
70
|
+
});
|
|
66
71
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
72
|
+
equal(t, h.digest(), hash);
|
|
73
|
+
t.end();
|
|
74
|
+
});
|
|
70
75
|
}
|
|
71
76
|
|
|
72
|
-
makeTest('Hash#update 1 in 1', count16)
|
|
73
|
-
makeTest('empty Hash#update', empty)
|
|
74
|
-
makeTest('Hash#update 1 in 3', multi)
|
|
75
|
-
makeTest('Hash#update 2 in 1', long)
|
|
77
|
+
makeTest('Hash#update 1 in 1', count16);
|
|
78
|
+
makeTest('empty Hash#update', empty);
|
|
79
|
+
makeTest('Hash#update 1 in 3', multi);
|
|
80
|
+
makeTest('Hash#update 2 in 1', long);
|
|
@@ -1,100 +1,138 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var crypto = require('crypto');
|
|
4
|
+
var tape = require('tape');
|
|
5
|
+
var Buffer = require('safe-buffer').Buffer;
|
|
6
|
+
|
|
7
|
+
var Sha1 = require('../').sha1;
|
|
8
|
+
|
|
9
|
+
var nodeSupportsUint16 = false;
|
|
10
|
+
try {
|
|
11
|
+
crypto.createHash('sha1').update(new Uint16Array());
|
|
12
|
+
nodeSupportsUint16 = true;
|
|
13
|
+
} catch (err) {}
|
|
4
14
|
|
|
5
15
|
var inputs = [
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
]
|
|
16
|
+
['', 'ascii'],
|
|
17
|
+
['abc', 'ascii'],
|
|
18
|
+
['123', 'ascii'],
|
|
19
|
+
['123456789abcdef123456789abcdef123456789abcdef123456789abcdef', 'ascii'],
|
|
20
|
+
['123456789abcdef123456789abcdef123456789abcdef123456789abc', 'ascii'],
|
|
21
|
+
['123456789abcdef123456789abcdef123456789abcdef123456789ab', 'ascii'],
|
|
22
|
+
['0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcde', 'ascii'],
|
|
23
|
+
['0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef', 'ascii'],
|
|
24
|
+
['foobarbaz', 'ascii'],
|
|
25
|
+
[Buffer.from('buffer')],
|
|
26
|
+
nodeSupportsUint16 ? [new Uint16Array([1, 2, 3])] : null
|
|
27
|
+
].filter(Boolean);
|
|
16
28
|
|
|
17
29
|
tape("hash is the same as node's crypto", function (t) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
})
|
|
30
|
+
inputs.forEach(function (v) {
|
|
31
|
+
var a = new Sha1().update(v[0], v[1]).digest('hex');
|
|
32
|
+
var e = crypto.createHash('sha1').update(v[0], v[1]).digest('hex');
|
|
33
|
+
t.equal(a, e, a + ' == ' + e);
|
|
34
|
+
});
|
|
24
35
|
|
|
25
|
-
|
|
26
|
-
})
|
|
36
|
+
t.end();
|
|
37
|
+
});
|
|
27
38
|
|
|
28
39
|
tape('call update multiple times', function (t) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
})
|
|
40
|
+
inputs.forEach(function (v) {
|
|
41
|
+
var hash = new Sha1();
|
|
42
|
+
var sha1hash = crypto.createHash('sha1');
|
|
43
|
+
|
|
44
|
+
for (var i = 0; i < v[0].length; i = (i + 1) * 2) {
|
|
45
|
+
var s = v[0].slice(i, (i + 1) * 2);
|
|
46
|
+
hash.update(s, v[1]);
|
|
47
|
+
sha1hash.update(s, v[1]);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
var a = hash.digest('hex');
|
|
51
|
+
var e = sha1hash.digest('hex');
|
|
52
|
+
t.equal(a, e, a + ' == ' + e);
|
|
53
|
+
});
|
|
54
|
+
t.end();
|
|
55
|
+
});
|
|
46
56
|
|
|
47
57
|
tape('call update twice', function (t) {
|
|
48
|
-
|
|
49
|
-
|
|
58
|
+
var sha1hash = crypto.createHash('sha1');
|
|
59
|
+
var hash = new Sha1();
|
|
50
60
|
|
|
51
|
-
|
|
52
|
-
|
|
61
|
+
sha1hash.update('foo', 'ascii');
|
|
62
|
+
hash.update('foo', 'ascii');
|
|
53
63
|
|
|
54
|
-
|
|
55
|
-
|
|
64
|
+
sha1hash.update('bar', 'ascii');
|
|
65
|
+
hash.update('bar', 'ascii');
|
|
56
66
|
|
|
57
|
-
|
|
58
|
-
|
|
67
|
+
sha1hash.update('baz', 'ascii');
|
|
68
|
+
hash.update('baz', 'ascii');
|
|
59
69
|
|
|
60
|
-
|
|
61
|
-
|
|
70
|
+
var a = hash.digest('hex');
|
|
71
|
+
var e = sha1hash.digest('hex');
|
|
62
72
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
})
|
|
73
|
+
t.equal(a, e);
|
|
74
|
+
t.end();
|
|
75
|
+
});
|
|
66
76
|
|
|
67
77
|
tape('hex encoding', function (t) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
78
|
+
inputs.forEach(function (v) {
|
|
79
|
+
var hash = new Sha1();
|
|
80
|
+
var sha1hash = crypto.createHash('sha1');
|
|
81
|
+
|
|
82
|
+
for (var i = 0; i < v[0].length; i = (i + 1) * 2) {
|
|
83
|
+
var s = v[0].slice(i, (i + 1) * 2);
|
|
84
|
+
hash.update(Buffer.from(s, 'ascii').toString('hex'), 'hex');
|
|
85
|
+
sha1hash.update(Buffer.from(s, 'ascii').toString('hex'), 'hex');
|
|
86
|
+
}
|
|
87
|
+
var a = hash.digest('hex');
|
|
88
|
+
var e = sha1hash.digest('hex');
|
|
89
|
+
|
|
90
|
+
t.equal(a, e, a + ' == ' + e);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
t.end();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
tape('throws on invalid input', function (t) {
|
|
97
|
+
var invalid = [
|
|
98
|
+
{}, // non-arrayish
|
|
99
|
+
{ length: 20 }, // undefined values
|
|
100
|
+
[NaN], // non-numbers
|
|
101
|
+
[[]], // non-numbers
|
|
102
|
+
[1, 1.5], // non-integers
|
|
103
|
+
[1, 256], // out of bounds
|
|
104
|
+
[-1, 0] // out of bounds
|
|
105
|
+
];
|
|
106
|
+
|
|
107
|
+
invalid.forEach(function (input) {
|
|
108
|
+
var hash = new Sha1();
|
|
109
|
+
|
|
110
|
+
t['throws'](function () {
|
|
111
|
+
hash.update(input);
|
|
112
|
+
hash.digest('hex');
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
t.end();
|
|
117
|
+
});
|
|
86
118
|
|
|
87
119
|
tape('call digest for more than MAX_UINT32 bits of data', function (t) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
120
|
+
var sha1hash = crypto.createHash('sha1');
|
|
121
|
+
var hash = new Sha1();
|
|
122
|
+
var bigData;
|
|
123
|
+
try {
|
|
124
|
+
bigData = Buffer.alloc(0x1ffffffff / 8);
|
|
125
|
+
} catch (err) {
|
|
126
|
+
// node < 3 has a lower buffer size limit than node 3+. node 0.10 requires the `/8`, 0.12 - 2 are fine with `-8`
|
|
127
|
+
bigData = Buffer.alloc(0x3fffffff / 8);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
hash.update(bigData);
|
|
131
|
+
sha1hash.update(bigData);
|
|
132
|
+
|
|
133
|
+
var a = hash.digest('hex');
|
|
134
|
+
var e = sha1hash.digest('hex');
|
|
135
|
+
|
|
136
|
+
t.equal(a, e, a + ' == ' + e);
|
|
137
|
+
t.end();
|
|
138
|
+
});
|
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tape = require('tape');
|
|
4
|
+
var vectors = require('hash-test-vectors');
|
|
3
5
|
// var from = require('bops/typedarray/from')
|
|
4
|
-
var Buffer = require('safe-buffer').Buffer
|
|
6
|
+
var Buffer = require('safe-buffer').Buffer;
|
|
5
7
|
|
|
6
|
-
var createHash = require('../')
|
|
8
|
+
var createHash = require('../');
|
|
7
9
|
|
|
8
|
-
function makeTest
|
|
9
|
-
|
|
10
|
+
function makeTest(alg, i, verbose) {
|
|
11
|
+
var v = vectors[i];
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
tape(alg + ': NIST vector ' + i, function (t) {
|
|
14
|
+
if (verbose) {
|
|
15
|
+
t.comment(v);
|
|
16
|
+
t.comment('VECTOR', i);
|
|
17
|
+
t.comment('INPUT', v.input);
|
|
18
|
+
t.comment(Buffer.from(v.input, 'base64').toString('hex'));
|
|
19
|
+
}
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
var buf = Buffer.from(v.input, 'base64');
|
|
22
|
+
t.equal(createHash(alg).update(buf).digest('hex'), v[alg]);
|
|
21
23
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
// eslint-disable-next-line no-param-reassign
|
|
25
|
+
i = ~~(buf.length / 2);
|
|
26
|
+
var buf1 = buf.slice(0, i);
|
|
27
|
+
var buf2 = buf.slice(i, buf.length);
|
|
25
28
|
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
t.comment(buf1.length + ', ' + buf2.length + ', ' + buf.length);
|
|
30
|
+
t.comment(createHash(alg)._block.length);
|
|
28
31
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
t.equal(
|
|
33
|
+
createHash(alg)
|
|
34
|
+
.update(buf1)
|
|
35
|
+
.update(buf2)
|
|
36
|
+
.digest('hex'),
|
|
37
|
+
v[alg]
|
|
38
|
+
);
|
|
36
39
|
|
|
37
|
-
|
|
40
|
+
var j, buf3;
|
|
38
41
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
// eslint-disable-next-line no-param-reassign
|
|
43
|
+
i = ~~(buf.length / 3);
|
|
44
|
+
j = ~~(buf.length * 2 / 3);
|
|
45
|
+
buf1 = buf.slice(0, i);
|
|
46
|
+
buf2 = buf.slice(i, j);
|
|
47
|
+
buf3 = buf.slice(j, buf.length);
|
|
44
48
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
t.equal(
|
|
50
|
+
createHash(alg)
|
|
51
|
+
.update(buf1)
|
|
52
|
+
.update(buf2)
|
|
53
|
+
.update(buf3)
|
|
54
|
+
.digest('hex'),
|
|
55
|
+
v[alg]
|
|
56
|
+
);
|
|
53
57
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
setTimeout(function () {
|
|
59
|
+
// avoid "too much recursion" errors in tape in firefox
|
|
60
|
+
t.end();
|
|
61
|
+
});
|
|
62
|
+
});
|
|
59
63
|
}
|
|
60
64
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
makeTest('sha384', i)
|
|
70
|
-
makeTest('sha512', i)
|
|
71
|
-
})
|
|
72
|
-
}
|
|
65
|
+
vectors.forEach(function (v, i) {
|
|
66
|
+
makeTest('sha', i);
|
|
67
|
+
makeTest('sha1', i);
|
|
68
|
+
makeTest('sha224', i);
|
|
69
|
+
makeTest('sha256', i);
|
|
70
|
+
makeTest('sha384', i);
|
|
71
|
+
makeTest('sha512', i);
|
|
72
|
+
});
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "meteor-node-stubs",
|
|
3
3
|
"author": "Ben Newman <ben@meteor.com>",
|
|
4
4
|
"description": "Stub implementations of Node built-in modules, a la Browserify",
|
|
5
|
-
"version": "1.2.
|
|
5
|
+
"version": "1.2.23",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"homepage": "https://github.com/meteor/meteor/blob/devel/npm-packages/meteor-node-stubs/README.md",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"console-browserify": "^1.2.0",
|
|
19
19
|
"constants-browserify": "^1.0.0",
|
|
20
20
|
"domain-browser": "^4.23.0",
|
|
21
|
+
"elliptic": "^6.6.1",
|
|
21
22
|
"events": "^3.3.0",
|
|
22
23
|
"https-browserify": "^1.0.0",
|
|
23
24
|
"os-browserify": "^0.3.0",
|
|
@@ -26,6 +27,7 @@
|
|
|
26
27
|
"punycode": "^1.4.1",
|
|
27
28
|
"querystring-es3": "^0.2.1",
|
|
28
29
|
"readable-stream": "^3.6.2",
|
|
30
|
+
"sha.js": "^2.4.12",
|
|
29
31
|
"stream-browserify": "^3.0.0",
|
|
30
32
|
"stream-http": "^3.2.0",
|
|
31
33
|
"string_decoder": "^1.3.0",
|