mybase 1.0.42 → 1.0.44

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 (3) hide show
  1. package/README.md +1 -0
  2. package/mybase.js +10 -5
  3. package/package.json +2 -1
package/README.md CHANGED
@@ -18,6 +18,7 @@ var { isLocal } = require('mybase')
18
18
  ### getTemp(filename=false) // returns temp directory of current OS, optionally appends a filename to it
19
19
  ### softexit(message=false,seconds=60,exitcode=-1)
20
20
  ### validHPassword(hpassword)
21
+ ### randomHPassword(length=10)
21
22
  ### validIp(ip)
22
23
  ### validTime(t)
23
24
  ### randomIP()
package/mybase.js CHANGED
@@ -3,13 +3,14 @@ const debug = require('debug')('mybase')
3
3
  const os = require('os')
4
4
  const fs = require('fs')
5
5
  const path = require('path')
6
-
7
6
  const net = require('net')
8
7
  const chalk = require('chalk')
9
8
  const punycode = require('punycode');
10
9
  const _validURL = require('@7c/validurl')
11
10
  const { match } = require('assert');
12
11
  const validator = require('validator')
12
+ const sha512 = require('js-sha512')
13
+
13
14
 
14
15
  Date.prototype.yyyymmdd = function() {
15
16
  var mm = this.getMonth() + 1; // getMonth() is zero-based
@@ -22,7 +23,10 @@ Date.prototype.yyyymmdd = function() {
22
23
  };
23
24
 
24
25
  function validHPassword(hpassword) { return (hpassword && hpassword.length === 128 && hpassword.search(/^[a-f0-9]+$/) == 0) }
25
-
26
+ function randomHPassword(length=10) {
27
+ let plain = randomString(length)
28
+ return sha512(plain)
29
+ }
26
30
  function validEmail_old(email) { return (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)) }
27
31
 
28
32
  function validEmail(email) {
@@ -443,9 +447,9 @@ function getTemp(filename=false) {
443
447
  return tmp
444
448
  }
445
449
 
446
- function sqlQuery(sqlHandle,query) {
450
+ function sqlQuery(sqlHandle,query,values=[]) {
447
451
  return new Promise((resolve,reject)=>{
448
- sqlHandle.query(query,(err,res)=>{
452
+ sqlHandle.query(query,values,(err,res)=>{
449
453
  if (err)return reject(err)
450
454
  resolve(res)
451
455
  })
@@ -604,5 +608,6 @@ module.exports = {
604
608
  arrayRandomItem,
605
609
  promiseTimeout,
606
610
  utcnow,
607
- Geoip2Paths
611
+ Geoip2Paths,
612
+ randomHPassword
608
613
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mybase",
3
- "version": "1.0.42",
3
+ "version": "1.0.44",
4
4
  "description": "",
5
5
  "main": "mybase.js",
6
6
  "scripts": {
@@ -13,6 +13,7 @@
13
13
  "aes-js": "^3.1.2",
14
14
  "chalk": "^3.0.0",
15
15
  "debug": "^4.3.1",
16
+ "js-sha512": "^0.8.0",
16
17
  "punycode": "^2.1.1",
17
18
  "validator": "^13.7.0"
18
19
  },