@blocklet/meta 1.16.1 → 1.16.2

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 (2) hide show
  1. package/lib/util-meta.js +9 -2
  2. package/package.json +6 -6
package/lib/util-meta.js CHANGED
@@ -12,7 +12,14 @@ const url_join_1 = __importDefault(require("url-join"));
12
12
  const constant_1 = __importDefault(require("@abtnode/constant"));
13
13
  const did_1 = __importDefault(require("./did"));
14
14
  const validate_1 = require("./validate");
15
+ // @ts-ignore
16
+ const package_json_1 = require("../package.json");
15
17
  const { BLOCKLET_STORE_API_BLOCKLET_PREFIX } = constant_1.default;
18
+ // HACK: copy from core/state/lib/util/request.js
19
+ const api = axios_1.default.create({
20
+ timeout: 10 * 1000,
21
+ headers: { 'User-Agent': `ABTNode/${package_json_1.version}`, 'x-blocklet-server-version': package_json_1.version },
22
+ });
16
23
  const validateUrl = async (url, expectedHttpResTypes = ['application/json', 'text/plain']) => {
17
24
  const parsed = new URL(url);
18
25
  const { protocol } = parsed;
@@ -28,7 +35,7 @@ const validateUrl = async (url, expectedHttpResTypes = ['application/json', 'tex
28
35
  if (protocol.startsWith('http')) {
29
36
  let res;
30
37
  try {
31
- res = await (0, axios_1.default)({ url, method: 'HEAD', timeout: 1000 * 10 });
38
+ res = await api({ url, method: 'HEAD', timeout: 1000 * 10 });
32
39
  }
33
40
  catch (err) {
34
41
  throw new Error(`Cannot get content-type from ${url}: ${err.message}`);
@@ -59,7 +66,7 @@ const getBlockletMetaByUrl = async (url) => {
59
66
  return meta;
60
67
  }
61
68
  if (protocol.startsWith('http')) {
62
- const { data: meta } = await (0, axios_1.default)({ url, method: 'GET', timeout: 1000 * 20 });
69
+ const { data: meta } = await api({ url, method: 'GET', timeout: 1000 * 20 });
63
70
  if (Object.prototype.toString.call(meta) !== '[object Object]') {
64
71
  throw new Error('Url is not valid');
65
72
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.1",
6
+ "version": "1.16.2",
7
7
  "description": "Library to parse/validate/fix blocklet meta",
8
8
  "main": "./lib/index.js",
9
9
  "typings": "./lib/index.d.ts",
@@ -24,14 +24,14 @@
24
24
  "author": "wangshijun <wangshijun2020@gmail.com> (http://github.com/wangshijun)",
25
25
  "license": "MIT",
26
26
  "dependencies": {
27
- "@abtnode/client": "1.16.1",
28
- "@abtnode/constant": "1.16.1",
29
- "@abtnode/util": "1.16.1",
27
+ "@abtnode/client": "1.16.2",
28
+ "@abtnode/constant": "1.16.2",
29
+ "@abtnode/util": "1.16.2",
30
30
  "@arcblock/did": "1.18.65",
31
31
  "@arcblock/did-ext": "1.18.65",
32
32
  "@arcblock/did-util": "1.18.65",
33
33
  "@arcblock/jwt": "1.18.65",
34
- "@blocklet/constant": "1.16.1",
34
+ "@blocklet/constant": "1.16.2",
35
35
  "@ocap/asset": "1.18.65",
36
36
  "@ocap/mcrypto": "1.18.65",
37
37
  "@ocap/types": "1.18.65",
@@ -80,5 +80,5 @@
80
80
  "ts-node": "^10.9.1",
81
81
  "typescript": "^4.8.4"
82
82
  },
83
- "gitHead": "5912cfbd3b7573850727b05a808b1f798686267f"
83
+ "gitHead": "a5047fb5b8673d33dfce92cee06687a42d3ac07a"
84
84
  }