@abtnode/util 1.16.26-beta-351de484 → 1.16.26-beta-63f52a83

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/base32.js CHANGED
@@ -1,4 +1,4 @@
1
- const { toBuffer, toAddress } = require('@ocap/util');
1
+ const { toBuffer, toAddress, toBase58, toHex } = require('@ocap/util');
2
2
  const { base32 } = require('multiformats/bases/base32');
3
3
 
4
4
  const encode = (did) => {
@@ -11,4 +11,18 @@ const encode = (did) => {
11
11
  return base32.encode(buffer);
12
12
  };
13
13
 
14
- module.exports = { encode };
14
+ const decode = (str) => {
15
+ if (!str) {
16
+ return str;
17
+ }
18
+
19
+ const buffer = base32.decode(str);
20
+ const base58 = toBase58(buffer);
21
+ if (base58.length > 30) {
22
+ return base58;
23
+ }
24
+
25
+ return toHex(buffer);
26
+ };
27
+
28
+ module.exports = { encode, decode };
@@ -3,6 +3,7 @@ const http = require('http');
3
3
  const https = require('https');
4
4
  const path = require('path');
5
5
  const get = require('lodash/get');
6
+ const pick = require('lodash/pick');
6
7
 
7
8
  const logger = require('@abtnode/logger')('@abtnode/util:logo-middleware');
8
9
 
@@ -41,7 +42,7 @@ const sendCustomRemoteFile = (req, res, url) => {
41
42
 
42
43
  const opts = Object.assign(new URL(tmp.href), {
43
44
  method: req.method,
44
- headers: req.headers,
45
+ headers: pick(req.headers, ['user-agent', 'accept', 'accept-encoding', 'accept-language', 'referer', 'cookie']),
45
46
  });
46
47
 
47
48
  const request = opts.protocol === 'https:' ? https.request : http.request;
package/lib/user.js CHANGED
@@ -191,7 +191,8 @@ const getAvatarByUrl = async (url) => {
191
191
  }
192
192
  };
193
193
 
194
- const getEmailHash = (email) => md5(email.trim().toLowerCase());
194
+ // HACK: 即使传入空值,也会返回空字符串的 md5
195
+ const getEmailHash = (email) => md5(email?.trim()?.toLowerCase() || '');
195
196
 
196
197
  const getAvatarByEmail = async (email) => {
197
198
  try {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.26-beta-351de484",
6
+ "version": "1.16.26-beta-63f52a83",
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": "Apache-2.0",
20
20
  "dependencies": {
21
- "@abtnode/constant": "1.16.26-beta-351de484",
22
- "@abtnode/logger": "1.16.26-beta-351de484",
23
- "@blocklet/constant": "1.16.26-beta-351de484",
24
- "@blocklet/meta": "1.16.26-beta-351de484",
21
+ "@abtnode/constant": "1.16.26-beta-63f52a83",
22
+ "@abtnode/logger": "1.16.26-beta-63f52a83",
23
+ "@blocklet/constant": "1.16.26-beta-63f52a83",
24
+ "@blocklet/meta": "1.16.26-beta-63f52a83",
25
25
  "@ocap/client": "1.18.115",
26
26
  "@ocap/mcrypto": "1.18.115",
27
27
  "@ocap/util": "1.18.115",
@@ -76,5 +76,5 @@
76
76
  "fs-extra": "^11.2.0",
77
77
  "jest": "^29.7.0"
78
78
  },
79
- "gitHead": "00eba435a21506382c7823ea804abea196390a0f"
79
+ "gitHead": "ce04b1916e531d79d9535111cd370c69c04fcbc1"
80
80
  }