@mjhls/mjh-framework 1.0.811 → 1.0.812

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.
@@ -9855,6 +9855,8 @@ var MediaSeriesLanding = function MediaSeriesLanding(props) {
9855
9855
 
9856
9856
  MediaSeriesLanding.getInitialData = function () {
9857
9857
  var _ref3 = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee2(ctx, client, cache) {
9858
+ var _ref4;
9859
+
9858
9860
  var urlQuery, pathname, identifier, itemsPerPage, currentPage, start, statusCode, params, docGroupID, seriesQuery, seriesData, allSeries, buildUsedTopicsArray, usedTopics, taxonomyFilter;
9859
9861
  return asyncToGenerator.regenerator.wrap(function _callee2$(_context2) {
9860
9862
  while (1) {
@@ -9873,11 +9875,11 @@ MediaSeriesLanding.getInitialData = function () {
9873
9875
  url: pathname
9874
9876
  };
9875
9877
  _context2.next = 9;
9876
- return client.fetch('*[_type == \'documentGroup\' && identifier.current == \'' + identifier + '\'][0]{\n _id, \n name\n }');
9878
+ return client.fetch('*[_type == \'documentGroup\' && identifier.current == \'' + identifier + '\'][0]{\n _id, \n isGated,\n name\n }');
9877
9879
 
9878
9880
  case 9:
9879
9881
  docGroupID = _context2.sent;
9880
- seriesQuery = '*[_type == \'documentGroup\' && references(\'' + docGroupID._id + '\') && isSeries != false && isShow != false && defined(published) && dateTime(published) <= dateTime(now()) ] | order(published desc) [$from...$to] {\n _id,\n name,\n identifier,\n published,\n thumbnail,\n description,\n topicMapping[]->,\n \'pageNumber\': ' + currentPage + ',\n \'parentUrl\': \'' + identifier + '\'\n }';
9882
+ seriesQuery = '*[_type == \'documentGroup\' && references(\'' + docGroupID._id + '\') && isSeries != false && isShow != false && defined(published) && dateTime(published) <= dateTime(now()) ] | order(published desc) [$from...$to] {\n _id,\n name,\n identifier,\n published,\n thumbnail,\n description,\n topicMapping[]->,\n isGated,\n \'pageNumber\': ' + currentPage + ',\n \'parentUrl\': \'' + identifier + '\'\n }';
9881
9883
  _context2.next = 13;
9882
9884
  return client.fetch(seriesQuery, params);
9883
9885
 
@@ -9939,17 +9941,7 @@ MediaSeriesLanding.getInitialData = function () {
9939
9941
  statusCode = 404;
9940
9942
  }
9941
9943
 
9942
- return _context2.abrupt('return', defineProperty._defineProperty({
9943
- seriesData: seriesData,
9944
- query: seriesQuery,
9945
- params: params,
9946
- currentPage: currentPage,
9947
- taxonomyFilter: taxonomyFilter,
9948
- identifier: identifier,
9949
- docGroupID: docGroupID._id,
9950
- parentUrl: identifier,
9951
- statusCode: statusCode
9952
- }, 'taxonomyFilter', taxonomyFilter));
9944
+ return _context2.abrupt('return', (_ref4 = { seriesData: seriesData, query: seriesQuery, params: params, currentPage: currentPage, taxonomyFilter: taxonomyFilter, identifier: identifier, docGroupID: docGroupID._id, parentUrl: identifier, statusCode: statusCode }, defineProperty._defineProperty(_ref4, 'taxonomyFilter', taxonomyFilter), defineProperty._defineProperty(_ref4, 'docGroup', docGroupID), _ref4));
9953
9945
 
9954
9946
  case 25:
9955
9947
  case 'end':
@@ -0,0 +1,329 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var asyncToGenerator = require('./asyncToGenerator-58c289d9.js');
6
+ var md5 = require('./md5-e1ca5797.js');
7
+ require('./_commonjsHelpers-06173234.js');
8
+ require('./es6.string.iterator-c2573ffd.js');
9
+ require('./_to-object-6de10e57.js');
10
+ require('./web.dom.iterable-46657b5c.js');
11
+ require('./_library-dd23b178.js');
12
+ require('./core.get-iterator-method-f474eacc.js');
13
+ require('./_iter-detect-55a5657a.js');
14
+
15
+ var encrypt = function () {
16
+ var _ref = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee(password) {
17
+ var hash;
18
+ return asyncToGenerator.regenerator.wrap(function _callee$(_context) {
19
+ while (1) {
20
+ switch (_context.prev = _context.next) {
21
+ case 0:
22
+ hash = md5.md5(password);
23
+ return _context.abrupt('return', hash);
24
+
25
+ case 2:
26
+ case 'end':
27
+ return _context.stop();
28
+ }
29
+ }
30
+ }, _callee, this);
31
+ }));
32
+
33
+ return function encrypt(_x) {
34
+ return _ref.apply(this, arguments);
35
+ };
36
+ }();
37
+
38
+ var comparePassword = function () {
39
+ var _ref2 = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee2(plainTextPassword, hashedPassword) {
40
+ var hash;
41
+ return asyncToGenerator.regenerator.wrap(function _callee2$(_context2) {
42
+ while (1) {
43
+ switch (_context2.prev = _context2.next) {
44
+ case 0:
45
+ hash = md5.md5(plainTextPassword);
46
+ return _context2.abrupt('return', hash === hashedPassword);
47
+
48
+ case 2:
49
+ case 'end':
50
+ return _context2.stop();
51
+ }
52
+ }
53
+ }, _callee2, this);
54
+ }));
55
+
56
+ return function comparePassword(_x2, _x3) {
57
+ return _ref2.apply(this, arguments);
58
+ };
59
+ }();
60
+
61
+ var faunadb = require('faunadb'),
62
+ q = faunadb.query;
63
+
64
+ var registerUser = function () {
65
+ var _ref = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee(body) {
66
+ var secret = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'fnAEG3Bb7AACAC0BiSQFYGBLFUtHjn3QOTKE1iBX';
67
+ var data, client, hashedPassword, result;
68
+ return asyncToGenerator.regenerator.wrap(function _callee$(_context) {
69
+ while (1) {
70
+ switch (_context.prev = _context.next) {
71
+ case 0:
72
+ _context.prev = 0;
73
+ data = body;
74
+
75
+ if (secret) {
76
+ _context.next = 4;
77
+ break;
78
+ }
79
+
80
+ throw new Error('Missing secret key');
81
+
82
+ case 4:
83
+ client = new faunadb.Client({ secret: secret });
84
+ _context.next = 7;
85
+ return encrypt(data.Password);
86
+
87
+ case 7:
88
+ hashedPassword = _context.sent;
89
+
90
+ data.Password = hashedPassword;
91
+
92
+ _context.next = 11;
93
+ return client.query(q.Create(q.Collection('Users'), {
94
+ data: data
95
+ }));
96
+
97
+ case 11:
98
+ result = _context.sent;
99
+
100
+ if (!(!result || !result.data || result.data.Email != data.Email)) {
101
+ _context.next = 14;
102
+ break;
103
+ }
104
+
105
+ throw new Error('Failed to register!');
106
+
107
+ case 14:
108
+ return _context.abrupt('return', result);
109
+
110
+ case 17:
111
+ _context.prev = 17;
112
+ _context.t0 = _context['catch'](0);
113
+ return _context.abrupt('return', { error: _context.t0.message });
114
+
115
+ case 20:
116
+ case 'end':
117
+ return _context.stop();
118
+ }
119
+ }
120
+ }, _callee, this, [[0, 17]]);
121
+ }));
122
+
123
+ return function registerUser(_x) {
124
+ return _ref.apply(this, arguments);
125
+ };
126
+ }();
127
+
128
+ var findUserByEmail = function () {
129
+ var _ref2 = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee2(email) {
130
+ var secret = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'fnAEG3Bb7AACAC0BiSQFYGBLFUtHjn3QOTKE1iBX';
131
+ var client, result;
132
+ return asyncToGenerator.regenerator.wrap(function _callee2$(_context2) {
133
+ while (1) {
134
+ switch (_context2.prev = _context2.next) {
135
+ case 0:
136
+ _context2.prev = 0;
137
+ client = new faunadb.Client({ secret: secret });
138
+ _context2.next = 4;
139
+ return client.query(q.Get(q.Match(q.Index('Email'), email)));
140
+
141
+ case 4:
142
+ result = _context2.sent;
143
+ return _context2.abrupt('return', result ? true : false);
144
+
145
+ case 8:
146
+ _context2.prev = 8;
147
+ _context2.t0 = _context2['catch'](0);
148
+ return _context2.abrupt('return', false);
149
+
150
+ case 11:
151
+ case 'end':
152
+ return _context2.stop();
153
+ }
154
+ }
155
+ }, _callee2, this, [[0, 8]]);
156
+ }));
157
+
158
+ return function findUserByEmail(_x3) {
159
+ return _ref2.apply(this, arguments);
160
+ };
161
+ }();
162
+
163
+ var authenticateUser = function () {
164
+ var _ref3 = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee3(email, password) {
165
+ var secret = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'fnAEG3Bb7AACAC0BiSQFYGBLFUtHjn3QOTKE1iBX';
166
+ var client, result, hashedPassword, isAuth;
167
+ return asyncToGenerator.regenerator.wrap(function _callee3$(_context3) {
168
+ while (1) {
169
+ switch (_context3.prev = _context3.next) {
170
+ case 0:
171
+ _context3.prev = 0;
172
+ client = new faunadb.Client({ secret: secret });
173
+ _context3.next = 4;
174
+ return client.query(q.Get(q.Match(q.Index('Email'), email)));
175
+
176
+ case 4:
177
+ result = _context3.sent;
178
+ hashedPassword = result.data.Password;
179
+ _context3.next = 8;
180
+ return comparePassword(password, hashedPassword);
181
+
182
+ case 8:
183
+ isAuth = _context3.sent;
184
+ return _context3.abrupt('return', isAuth ? { email: email } : false);
185
+
186
+ case 12:
187
+ _context3.prev = 12;
188
+ _context3.t0 = _context3['catch'](0);
189
+
190
+ console.log(_context3.t0);
191
+ return _context3.abrupt('return', false);
192
+
193
+ case 16:
194
+ case 'end':
195
+ return _context3.stop();
196
+ }
197
+ }
198
+ }, _callee3, this, [[0, 12]]);
199
+ }));
200
+
201
+ return function authenticateUser(_x5, _x6) {
202
+ return _ref3.apply(this, arguments);
203
+ };
204
+ }();
205
+
206
+ var updateUserSecret = function () {
207
+ var _ref4 = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee4(email, hash) {
208
+ var secret = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'fnAEG3Bb7AACAC0BiSQFYGBLFUtHjn3QOTKE1iBX';
209
+ var expiration, client, result;
210
+ return asyncToGenerator.regenerator.wrap(function _callee4$(_context4) {
211
+ while (1) {
212
+ switch (_context4.prev = _context4.next) {
213
+ case 0:
214
+ expiration = new Date().getTime() + 43200000; //1day
215
+
216
+ _context4.prev = 1;
217
+
218
+ console.log(email, hash, expiration);
219
+ client = new faunadb.Client({ secret: secret });
220
+ _context4.next = 6;
221
+ return client.query(q.Update(q.Select(['ref'], q.Get(q.Match(q.Index('Email'), email))), { data: { secretKey: hash, secretExpiration: expiration } }));
222
+
223
+ case 6:
224
+ result = _context4.sent;
225
+ return _context4.abrupt('return', result ? true : false);
226
+
227
+ case 10:
228
+ _context4.prev = 10;
229
+ _context4.t0 = _context4['catch'](1);
230
+
231
+ console.log(_context4.t0);
232
+ return _context4.abrupt('return', false);
233
+
234
+ case 14:
235
+ case 'end':
236
+ return _context4.stop();
237
+ }
238
+ }
239
+ }, _callee4, this, [[1, 10]]);
240
+ }));
241
+
242
+ return function updateUserSecret(_x8, _x9) {
243
+ return _ref4.apply(this, arguments);
244
+ };
245
+ }();
246
+
247
+ var updateUserPassword = function () {
248
+ var _ref5 = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee5(hash, newPassword) {
249
+ var secret = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'fnAEG3Bb7AACAC0BiSQFYGBLFUtHjn3QOTKE1iBX';
250
+ var now, client, result, expiration, password, updatePassword;
251
+ return asyncToGenerator.regenerator.wrap(function _callee5$(_context5) {
252
+ while (1) {
253
+ switch (_context5.prev = _context5.next) {
254
+ case 0:
255
+ _context5.prev = 0;
256
+ now = Date.now();
257
+ client = new faunadb.Client({ secret: secret });
258
+ _context5.next = 5;
259
+ return client.query(q.Get(q.Match(q.Index('SecretKey'), hash)));
260
+
261
+ case 5:
262
+ result = _context5.sent;
263
+ expiration = result.data.secretExpiration;
264
+
265
+ if (!(now > expiration)) {
266
+ _context5.next = 9;
267
+ break;
268
+ }
269
+
270
+ throw new Error('eKey has expired.');
271
+
272
+ case 9:
273
+ if (!(now < expiration)) {
274
+ _context5.next = 18;
275
+ break;
276
+ }
277
+
278
+ _context5.next = 12;
279
+ return encrypt(newPassword);
280
+
281
+ case 12:
282
+ password = _context5.sent;
283
+ _context5.next = 15;
284
+ return client.query(q.Update(q.Select(['ref'], q.Get(q.Match(q.Index('SecretKey'), hash))), { data: { Password: password, secretKey: '' } }));
285
+
286
+ case 15:
287
+ updatePassword = _context5.sent;
288
+
289
+ if (updatePassword) {
290
+ _context5.next = 18;
291
+ break;
292
+ }
293
+
294
+ throw new Error('Failed to update password.');
295
+
296
+ case 18:
297
+ if (!(!result || result.error)) {
298
+ _context5.next = 20;
299
+ break;
300
+ }
301
+
302
+ throw new Error('User not found');
303
+
304
+ case 20:
305
+ return _context5.abrupt('return', true);
306
+
307
+ case 23:
308
+ _context5.prev = 23;
309
+ _context5.t0 = _context5['catch'](0);
310
+ return _context5.abrupt('return', { err: _context5.t0 });
311
+
312
+ case 26:
313
+ case 'end':
314
+ return _context5.stop();
315
+ }
316
+ }
317
+ }, _callee5, this, [[0, 23]]);
318
+ }));
319
+
320
+ return function updateUserPassword(_x11, _x12) {
321
+ return _ref5.apply(this, arguments);
322
+ };
323
+ }();
324
+
325
+ exports.authenticateUser = authenticateUser;
326
+ exports.findUserByEmail = findUserByEmail;
327
+ exports.registerUser = registerUser;
328
+ exports.updateUserPassword = updateUserPassword;
329
+ exports.updateUserSecret = updateUserSecret;
package/dist/cjs/index.js CHANGED
@@ -187,6 +187,7 @@ require('./index-bd6c9f56.js');
187
187
  require('swr');
