mybase 1.0.42 → 1.0.43

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 +8 -3
  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) {
@@ -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.43",
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
  },