@mjhls/mjh-framework 1.0.1005 → 1.0.1006
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/README.md +1 -1
- package/dist/cjs/faundadb.js +63 -22
- package/dist/esm/faundadb.js +63 -23
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# mjh-framework v. 1.0.
|
|
1
|
+
# mjh-framework v. 1.0.1006
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/mjh-framework) [](https://standardjs.com)
|
|
4
4
|
|
package/dist/cjs/faundadb.js
CHANGED
|
@@ -318,27 +318,67 @@ var updateUserSecret = function () {
|
|
|
318
318
|
return _ref6.apply(this, arguments);
|
|
319
319
|
};
|
|
320
320
|
}();
|
|
321
|
+
var updateUserSecretByForm = function () {
|
|
322
|
+
var _ref7 = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee7(email, hash, form) {
|
|
323
|
+
var secret = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'fnAEG3Bb7AACAC0BiSQFYGBLFUtHjn3QOTKE1iBX';
|
|
324
|
+
var expiration, client, result;
|
|
325
|
+
return asyncToGenerator.regenerator.wrap(function _callee7$(_context7) {
|
|
326
|
+
while (1) {
|
|
327
|
+
switch (_context7.prev = _context7.next) {
|
|
328
|
+
case 0:
|
|
329
|
+
expiration = new Date().getTime() + 43200000; //1day
|
|
330
|
+
|
|
331
|
+
_context7.prev = 1;
|
|
332
|
+
|
|
333
|
+
console.log(email, hash, expiration);
|
|
334
|
+
client = new faunadb.Client({ secret: secret });
|
|
335
|
+
_context7.next = 6;
|
|
336
|
+
return client.query(q.Update(q.Select(['ref'], q.Get(q.Match(q.Index('Email_and_FormName'), [email, form]))), { data: { secretKey: hash, secretExpiration: expiration } }));
|
|
337
|
+
|
|
338
|
+
case 6:
|
|
339
|
+
result = _context7.sent;
|
|
340
|
+
return _context7.abrupt('return', result ? true : false);
|
|
341
|
+
|
|
342
|
+
case 10:
|
|
343
|
+
_context7.prev = 10;
|
|
344
|
+
_context7.t0 = _context7['catch'](1);
|
|
345
|
+
|
|
346
|
+
console.log(_context7.t0);
|
|
347
|
+
return _context7.abrupt('return', false);
|
|
348
|
+
|
|
349
|
+
case 14:
|
|
350
|
+
case 'end':
|
|
351
|
+
return _context7.stop();
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}, _callee7, this, [[1, 10]]);
|
|
355
|
+
}));
|
|
356
|
+
|
|
357
|
+
return function updateUserSecretByForm(_x18, _x19, _x20) {
|
|
358
|
+
return _ref7.apply(this, arguments);
|
|
359
|
+
};
|
|
360
|
+
}();
|
|
321
361
|
|
|
322
362
|
var updateUserPassword = function () {
|
|
323
|
-
var
|
|
363
|
+
var _ref8 = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee8(hash, newPassword) {
|
|
324
364
|
var secret = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'fnAEG3Bb7AACAC0BiSQFYGBLFUtHjn3QOTKE1iBX';
|
|
325
365
|
var now, client, result, expiration, password, updatePassword;
|
|
326
|
-
return asyncToGenerator.regenerator.wrap(function
|
|
366
|
+
return asyncToGenerator.regenerator.wrap(function _callee8$(_context8) {
|
|
327
367
|
while (1) {
|
|
328
|
-
switch (
|
|
368
|
+
switch (_context8.prev = _context8.next) {
|
|
329
369
|
case 0:
|
|
330
|
-
|
|
370
|
+
_context8.prev = 0;
|
|
331
371
|
now = Date.now();
|
|
332
372
|
client = new faunadb.Client({ secret: secret });
|
|
333
|
-
|
|
373
|
+
_context8.next = 5;
|
|
334
374
|
return client.query(q.Get(q.Match(q.Index('SecretKey'), hash)));
|
|
335
375
|
|
|
336
376
|
case 5:
|
|
337
|
-
result =
|
|
377
|
+
result = _context8.sent;
|
|
338
378
|
expiration = result.data.secretExpiration;
|
|
339
379
|
|
|
340
380
|
if (!(now > expiration)) {
|
|
341
|
-
|
|
381
|
+
_context8.next = 9;
|
|
342
382
|
break;
|
|
343
383
|
}
|
|
344
384
|
|
|
@@ -346,23 +386,23 @@ var updateUserPassword = function () {
|
|
|
346
386
|
|
|
347
387
|
case 9:
|
|
348
388
|
if (!(now < expiration)) {
|
|
349
|
-
|
|
389
|
+
_context8.next = 18;
|
|
350
390
|
break;
|
|
351
391
|
}
|
|
352
392
|
|
|
353
|
-
|
|
393
|
+
_context8.next = 12;
|
|
354
394
|
return encrypt(newPassword);
|
|
355
395
|
|
|
356
396
|
case 12:
|
|
357
|
-
password =
|
|
358
|
-
|
|
397
|
+
password = _context8.sent;
|
|
398
|
+
_context8.next = 15;
|
|
359
399
|
return client.query(q.Update(q.Select(['ref'], q.Get(q.Match(q.Index('SecretKey'), hash))), { data: { Password: password, secretKey: '' } }));
|
|
360
400
|
|
|
361
401
|
case 15:
|
|
362
|
-
updatePassword =
|
|
402
|
+
updatePassword = _context8.sent;
|
|
363
403
|
|
|
364
404
|
if (updatePassword) {
|
|
365
|
-
|
|
405
|
+
_context8.next = 18;
|
|
366
406
|
break;
|
|
367
407
|
}
|
|
368
408
|
|
|
@@ -370,30 +410,30 @@ var updateUserPassword = function () {
|
|
|
370
410
|
|
|
371
411
|
case 18:
|
|
372
412
|
if (!(!result || result.error)) {
|
|
373
|
-
|
|
413
|
+
_context8.next = 20;
|
|
374
414
|
break;
|
|
375
415
|
}
|
|
376
416
|
|
|
377
417
|
throw new Error('User not found');
|
|
378
418
|
|
|
379
419
|
case 20:
|
|
380
|
-
return
|
|
420
|
+
return _context8.abrupt('return', true);
|
|
381
421
|
|
|
382
422
|
case 23:
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
return
|
|
423
|
+
_context8.prev = 23;
|
|
424
|
+
_context8.t0 = _context8['catch'](0);
|
|
425
|
+
return _context8.abrupt('return', { err: _context8.t0 });
|
|
386
426
|
|
|
387
427
|
case 26:
|
|
388
428
|
case 'end':
|
|
389
|
-
return
|
|
429
|
+
return _context8.stop();
|
|
390
430
|
}
|
|
391
431
|
}
|
|
392
|
-
},
|
|
432
|
+
}, _callee8, this, [[0, 23]]);
|
|
393
433
|
}));
|
|
394
434
|
|
|
395
|
-
return function updateUserPassword(
|
|
396
|
-
return
|
|
435
|
+
return function updateUserPassword(_x22, _x23) {
|
|
436
|
+
return _ref8.apply(this, arguments);
|
|
397
437
|
};
|
|
398
438
|
}();
|
|
399
439
|
|
|
@@ -404,3 +444,4 @@ exports.findUserByEmailAndForm = findUserByEmailAndForm;
|
|
|
404
444
|
exports.registerUser = registerUser;
|
|
405
445
|
exports.updateUserPassword = updateUserPassword;
|
|
406
446
|
exports.updateUserSecret = updateUserSecret;
|
|
447
|
+
exports.updateUserSecretByForm = updateUserSecretByForm;
|
package/dist/esm/faundadb.js
CHANGED
|
@@ -314,27 +314,67 @@ var updateUserSecret = function () {
|
|
|
314
314
|
return _ref6.apply(this, arguments);
|
|
315
315
|
};
|
|
316
316
|
}();
|
|
317
|
+
var updateUserSecretByForm = function () {
|
|
318
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7(email, hash, form) {
|
|
319
|
+
var secret = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'fnAEG3Bb7AACAC0BiSQFYGBLFUtHjn3QOTKE1iBX';
|
|
320
|
+
var expiration, client, result;
|
|
321
|
+
return regenerator.wrap(function _callee7$(_context7) {
|
|
322
|
+
while (1) {
|
|
323
|
+
switch (_context7.prev = _context7.next) {
|
|
324
|
+
case 0:
|
|
325
|
+
expiration = new Date().getTime() + 43200000; //1day
|
|
326
|
+
|
|
327
|
+
_context7.prev = 1;
|
|
328
|
+
|
|
329
|
+
console.log(email, hash, expiration);
|
|
330
|
+
client = new faunadb.Client({ secret: secret });
|
|
331
|
+
_context7.next = 6;
|
|
332
|
+
return client.query(q.Update(q.Select(['ref'], q.Get(q.Match(q.Index('Email_and_FormName'), [email, form]))), { data: { secretKey: hash, secretExpiration: expiration } }));
|
|
333
|
+
|
|
334
|
+
case 6:
|
|
335
|
+
result = _context7.sent;
|
|
336
|
+
return _context7.abrupt('return', result ? true : false);
|
|
337
|
+
|
|
338
|
+
case 10:
|
|
339
|
+
_context7.prev = 10;
|
|
340
|
+
_context7.t0 = _context7['catch'](1);
|
|
341
|
+
|
|
342
|
+
console.log(_context7.t0);
|
|
343
|
+
return _context7.abrupt('return', false);
|
|
344
|
+
|
|
345
|
+
case 14:
|
|
346
|
+
case 'end':
|
|
347
|
+
return _context7.stop();
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}, _callee7, this, [[1, 10]]);
|
|
351
|
+
}));
|
|
352
|
+
|
|
353
|
+
return function updateUserSecretByForm(_x18, _x19, _x20) {
|
|
354
|
+
return _ref7.apply(this, arguments);
|
|
355
|
+
};
|
|
356
|
+
}();
|
|
317
357
|
|
|
318
358
|
var updateUserPassword = function () {
|
|
319
|
-
var
|
|
359
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8(hash, newPassword) {
|
|
320
360
|
var secret = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'fnAEG3Bb7AACAC0BiSQFYGBLFUtHjn3QOTKE1iBX';
|
|
321
361
|
var now, client, result, expiration, password, updatePassword;
|
|
322
|
-
return regenerator.wrap(function
|
|
362
|
+
return regenerator.wrap(function _callee8$(_context8) {
|
|
323
363
|
while (1) {
|
|
324
|
-
switch (
|
|
364
|
+
switch (_context8.prev = _context8.next) {
|
|
325
365
|
case 0:
|
|
326
|
-
|
|
366
|
+
_context8.prev = 0;
|
|
327
367
|
now = Date.now();
|
|
328
368
|
client = new faunadb.Client({ secret: secret });
|
|
329
|
-
|
|
369
|
+
_context8.next = 5;
|
|
330
370
|
return client.query(q.Get(q.Match(q.Index('SecretKey'), hash)));
|
|
331
371
|
|
|
332
372
|
case 5:
|
|
333
|
-
result =
|
|
373
|
+
result = _context8.sent;
|
|
334
374
|
expiration = result.data.secretExpiration;
|
|
335
375
|
|
|
336
376
|
if (!(now > expiration)) {
|
|
337
|
-
|
|
377
|
+
_context8.next = 9;
|
|
338
378
|
break;
|
|
339
379
|
}
|
|
340
380
|
|
|
@@ -342,23 +382,23 @@ var updateUserPassword = function () {
|
|
|
342
382
|
|
|
343
383
|
case 9:
|
|
344
384
|
if (!(now < expiration)) {
|
|
345
|
-
|
|
385
|
+
_context8.next = 18;
|
|
346
386
|
break;
|
|
347
387
|
}
|
|
348
388
|
|
|
349
|
-
|
|
389
|
+
_context8.next = 12;
|
|
350
390
|
return encrypt(newPassword);
|
|
351
391
|
|
|
352
392
|
case 12:
|
|
353
|
-
password =
|
|
354
|
-
|
|
393
|
+
password = _context8.sent;
|
|
394
|
+
_context8.next = 15;
|
|
355
395
|
return client.query(q.Update(q.Select(['ref'], q.Get(q.Match(q.Index('SecretKey'), hash))), { data: { Password: password, secretKey: '' } }));
|
|
356
396
|
|
|
357
397
|
case 15:
|
|
358
|
-
updatePassword =
|
|
398
|
+
updatePassword = _context8.sent;
|
|
359
399
|
|
|
360
400
|
if (updatePassword) {
|
|
361
|
-
|
|
401
|
+
_context8.next = 18;
|
|
362
402
|
break;
|
|
363
403
|
}
|
|
364
404
|
|
|
@@ -366,31 +406,31 @@ var updateUserPassword = function () {
|
|
|
366
406
|
|
|
367
407
|
case 18:
|
|
368
408
|
if (!(!result || result.error)) {
|
|
369
|
-
|
|
409
|
+
_context8.next = 20;
|
|
370
410
|
break;
|
|
371
411
|
}
|
|
372
412
|
|
|
373
413
|
throw new Error('User not found');
|
|
374
414
|
|
|
375
415
|
case 20:
|
|
376
|
-
return
|
|
416
|
+
return _context8.abrupt('return', true);
|
|
377
417
|
|
|
378
418
|
case 23:
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
return
|
|
419
|
+
_context8.prev = 23;
|
|
420
|
+
_context8.t0 = _context8['catch'](0);
|
|
421
|
+
return _context8.abrupt('return', { err: _context8.t0 });
|
|
382
422
|
|
|
383
423
|
case 26:
|
|
384
424
|
case 'end':
|
|
385
|
-
return
|
|
425
|
+
return _context8.stop();
|
|
386
426
|
}
|
|
387
427
|
}
|
|
388
|
-
},
|
|
428
|
+
}, _callee8, this, [[0, 23]]);
|
|
389
429
|
}));
|
|
390
430
|
|
|
391
|
-
return function updateUserPassword(
|
|
392
|
-
return
|
|
431
|
+
return function updateUserPassword(_x22, _x23) {
|
|
432
|
+
return _ref8.apply(this, arguments);
|
|
393
433
|
};
|
|
394
434
|
}();
|
|
395
435
|
|
|
396
|
-
export { authenticateUser, authenticateUserByForm, findUserByEmail, findUserByEmailAndForm, registerUser, updateUserPassword, updateUserSecret };
|
|
436
|
+
export { authenticateUser, authenticateUserByForm, findUserByEmail, findUserByEmailAndForm, registerUser, updateUserPassword, updateUserSecret, updateUserSecretByForm };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mjhls/mjh-framework",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1006",
|
|
4
4
|
"description": "Foundation Framework",
|
|
5
5
|
"author": "mjh-framework",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"disqus-react": "^1.0.11",
|
|
29
|
-
"next": "^9.0.0",
|
|
29
|
+
"next": "^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0",
|
|
30
30
|
"prop-types": "^15.5.4",
|
|
31
31
|
"react": "^15.0.0 || ^16.0.0",
|
|
32
32
|
"react-bootstrap": "^1.0.0-beta.14",
|