meteor-node-stubs 1.2.18 → 1.2.20

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.
Files changed (49) hide show
  1. package/node_modules/@meteorjs/browserify-sign/browser/sign.js +1 -1
  2. package/node_modules/@meteorjs/browserify-sign/elliptic/README.md +238 -0
  3. package/node_modules/@meteorjs/browserify-sign/elliptic/benchmarks/deps/jodid.js +82 -0
  4. package/node_modules/@meteorjs/browserify-sign/elliptic/benchmarks/deps/secp256k1.js +41 -0
  5. package/node_modules/@meteorjs/browserify-sign/elliptic/benchmarks/index.js +153 -0
  6. package/node_modules/@meteorjs/browserify-sign/elliptic/benchmarks/package.json +21 -0
  7. package/node_modules/@meteorjs/browserify-sign/elliptic/dist/.gitkeep +0 -0
  8. package/node_modules/@meteorjs/browserify-sign/elliptic/dist/elliptic.js +8961 -0
  9. package/node_modules/@meteorjs/browserify-sign/elliptic/dist/elliptic.min.js +1 -0
  10. package/node_modules/@meteorjs/browserify-sign/elliptic/lib/elliptic/curve/base.js +381 -0
  11. package/node_modules/@meteorjs/browserify-sign/elliptic/lib/elliptic/curve/edwards.js +435 -0
  12. package/node_modules/@meteorjs/browserify-sign/elliptic/lib/elliptic/curve/index.js +8 -0
  13. package/node_modules/@meteorjs/browserify-sign/elliptic/lib/elliptic/curve/mont.js +178 -0
  14. package/node_modules/@meteorjs/browserify-sign/elliptic/lib/elliptic/curve/short.js +938 -0
  15. package/node_modules/@meteorjs/browserify-sign/elliptic/lib/elliptic/curves.js +206 -0
  16. package/node_modules/@meteorjs/browserify-sign/elliptic/lib/elliptic/ec/index.js +278 -0
  17. package/node_modules/@meteorjs/browserify-sign/elliptic/lib/elliptic/ec/key.js +121 -0
  18. package/node_modules/@meteorjs/browserify-sign/elliptic/lib/elliptic/ec/signature.js +176 -0
  19. package/node_modules/@meteorjs/browserify-sign/elliptic/lib/elliptic/eddsa/index.js +121 -0
  20. package/node_modules/@meteorjs/browserify-sign/elliptic/lib/elliptic/eddsa/key.js +95 -0
  21. package/node_modules/@meteorjs/browserify-sign/elliptic/lib/elliptic/eddsa/signature.js +66 -0
  22. package/node_modules/@meteorjs/browserify-sign/elliptic/lib/elliptic/precomputed/secp256k1.js +780 -0
  23. package/node_modules/@meteorjs/browserify-sign/elliptic/lib/elliptic/utils.js +122 -0
  24. package/node_modules/@meteorjs/browserify-sign/elliptic/lib/elliptic.js +13 -0
  25. package/node_modules/@meteorjs/browserify-sign/elliptic/test/api-test.js +20 -0
  26. package/node_modules/@meteorjs/browserify-sign/elliptic/test/curve-test.js +357 -0
  27. package/node_modules/@meteorjs/browserify-sign/elliptic/test/ecdh-test.js +43 -0
  28. package/node_modules/@meteorjs/browserify-sign/elliptic/test/ecdsa-test.js +547 -0
  29. package/node_modules/@meteorjs/browserify-sign/elliptic/test/ed25519-test.js +138 -0
  30. package/node_modules/@meteorjs/browserify-sign/elliptic/test/fixtures/derivation-fixtures.js +3842 -0
  31. package/node_modules/@meteorjs/browserify-sign/elliptic/test/fixtures/sign.input +1024 -0
  32. package/node_modules/@meteorjs/browserify-sign/elliptic/test/index.js +10 -0
  33. package/node_modules/@meteorjs/browserify-sign/elliptic/test/unittests.html +39 -0
  34. package/node_modules/@meteorjs/browserify-sign/package.json +2 -1
  35. package/node_modules/pbkdf2/.eslintrc +45 -0
  36. package/node_modules/pbkdf2/.github/FUNDING.yml +12 -0
  37. package/node_modules/pbkdf2/.nycrc +10 -0
  38. package/node_modules/pbkdf2/CHANGELOG.md +345 -0
  39. package/node_modules/pbkdf2/README.md +27 -9
  40. package/node_modules/pbkdf2/browser.js +4 -2
  41. package/node_modules/pbkdf2/index.js +30 -25
  42. package/node_modules/pbkdf2/lib/async.js +108 -104
  43. package/node_modules/pbkdf2/lib/default-encoding.js +8 -6
  44. package/node_modules/pbkdf2/lib/precondition.js +16 -14
  45. package/node_modules/pbkdf2/lib/sync-browser.js +120 -94
  46. package/node_modules/pbkdf2/lib/sync.js +59 -38
  47. package/node_modules/pbkdf2/lib/to-buffer.js +18 -11
  48. package/node_modules/pbkdf2/package.json +75 -68
  49. package/package.json +1 -1
