mybase 1.0.45 → 1.0.46

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 +11 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -42,6 +42,7 @@ var { isLocal } = require('mybase')
42
42
  ## Encryption
43
43
  ### decryptAES_CBC_NOIV(encryptedHex, encryptionKey)
44
44
  ### encryptAES_CBC_NOIV(plainString, encryptionKey)
45
+ ### hash_sha512(plain)
45
46
  ```
46
47
  var handle = await maxmindOpen(config.geoip.country)
47
48
  ```
package/mybase.js CHANGED
@@ -11,6 +11,10 @@ const { match } = require('assert');
11
11
  const validator = require('validator')
12
12
  const sha512 = require('js-sha512')
13
13
 
14
+ // create cache folder if not exists
15
+ let vault_cache_folder = '/var/tmp/vault-cache'
16
+ if (!fs.existsSync(vault_cache_folder)) fs.mkdirSync(vault_cache_folder)
17
+
14
18
 
15
19
  Date.prototype.yyyymmdd = function() {
16
20
  var mm = this.getMonth() + 1; // getMonth() is zero-based
@@ -22,6 +26,11 @@ Date.prototype.yyyymmdd = function() {
22
26
  ].join('');
23
27
  };
24
28
 
29
+ function hash_sha512(plain) {
30
+ if (typeof plain==='string') return sha512(plain)
31
+ return false
32
+ }
33
+
25
34
  function validHPassword(hpassword) { return (hpassword && hpassword.length === 128 && hpassword.search(/^[a-f0-9]+$/) == 0) }
26
35
  function randomHPassword(length=10) {
27
36
  let plain = randomString(length)
@@ -616,5 +625,6 @@ module.exports = {
616
625
  utcnow,
617
626
  Geoip2Paths,
618
627
  randomHPassword,
619
- isURL
628
+ isURL,
629
+ hash_sha512
620
630
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mybase",
3
- "version": "1.0.45",
3
+ "version": "1.0.46",
4
4
  "description": "",
5
5
  "main": "mybase.js",
6
6
  "scripts": {