188
188
  require('passport-local');
189
189
  require('mysql');
190
+ require('./md5-e1ca5797.js');
190
191
  require('./SeriesSlider-2db54929.js');
191
192
  require('./style-inject.es-dcee06b6.js');
192
193
  require('disqus-react');
@@ -0,0 +1,323 @@
1
+ 'use strict';
2
+
3
+ var _commonjsHelpers = require('./_commonjsHelpers-06173234.js');
4
+
5
+ var crypt = _commonjsHelpers.createCommonjsModule(function (module) {
6
+ (function() {
7
+ var base64map
8
+ = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
9
+
10
+ crypt = {
11
+ // Bit-wise rotation left
12
+ rotl: function(n, b) {
13
+ return (n << b) | (n >>> (32 - b));
14
+ },
15
+
16
+ // Bit-wise rotation right
17
+ rotr: function(n, b) {
18
+ return (n << (32 - b)) | (n >>> b);
19
+ },
20
+
21
+ // Swap big-endian to little-endian and vice versa
22
+ endian: function(n) {
23
+ // If number given, swap endian
24
+ if (n.constructor == Number) {
25
+ return crypt.rotl(n, 8) & 0x00FF00FF | crypt.rotl(n, 24) & 0xFF00FF00;
26
+ }
27
+
28
+ // Else, assume array and swap all items
29
+ for (var i = 0; i < n.length; i++)
30
+ n[i] = crypt.endian(n[i]);
31
+ return n;
32
+ },
33
+
34
+ // Generate an array of any length of random bytes
35
+ randomBytes: function(n) {
36
+ for (var bytes = []; n > 0; n--)
37
+ bytes.push(Math.floor(Math.random() * 256));
38
+ return bytes;
39
+ },
40
+
41
+ // Convert a byte array to big-endian 32-bit words
42
+ bytesToWords: function(bytes) {
43
+ for (var words = [], i = 0, b = 0; i < bytes.length; i++, b += 8)
44
+ words[b >>> 5] |= bytes[i] << (24 - b % 32);
45
+ return words;
46
+ },
47
+
48
+ // Convert big-endian 32-bit words to a byte array
49
+ wordsToBytes: function(words) {
50
+ for (var bytes = [], b = 0; b < words.length * 32; b += 8)
51
+ bytes.push((words[b >>> 5] >>> (24 - b % 32)) & 0xFF);
52
+ return bytes;
53
+ },
54
+
55
+ // Convert a byte array to a hex string
56
+ bytesToHex: function(bytes) {
57
+ for (var hex = [], i = 0; i < bytes.length; i++) {
58
+ hex.push((bytes[i] >>> 4).toString(16));
59
+ hex.push((bytes[i] & 0xF).toString(16));
60
+ }
61
+ return hex.join('');
62
+ },
63
+
64
+ // Convert a hex string to a byte array
65
+ hexToBytes: function(hex) {
66
+ for (var bytes = [], c = 0; c < hex.length; c += 2)
67
+ bytes.push(parseInt(hex.substr(c, 2), 16));
68
+ return bytes;
69
+ },
70
+
71
+ // Convert a byte array to a base-64 string
72
+ bytesToBase64: function(bytes) {
73
+ for (var base64 = [], i = 0; i < bytes.length; i += 3) {
74
+ var triplet = (bytes[i] << 16) | (bytes[i + 1] << 8) | bytes[i + 2];
75
+ for (var j = 0; j < 4; j++)
76
+ if (i * 8 + j * 6 <= bytes.length * 8)
77
+ base64.push(base64map.charAt((triplet >>> 6 * (3 - j)) & 0x3F));
78
+ else
79
+ base64.push('=');
80
+ }
81
+ return base64.join('');
82
+ },
83
+
84
+ // Convert a base-64 string to a byte array
85
+ base64ToBytes: function(base64) {
86
+ // Remove non-base-64 characters
87
+ base64 = base64.replace(/[^A-Z0-9+\/]/ig, '');
88
+
89
+ for (var bytes = [], i = 0, imod4 = 0; i < base64.length;
90
+ imod4 = ++i % 4) {
91
+ if (imod4 == 0) continue;
92
+ bytes.push(((base64map.indexOf(base64.charAt(i - 1))
93
+ & (Math.pow(2, -2 * imod4 + 8) - 1)) << (imod4 * 2))
94
+ | (base64map.indexOf(base64.charAt(i)) >>> (6 - imod4 * 2)));
95
+ }
96
+ return bytes;
97
+ }
98
+ };
99
+
100
+ module.exports = crypt;
101
+ })();
102
+ });
103
+
104
+ var charenc = {
105
+ // UTF-8 encoding
106
+ utf8: {
107
+ // Convert a string to a byte array
108
+ stringToBytes: function(str) {
109
+ return charenc.bin.stringToBytes(unescape(encodeURIComponent(str)));
110
+ },
111
+
112
+ // Convert a byte array to a string
113
+ bytesToString: function(bytes) {
114
+ return decodeURIComponent(escape(charenc.bin.bytesToString(bytes)));
115
+ }
116
+ },
117
+
118
+ // Binary encoding
119
+ bin: {
120
+ // Convert a string to a byte array
121
+ stringToBytes: function(str) {
122
+ for (var bytes = [], i = 0; i < str.length; i++)
123
+ bytes.push(str.charCodeAt(i) & 0xFF);
124
+ return bytes;
125
+ },
126
+
127
+ // Convert a byte array to a string
128
+ bytesToString: function(bytes) {
129
+ for (var str = [], i = 0; i < bytes.length; i++)
130
+ str.push(String.fromCharCode(bytes[i]));
131
+ return str.join('');
132
+ }
133
+ }
134
+ };
135
+
136
+ var charenc_1 = charenc;
137
+
138
+ /*!
139
+ * Determine if an object is a Buffer
140
+ *
141
+ * @author Feross Aboukhadijeh <https://feross.org>
142
+ * @license MIT
143
+ */
144
+
145
+ // The _isBuffer check is for Safari 5-7 support, because it's missing
146
+ // Object.prototype.constructor. Remove this eventually
147
+ var isBuffer_1 = function (obj) {
148
+ return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
149
+ };
150
+
151
+ function isBuffer (obj) {
152
+ return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
153
+ }
154
+
155
+ // For Node v0.10 support. Remove this eventually.
156
+ function isSlowBuffer (obj) {
157
+ return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
158
+ }
159
+
160
+ var md5 = _commonjsHelpers.createCommonjsModule(function (module) {
161
+ (function(){
162
+ var crypt$1 = crypt,
163
+ utf8 = charenc_1.utf8,
164
+ isBuffer = isBuffer_1,
165
+ bin = charenc_1.bin,
166
+
167
+ // The core
168
+ md5 = function (message, options) {
169
+ // Convert to byte array
170
+ if (message.constructor == String)
171
+ if (options && options.encoding === 'binary')
172
+ message = bin.stringToBytes(message);
173
+ else
174
+ message = utf8.stringToBytes(message);
175
+ else if (isBuffer(message))
176
+ message = Array.prototype.slice.call(message, 0);
177
+ else if (!Array.isArray(message) && message.constructor !== Uint8Array)
178
+ message = message.toString();
179
+ // else, assume byte array already
180
+
181
+ var m = crypt$1.bytesToWords(message),
182
+ l = message.length * 8,
183
+ a = 1732584193,
184
+ b = -271733879,
185
+ c = -1732584194,
186
+ d = 271733878;
187
+
188
+ // Swap endian
189
+ for (var i = 0; i < m.length; i++) {
190
+ m[i] = ((m[i] << 8) | (m[i] >>> 24)) & 0x00FF00FF |
191
+ ((m[i] << 24) | (m[i] >>> 8)) & 0xFF00FF00;
192
+ }
193
+
194
+ // Padding
195
+ m[l >>> 5] |= 0x80 << (l % 32);
196
+ m[(((l + 64) >>> 9) << 4) + 14] = l;
197
+
198
+ // Method shortcuts
199
+ var FF = md5._ff,
200
+ GG = md5._gg,
201
+ HH = md5._hh,
202
+ II = md5._ii;
203
+
204
+ for (var i = 0; i < m.length; i += 16) {
205
+
206
+ var aa = a,
207
+ bb = b,
208
+ cc = c,
209
+ dd = d;
210
+
211
+ a = FF(a, b, c, d, m[i+ 0], 7, -680876936);
212
+ d = FF(d, a, b, c, m[i+ 1], 12, -389564586);
213
+ c = FF(c, d, a, b, m[i+ 2], 17, 606105819);
214
+ b = FF(b, c, d, a, m[i+ 3], 22, -1044525330);
215
+ a = FF(a, b, c, d, m[i+ 4], 7, -176418897);
216
+ d = FF(d, a, b, c, m[i+ 5], 12, 1200080426);
217
+ c = FF(c, d, a, b, m[i+ 6], 17, -1473231341);
218
+ b = FF(b, c, d, a, m[i+ 7], 22, -45705983);
219
+ a = FF(a, b, c, d, m[i+ 8], 7, 1770035416);
220
+ d = FF(d, a, b, c, m[i+ 9], 12, -1958414417);
221
+ c = FF(c, d, a, b, m[i+10], 17, -42063);
222
+ b = FF(b, c, d, a, m[i+11], 22, -1990404162);
223
+ a = FF(a, b, c, d, m[i+12], 7, 1804603682);
224
+ d = FF(d, a, b, c, m[i+13], 12, -40341101);
225
+ c = FF(c, d, a, b, m[i+14], 17, -1502002290);
226
+ b = FF(b, c, d, a, m[i+15], 22, 1236535329);
227
+
228
+ a = GG(a, b, c, d, m[i+ 1], 5, -165796510);
229
+ d = GG(d, a, b, c, m[i+ 6], 9, -1069501632);
230
+ c = GG(c, d, a, b, m[i+11], 14, 643717713);
231
+ b = GG(b, c, d, a, m[i+ 0], 20, -373897302);
232
+ a = GG(a, b, c, d, m[i+ 5], 5, -701558691);
233
+ d = GG(d, a, b, c, m[i+10], 9, 38016083);
234
+ c = GG(c, d, a, b, m[i+15], 14, -660478335);
235
+ b = GG(b, c, d, a, m[i+ 4], 20, -405537848);
236
+ a = GG(a, b, c, d, m[i+ 9], 5, 568446438);
237
+ d = GG(d, a, b, c, m[i+14], 9, -1019803690);
238
+ c = GG(c, d, a, b, m[i+ 3], 14, -187363961);
239
+ b = GG(b, c, d, a, m[i+ 8], 20, 1163531501);
240
+ a = GG(a, b, c, d, m[i+13], 5, -1444681467);
241
+ d = GG(d, a, b, c, m[i+ 2], 9, -51403784);
242
+ c = GG(c, d, a, b, m[i+ 7], 14, 1735328473);
243
+ b = GG(b, c, d, a, m[i+12], 20, -1926607734);
244
+
245
+ a = HH(a, b, c, d, m[i+ 5], 4, -378558);
246
+ d = HH(d, a, b, c, m[i+ 8], 11, -2022574463);
247
+ c = HH(c, d, a, b, m[i+11], 16, 1839030562);
248
+ b = HH(b, c, d, a, m[i+14], 23, -35309556);
249
+ a = HH(a, b, c, d, m[i+ 1], 4, -1530992060);
250
+ d = HH(d, a, b, c, m[i+ 4], 11, 1272893353);
251
+ c = HH(c, d, a, b, m[i+ 7], 16, -155497632);
252
+ b = HH(b, c, d, a, m[i+10], 23, -1094730640);
253
+ a = HH(a, b, c, d, m[i+13], 4, 681279174);
254
+ d = HH(d, a, b, c, m[i+ 0], 11, -358537222);
255
+ c = HH(c, d, a, b, m[i+ 3], 16, -722521979);
256
+ b = HH(b, c, d, a, m[i+ 6], 23, 76029189);
257
+ a = HH(a, b, c, d, m[i+ 9], 4, -640364487);
258
+ d = HH(d, a, b, c, m[i+12], 11, -421815835);
259
+ c = HH(c, d, a, b, m[i+15], 16, 530742520);
260
+ b = HH(b, c, d, a, m[i+ 2], 23, -995338651);
261
+
262
+ a = II(a, b, c, d, m[i+ 0], 6, -198630844);
263
+ d = II(d, a, b, c, m[i+ 7], 10, 1126891415);
264
+ c = II(c, d, a, b, m[i+14], 15, -1416354905);
265
+ b = II(b, c, d, a, m[i+ 5], 21, -57434055);
266
+ a = II(a, b, c, d, m[i+12], 6, 1700485571);
267
+ d = II(d, a, b, c, m[i+ 3], 10, -1894986606);
268
+ c = II(c, d, a, b, m[i+10], 15, -1051523);
269
+ b = II(b, c, d, a, m[i+ 1], 21, -2054922799);
270
+ a = II(a, b, c, d, m[i+ 8], 6, 1873313359);
271
+ d = II(d, a, b, c, m[i+15], 10, -30611744);
272
+ c = II(c, d, a, b, m[i+ 6], 15, -1560198380);
273
+ b = II(b, c, d, a, m[i+13], 21, 1309151649);
274
+ a = II(a, b, c, d, m[i+ 4], 6, -145523070);
275
+ d = II(d, a, b, c, m[i+11], 10, -1120210379);
276
+ c = II(c, d, a, b, m[i+ 2], 15, 718787259);
277
+ b = II(b, c, d, a, m[i+ 9], 21, -343485551);
278
+
279
+ a = (a + aa) >>> 0;
280
+ b = (b + bb) >>> 0;
281
+ c = (c + cc) >>> 0;
282
+ d = (d + dd) >>> 0;
283
+ }
284
+
285
+ return crypt$1.endian([a, b, c, d]);
286
+ };
287
+
288
+ // Auxiliary functions
289
+ md5._ff = function (a, b, c, d, x, s, t) {
290
+ var n = a + (b & c | ~b & d) + (x >>> 0) + t;
291
+ return ((n << s) | (n >>> (32 - s))) + b;
292
+ };
293
+ md5._gg = function (a, b, c, d, x, s, t) {
294
+ var n = a + (b & d | c & ~d) + (x >>> 0) + t;
295
+ return ((n << s) | (n >>> (32 - s))) + b;
296
+ };
297
+ md5._hh = function (a, b, c, d, x, s, t) {
298
+ var n = a + (b ^ c ^ d) + (x >>> 0) + t;
299
+ return ((n << s) | (n >>> (32 - s))) + b;
300
+ };
301
+ md5._ii = function (a, b, c, d, x, s, t) {
302
+ var n = a + (c ^ (b | ~d)) + (x >>> 0) + t;
303
+ return ((n << s) | (n >>> (32 - s))) + b;
304
+ };
305
+
306
+ // Package private blocksize
307
+ md5._blocksize = 16;
308
+ md5._digestsize = 16;
309
+
310
+ module.exports = function (message, options) {
311
+ if (message === undefined || message === null)
312
+ throw new Error('Illegal argument ' + message);
313
+
314
+ var digestbytes = crypt$1.wordsToBytes(md5(message, options));
315
+ return options && options.asBytes ? digestbytes :
316
+ options && options.asString ? bin.bytesToString(digestbytes) :
317
+ crypt$1.bytesToHex(digestbytes);
318
+ };
319
+
320
+ })();
321
+ });
322
+
323
+ exports.md5 = md5;