@@ -0,0 +1,176 @@
1
+ 'use strict';
2
+
3
+ var BN = require('bn.js');
4
+
5
+ var utils = require('../utils');
6
+ var assert = utils.assert;
7
+
8
+ function Signature(options, enc) {
9
+ if (options instanceof Signature)
10
+ return options;
11
+
12
+ if (this._importDER(options, enc))
13
+ return;
14
+
15
+ assert(options.r && options.s, 'Signature without r or s');
16
+ this.r = new BN(options.r, 16);
17
+ this.s = new BN(options.s, 16);
18
+ if (options.recoveryParam === undefined)
19
+ this.recoveryParam = null;
20
+ else
21
+ this.recoveryParam = options.recoveryParam;
22
+ }
23
+ module.exports = Signature;
24
+
25
+ function Position() {
26
+ this.place = 0;
27
+ }
28
+
29
+ function getLength(buf, p) {
30
+ var initial = buf[p.place++];
31
+ if (!(initial & 0x80)) {
32
+ return initial;
33
+ }
34
+ var octetLen = initial & 0xf;
35
+
36
+ // Indefinite length or overflow
37
+ if (octetLen === 0 || octetLen > 4) {
38
+ return false;
39
+ }
40
+
41
+ if(buf[p.place] === 0x00) {
42
+ return false;
43
+ }
44
+
45
+ var val = 0;
46
+ for (var i = 0, off = p.place; i < octetLen; i++, off++) {
47
+ val <<= 8;
48
+ val |= buf[off];
49
+ val >>>= 0;
50
+ }
51
+
52
+ // Leading zeroes
53
+ if (val <= 0x7f) {
54
+ return false;
55
+ }
56
+
57
+ p.place = off;
58
+ return val;
59
+ }
60
+
61
+ function rmPadding(buf) {
62
+ var i = 0;
63
+ var len = buf.length - 1;
64
+ while (!buf[i] && !(buf[i + 1] & 0x80) && i < len) {
65
+ i++;
66
+ }
67
+ if (i === 0) {
68
+ return buf;
69
+ }
70
+ return buf.slice(i);
71
+ }
72
+
73
+ Signature.prototype._importDER = function _importDER(data, enc) {
74
+ data = utils.toArray(data, enc);
75
+ var p = new Position();
76
+ if (data[p.place++] !== 0x30) {
77
+ return false;
78
+ }
79
+ var len = getLength(data, p);
80
+ if (len === false) {
81
+ return false;
82
+ }
83
+ if ((len + p.place) !== data.length) {
84
+ return false;
85
+ }
86
+ if (data[p.place++] !== 0x02) {
87
+ return false;
88
+ }
89
+ var rlen = getLength(data, p);
90
+ if (rlen === false) {
91
+ return false;
92
+ }
93
+ if ((data[p.place] & 128) !== 0) {
94
+ return false;
95
+ }
96
+ var r = data.slice(p.place, rlen + p.place);
97
+ p.place += rlen;
98
+ if (data[p.place++] !== 0x02) {
99
+ return false;
100
+ }
101
+ var slen = getLength(data, p);
102
+ if (slen === false) {
103
+ return false;
104
+ }
105
+ if (data.length !== slen + p.place) {
106
+ return false;
107
+ }
108
+ if ((data[p.place] & 128) !== 0) {
109
+ return false;
110
+ }
111
+ var s = data.slice(p.place, slen + p.place);
112
+ if (r[0] === 0) {
113
+ if (r[1] & 0x80) {
114
+ r = r.slice(1);
115
+ } else {
116
+ // Leading zeroes
117
+ return false;
118
+ }
119
+ }
120
+ if (s[0] === 0) {
121
+ if (s[1] & 0x80) {
122
+ s = s.slice(1);
123
+ } else {
124
+ // Leading zeroes
125
+ return false;
126
+ }
127
+ }
128
+
129
+ this.r = new BN(r);
130
+ this.s = new BN(s);
131
+ this.recoveryParam = null;
132
+
133
+ return true;
134
+ };
135
+
136
+ function constructLength(arr, len) {
137
+ if (len < 0x80) {
138
+ arr.push(len);
139
+ return;
140
+ }
141
+ var octets = 1 + (Math.log(len) / Math.LN2 >>> 3);
142
+ arr.push(octets | 0x80);
143
+ while (--octets) {
144
+ arr.push((len >>> (octets << 3)) & 0xff);
145
+ }
146
+ arr.push(len);
147
+ }
148
+
149
+ Signature.prototype.toDER = function toDER(enc) {
150
+ var r = this.r.toArray();
151
+ var s = this.s.toArray();
152
+
153
+ // Pad values
154
+ if (r[0] & 0x80)
155
+ r = [ 0 ].concat(r);
156
+ // Pad values
157
+ if (s[0] & 0x80)
158
+ s = [ 0 ].concat(s);
159
+
160
+ r = rmPadding(r);
161
+ s = rmPadding(s);
162
+
163
+ while (!s[0] && !(s[1] & 0x80)) {
164
+ s = s.slice(1);
165
+ }
166
+ var arr = [ 0x02 ];
167
+ constructLength(arr, r.length);
168
+ arr = arr.concat(r);
169
+ arr.push(0x02);
170
+ constructLength(arr, s.length);
171
+ var backHalf = arr.concat(s);
172
+ var res = [ 0x30 ];
173
+ constructLength(res, backHalf.length);
174
+ res = res.concat(backHalf);
175
+ return utils.encode(res, enc);
176
+ };
@@ -0,0 +1,121 @@
1
+ 'use strict';
2
+
3
+ var hash = require('hash.js');
4
+ var curves = require('../curves');
5
+ var utils = require('../utils');
6
+ var assert = utils.assert;
7
+ var parseBytes = utils.parseBytes;
8
+ var KeyPair = require('./key');
9
+ var Signature = require('./signature');
10
+
11
+ function EDDSA(curve) {
12
+ assert(curve === 'ed25519', 'only tested with ed25519 so far');
13
+
14
+ if (!(this instanceof EDDSA))
15
+ return new EDDSA(curve);
16
+
17
+ curve = curves[curve].curve;
18
+ this.curve = curve;
19
+ this.g = curve.g;
20
+ this.g.precompute(curve.n.bitLength() + 1);
21
+
22
+ this.pointClass = curve.point().constructor;
23
+ this.encodingLength = Math.ceil(curve.n.bitLength() / 8);
24
+ this.hash = hash.sha512;
25
+ }
26
+
27
+ module.exports = EDDSA;
28
+
29
+ /**
30
+ * @param {Array|String} message - message bytes
31
+ * @param {Array|String|KeyPair} secret - secret bytes or a keypair
32
+ * @returns {Signature} - signature
33
+ */
34
+ EDDSA.prototype.sign = function sign(message, secret) {
35
+ message = parseBytes(message);
36
+ var key = this.keyFromSecret(secret);
37
+ var r = this.hashInt(key.messagePrefix(), message);
38
+ var R = this.g.mul(r);
39
+ var Rencoded = this.encodePoint(R);
40
+ var s_ = this.hashInt(Rencoded, key.pubBytes(), message)
41
+ .mul(key.priv());
42
+ var S = r.add(s_).umod(this.curve.n);
43
+ return this.makeSignature({ R: R, S: S, Rencoded: Rencoded });
44
+ };
45
+
46
+ /**
47
+ * @param {Array} message - message bytes
48
+ * @param {Array|String|Signature} sig - sig bytes
49
+ * @param {Array|String|Point|KeyPair} pub - public key
50
+ * @returns {Boolean} - true if public key matches sig of message
51
+ */
52
+ EDDSA.prototype.verify = function verify(message, sig, pub) {
53
+ message = parseBytes(message);
54
+ sig = this.makeSignature(sig);
55
+ if (sig.S().gte(sig.eddsa.curve.n) || sig.S().isNeg()) {
56
+ return false;
57
+ }
58
+ var key = this.keyFromPublic(pub);
59
+ var h = this.hashInt(sig.Rencoded(), key.pubBytes(), message);
60
+ var SG = this.g.mul(sig.S());
61
+ var RplusAh = sig.R().add(key.pub().mul(h));
62
+ return RplusAh.eq(SG);
63
+ };
64
+
65
+ EDDSA.prototype.hashInt = function hashInt() {
66
+ var hash = this.hash();
67
+ for (var i = 0; i < arguments.length; i++)
68
+ hash.update(arguments[i]);
69
+ return utils.intFromLE(hash.digest()).umod(this.curve.n);
70
+ };
71
+
72
+ EDDSA.prototype.keyFromPublic = function keyFromPublic(pub) {
73
+ return KeyPair.fromPublic(this, pub);
74
+ };
75
+
76
+ EDDSA.prototype.keyFromSecret = function keyFromSecret(secret) {
77
+ return KeyPair.fromSecret(this, secret);
78
+ };
79
+
80
+ EDDSA.prototype.makeSignature = function makeSignature(sig) {
81
+ if (sig instanceof Signature)
82
+ return sig;
83
+ return new Signature(this, sig);
84
+ };
85
+
86
+ /**
87
+ * * https://tools.ietf.org/html/draft-josefsson-eddsa-ed25519-03#section-5.2
88
+ *
89
+ * EDDSA defines methods for encoding and decoding points and integers. These are
90
+ * helper convenience methods, that pass along to utility functions implied
91
+ * parameters.
92
+ *
93
+ */
94
+ EDDSA.prototype.encodePoint = function encodePoint(point) {
95
+ var enc = point.getY().toArray('le', this.encodingLength);
96
+ enc[this.encodingLength - 1] |= point.getX().isOdd() ? 0x80 : 0;
97
+ return enc;
98
+ };
99
+
100
+ EDDSA.prototype.decodePoint = function decodePoint(bytes) {
101
+ bytes = utils.parseBytes(bytes);
102
+
103
+ var lastIx = bytes.length - 1;
104
+ var normed = bytes.slice(0, lastIx).concat(bytes[lastIx] & ~0x80);
105
+ var xIsOdd = (bytes[lastIx] & 0x80) !== 0;
106
+
107
+ var y = utils.intFromLE(normed);
108
+ return this.curve.pointFromY(y, xIsOdd);
109
+ };
110
+
111
+ EDDSA.prototype.encodeInt = function encodeInt(num) {
112
+ return num.toArray('le', this.encodingLength);
113
+ };
114
+
115
+ EDDSA.prototype.decodeInt = function decodeInt(bytes) {
116
+ return utils.intFromLE(bytes);
117
+ };
118
+
119
+ EDDSA.prototype.isPoint = function isPoint(val) {
120
+ return val instanceof this.pointClass;
121
+ };
@@ -0,0 +1,95 @@
1
+ 'use strict';
2
+
3
+ var utils = require('../utils');
4
+ var assert = utils.assert;
5
+ var parseBytes = utils.parseBytes;
6
+ var cachedProperty = utils.cachedProperty;
7
+
8
+ /**
9
+ * @param {EDDSA} eddsa - instance
10
+ * @param {Object} params - public/private key parameters
11
+ *
12
+ * @param {Array<Byte>} [params.secret] - secret seed bytes
13
+ * @param {Point} [params.pub] - public key point (aka `A` in eddsa terms)
14
+ * @param {Array<Byte>} [params.pub] - public key point encoded as bytes
15
+ *
16
+ */
17
+ function KeyPair(eddsa, params) {
18
+ this.eddsa = eddsa;
19
+ this._secret = parseBytes(params.secret);
20
+ if (eddsa.isPoint(params.pub))
21
+ this._pub = params.pub;
22
+ else
23
+ this._pubBytes = parseBytes(params.pub);
24
+ }
25
+
26
+ KeyPair.fromPublic = function fromPublic(eddsa, pub) {
27
+ if (pub instanceof KeyPair)
28
+ return pub;
29
+ return new KeyPair(eddsa, { pub: pub });
30
+ };
31
+
32
+ KeyPair.fromSecret = function fromSecret(eddsa, secret) {
33
+ if (secret instanceof KeyPair)
34
+ return secret;
35
+ return new KeyPair(eddsa, { secret: secret });
36
+ };
37
+
38
+ KeyPair.prototype.secret = function secret() {
39
+ return this._secret;
40
+ };
41
+
42
+ cachedProperty(KeyPair, 'pubBytes', function pubBytes() {
43
+ return this.eddsa.encodePoint(this.pub());
44
+ });
45
+
46
+ cachedProperty(KeyPair, 'pub', function pub() {
47
+ if (this._pubBytes)
48
+ return this.eddsa.decodePoint(this._pubBytes);
49
+ return this.eddsa.g.mul(this.priv());
50
+ });
51
+
52
+ cachedProperty(KeyPair, 'privBytes', function privBytes() {
53
+ var eddsa = this.eddsa;
54
+ var hash = this.hash();
55
+ var lastIx = eddsa.encodingLength - 1;
56
+
57
+ var a = hash.slice(0, eddsa.encodingLength);
58
+ a[0] &= 248;
59
+ a[lastIx] &= 127;
60
+ a[lastIx] |= 64;
61
+
62
+ return a;
63
+ });
64
+
65
+ cachedProperty(KeyPair, 'priv', function priv() {
66
+ return this.eddsa.decodeInt(this.privBytes());
67
+ });
68
+
69
+ cachedProperty(KeyPair, 'hash', function hash() {
70
+ return this.eddsa.hash().update(this.secret()).digest();
71
+ });
72
+
73
+ cachedProperty(KeyPair, 'messagePrefix', function messagePrefix() {
74
+ return this.hash().slice(this.eddsa.encodingLength);
75
+ });
76
+
77
+ KeyPair.prototype.sign = function sign(message) {
78
+ assert(this._secret, 'KeyPair can only verify');
79
+ return this.eddsa.sign(message, this);
80
+ };
81
+
82
+ KeyPair.prototype.verify = function verify(message, sig) {
83
+ return this.eddsa.verify(message, sig, this);
84
+ };
85
+
86
+ KeyPair.prototype.getSecret = function getSecret(enc) {
87
+ assert(this._secret, 'KeyPair is public only');
88
+ return utils.encode(this.secret(), enc);
89
+ };
90
+
91
+ KeyPair.prototype.getPublic = function getPublic(enc) {
92
+ return utils.encode(this.pubBytes(), enc);
93
+ };
94
+
95
+ module.exports = KeyPair;
@@ -0,0 +1,66 @@
1
+ 'use strict';
2
+
3
+ var BN = require('bn.js');
4
+ var utils = require('../utils');
5
+ var assert = utils.assert;
6
+ var cachedProperty = utils.cachedProperty;
7
+ var parseBytes = utils.parseBytes;
8
+
9
+ /**
10
+ * @param {EDDSA} eddsa - eddsa instance
11
+ * @param {Array<Bytes>|Object} sig -
12
+ * @param {Array<Bytes>|Point} [sig.R] - R point as Point or bytes
13
+ * @param {Array<Bytes>|bn} [sig.S] - S scalar as bn or bytes
14
+ * @param {Array<Bytes>} [sig.Rencoded] - R point encoded
15
+ * @param {Array<Bytes>} [sig.Sencoded] - S scalar encoded
16
+ */
17
+ function Signature(eddsa, sig) {
18
+ this.eddsa = eddsa;
19
+
20
+ if (typeof sig !== 'object')
21
+ sig = parseBytes(sig);
22
+
23
+ if (Array.isArray(sig)) {
24
+ assert(sig.length === eddsa.encodingLength * 2, 'Signature has invalid size');
25
+ sig = {
26
+ R: sig.slice(0, eddsa.encodingLength),
27
+ S: sig.slice(eddsa.encodingLength),
28
+ };
29
+ }
30
+
31
+ assert(sig.R && sig.S, 'Signature without R or S');
32
+
33
+ if (eddsa.isPoint(sig.R))
34
+ this._R = sig.R;
35
+ if (sig.S instanceof BN)
36
+ this._S = sig.S;
37
+
38
+ this._Rencoded = Array.isArray(sig.R) ? sig.R : sig.Rencoded;
39
+ this._Sencoded = Array.isArray(sig.S) ? sig.S : sig.Sencoded;
40
+ }
41
+
42
+ cachedProperty(Signature, 'S', function S() {
43
+ return this.eddsa.decodeInt(this.Sencoded());
44
+ });
45
+
46
+ cachedProperty(Signature, 'R', function R() {
47
+ return this.eddsa.decodePoint(this.Rencoded());
48
+ });
49
+
50
+ cachedProperty(Signature, 'Rencoded', function Rencoded() {
51
+ return this.eddsa.encodePoint(this.R());
52
+ });
53
+
54
+ cachedProperty(Signature, 'Sencoded', function Sencoded() {
55
+ return this.eddsa.encodeInt(this.S());
56
+ });
57
+
58
+ Signature.prototype.toBytes = function toBytes() {
59
+ return this.Rencoded().concat(this.Sencoded());
60
+ };
61
+
62
+ Signature.prototype.toHex = function toHex() {
63
+ return utils.encode(this.toBytes(), 'hex').toUpperCase();
64
+ };
65
+
66
+ module.exports = Signature;