@blocklet/meta 1.16.1 → 1.16.2-beta-992f57fb
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/util-meta.js +9 -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 (
|
|
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 (
|
|
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.
|
|
6
|
+
"version": "1.16.2-beta-992f57fb",
|
|
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.
|
|
28
|
-
"@abtnode/constant": "1.16.
|
|
29
|
-
"@abtnode/util": "1.16.
|
|
27
|
+
"@abtnode/client": "1.16.2-beta-992f57fb",
|
|
28
|
+
"@abtnode/constant": "1.16.2-beta-992f57fb",
|
|
29
|
+
"@abtnode/util": "1.16.2-beta-992f57fb",
|
|
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.
|
|
34
|
+
"@blocklet/constant": "1.16.2-beta-992f57fb",
|
|
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": "
|
|
83
|
+
"gitHead": "c2bbe98efb7ec70476263319053aa648a45c5a6a"
|
|
84
84
|
}
|