@abtnode/util 1.8.35 → 1.8.37
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/lib/security.js +27 -0
- package/package.json +5 -5
package/lib/security.js
CHANGED
|
@@ -4,7 +4,34 @@ const AES = require('@ocap/mcrypto/lib/crypter/aes').default;
|
|
|
4
4
|
const encrypt = (m, s, i) => AES.encrypt(m, crypto.pbkdf2Sync(i, s, 256, 32, 'sha512').toString('hex'));
|
|
5
5
|
const decrypt = (m, s, i) => AES.decrypt(m, crypto.pbkdf2Sync(i, s, 256, 32, 'sha512').toString('hex'));
|
|
6
6
|
|
|
7
|
+
const formatEnv = (raw, stringifyObject = true) => {
|
|
8
|
+
let value = raw;
|
|
9
|
+
|
|
10
|
+
// ensure no
|
|
11
|
+
if (Array.isArray(value) && value.every((x) => x.originFileObj && x.url)) {
|
|
12
|
+
value = value.map((x) => x.url);
|
|
13
|
+
if (value.length === 1) {
|
|
14
|
+
[value] = value;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// ensure no objects
|
|
19
|
+
if (stringifyObject) {
|
|
20
|
+
if (value && typeof value === 'object') {
|
|
21
|
+
value = JSON.stringify(value);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// ensure no line breaks for environment variables
|
|
26
|
+
if (value && typeof value === 'string') {
|
|
27
|
+
value = value.replace(/(\r\n|\n|\r)/gm, ' ');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return value;
|
|
31
|
+
};
|
|
32
|
+
|
|
7
33
|
module.exports = {
|
|
8
34
|
encrypt,
|
|
9
35
|
decrypt,
|
|
36
|
+
formatEnv,
|
|
10
37
|
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.8.
|
|
6
|
+
"version": "1.8.37",
|
|
7
7
|
"description": "ArcBlock's JavaScript utility",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"author": "polunzh <polunzh@gmail.com> (http://github.com/polunzh)",
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@abtnode/constant": "1.8.
|
|
22
|
-
"@abtnode/logger": "1.8.
|
|
21
|
+
"@abtnode/constant": "1.8.37",
|
|
22
|
+
"@abtnode/logger": "1.8.37",
|
|
23
23
|
"@arcblock/jwt": "^1.18.15",
|
|
24
|
-
"@blocklet/constant": "1.8.
|
|
24
|
+
"@blocklet/constant": "1.8.37",
|
|
25
25
|
"@ocap/mcrypto": "1.18.15",
|
|
26
26
|
"@ocap/util": "1.18.15",
|
|
27
27
|
"@ocap/wallet": "1.18.15",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"fs-extra": "^10.1.0",
|
|
64
64
|
"jest": "^27.5.1"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "f26f451c6e2b1168b36f78269eafdf3f671236bf"
|
|
67
67
|
}
|