@blocklet/meta 1.8.27 → 1.8.29
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/payment/v2.js +1 -1
- package/lib/util-meta.js +6 -5
- package/lib/util.js +21 -0
- package/package.json +17 -17
package/lib/payment/v2.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
const crypto = require('crypto');
|
|
3
3
|
const debug = require('debug')('@blocklet/meta:payment');
|
|
4
4
|
const joinURL = require('url-join');
|
|
5
|
-
const axios = require('axios').create();
|
|
6
5
|
const stableStringify = require('json-stable-stringify');
|
|
7
6
|
const get = require('lodash/get');
|
|
8
7
|
const pick = require('lodash/pick');
|
|
9
8
|
const cloneDeep = require('lodash/cloneDeep');
|
|
9
|
+
const axios = require('@abtnode/util/lib/axios');
|
|
10
10
|
const { BN, fromTokenToUnit, fromUnitToToken } = require('@ocap/util');
|
|
11
11
|
const { isValidFactory } = require('@ocap/asset');
|
|
12
12
|
const { fromPublicKey } = require('@ocap/wallet');
|
package/lib/util-meta.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
const { fileURLToPath } = require('url');
|
|
1
2
|
const fs = require('fs');
|
|
2
|
-
const axios = require('axios');
|
|
3
|
+
const axios = require('@abtnode/util/lib/axios');
|
|
3
4
|
const any = require('promise.any');
|
|
4
5
|
const joinUrl = require('url-join');
|
|
5
6
|
|
|
@@ -10,11 +11,11 @@ const { validateMeta, fixAndValidateService } = require('./validate');
|
|
|
10
11
|
|
|
11
12
|
const validateUrl = async (url, expectedHttpResTypes = ['application/json', 'text/plain']) => {
|
|
12
13
|
const parsed = new URL(url);
|
|
13
|
-
const { protocol
|
|
14
|
+
const { protocol } = parsed;
|
|
14
15
|
|
|
15
16
|
// file
|
|
16
17
|
if (protocol.startsWith('file')) {
|
|
17
|
-
const decoded = decodeURIComponent(
|
|
18
|
+
const decoded = decodeURIComponent(fileURLToPath(url));
|
|
18
19
|
if (!fs.existsSync(decoded)) {
|
|
19
20
|
throw new Error(`File does not exist: ${decoded}`);
|
|
20
21
|
}
|
|
@@ -50,10 +51,10 @@ const validateBlockletMeta = (meta, opts = {}) => {
|
|
|
50
51
|
};
|
|
51
52
|
|
|
52
53
|
const getBlockletMetaByUrl = async (url) => {
|
|
53
|
-
const { protocol
|
|
54
|
+
const { protocol } = new URL(url);
|
|
54
55
|
|
|
55
56
|
if (protocol.startsWith('file')) {
|
|
56
|
-
const decoded = decodeURIComponent(
|
|
57
|
+
const decoded = decodeURIComponent(fileURLToPath(url));
|
|
57
58
|
if (!fs.existsSync(decoded)) {
|
|
58
59
|
throw new Error(`File does not exist: ${decoded}`);
|
|
59
60
|
}
|
package/lib/util.js
CHANGED
|
@@ -11,6 +11,7 @@ const {
|
|
|
11
11
|
fromBlockletSource,
|
|
12
12
|
BLOCKLET_INTERFACE_TYPE_WEB,
|
|
13
13
|
BLOCKLET_CONFIGURABLE_KEY,
|
|
14
|
+
CHAIN_INFO_CONFIG,
|
|
14
15
|
} = require('./constants');
|
|
15
16
|
|
|
16
17
|
const getComponentId = (component, ancestors = []) =>
|
|
@@ -189,6 +190,16 @@ const findComponentById = (blocklet, componentId, { _ancestors = [], returnAnces
|
|
|
189
190
|
return null;
|
|
190
191
|
};
|
|
191
192
|
|
|
193
|
+
const isEnvShareable = (env) => {
|
|
194
|
+
return (
|
|
195
|
+
!!env &&
|
|
196
|
+
!!(env.key || env.name) &&
|
|
197
|
+
!env.secure &&
|
|
198
|
+
env.shared !== false &&
|
|
199
|
+
!BLOCKLET_CONFIGURABLE_KEY[env.key || env.name]
|
|
200
|
+
);
|
|
201
|
+
};
|
|
202
|
+
|
|
192
203
|
const getSharedConfigObj = (component, ancestors) => {
|
|
193
204
|
const res = {};
|
|
194
205
|
if (!ancestors) {
|
|
@@ -442,6 +453,14 @@ const replaceSlotToIp = (url, ip) => (url || '').replace(SLOT_FOR_IP_DNS_SITE, (
|
|
|
442
453
|
|
|
443
454
|
const urlFriendly = (name) => slugify(name.replace(/^[@./-]/, '').replace(/[@./_]/g, '-'));
|
|
444
455
|
|
|
456
|
+
// transform process.env.CHAIN_x => { x: v }
|
|
457
|
+
const getChainInfo = (env) =>
|
|
458
|
+
Object.entries(CHAIN_INFO_CONFIG).reduce((info, x) => {
|
|
459
|
+
const [envName, [key, value]] = x;
|
|
460
|
+
info[key] = get(env, envName) || value;
|
|
461
|
+
return info;
|
|
462
|
+
}, {});
|
|
463
|
+
|
|
445
464
|
module.exports = {
|
|
446
465
|
isFreeBlocklet,
|
|
447
466
|
isFreeComponent,
|
|
@@ -454,6 +473,7 @@ module.exports = {
|
|
|
454
473
|
getSharedConfigObj,
|
|
455
474
|
getAppMissingConfigs,
|
|
456
475
|
getComponentMissingConfigs,
|
|
476
|
+
isEnvShareable,
|
|
457
477
|
wipeSensitiveData,
|
|
458
478
|
hasRunnableComponent,
|
|
459
479
|
getDisplayName,
|
|
@@ -469,4 +489,5 @@ module.exports = {
|
|
|
469
489
|
findComponentById,
|
|
470
490
|
getParentComponentName,
|
|
471
491
|
getConnectAppUrl,
|
|
492
|
+
getChainInfo,
|
|
472
493
|
};
|
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.29",
|
|
7
7
|
"description": "Library to parse/validate/fix blocklet meta",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -18,17 +18,17 @@
|
|
|
18
18
|
"author": "wangshijun <wangshijun2020@gmail.com> (http://github.com/wangshijun)",
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@abtnode/constant": "1.8.
|
|
22
|
-
"@abtnode/util": "1.8.
|
|
23
|
-
"@arcblock/did": "1.17.
|
|
24
|
-
"@arcblock/did-ext": "1.17.
|
|
25
|
-
"@arcblock/did-util": "1.17.
|
|
26
|
-
"@arcblock/jwt": "1.17.
|
|
27
|
-
"@blocklet/constant": "1.8.
|
|
28
|
-
"@ocap/asset": "1.17.
|
|
29
|
-
"@ocap/mcrypto": "1.17.
|
|
30
|
-
"@ocap/util": "1.17.
|
|
31
|
-
"@ocap/wallet": "1.17.
|
|
21
|
+
"@abtnode/constant": "1.8.29",
|
|
22
|
+
"@abtnode/util": "1.8.29",
|
|
23
|
+
"@arcblock/did": "1.17.23",
|
|
24
|
+
"@arcblock/did-ext": "1.17.23",
|
|
25
|
+
"@arcblock/did-util": "1.17.23",
|
|
26
|
+
"@arcblock/jwt": "1.17.23",
|
|
27
|
+
"@blocklet/constant": "1.8.29",
|
|
28
|
+
"@ocap/asset": "1.17.23",
|
|
29
|
+
"@ocap/mcrypto": "1.17.23",
|
|
30
|
+
"@ocap/util": "1.17.23",
|
|
31
|
+
"@ocap/wallet": "1.17.23",
|
|
32
32
|
"ajv": "^8.11.0",
|
|
33
33
|
"axios": "^0.27.2",
|
|
34
34
|
"cjk-length": "^1.0.0",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"fs-extra": "^10.1.0",
|
|
37
37
|
"hosted-git-info": "3.0.8",
|
|
38
38
|
"is-glob": "^4.0.3",
|
|
39
|
-
"joi": "^17.6.
|
|
39
|
+
"joi": "^17.6.2",
|
|
40
40
|
"joi-extension-semver": "^5.0.0",
|
|
41
41
|
"js-yaml": "^4.1.0",
|
|
42
42
|
"json-stable-stringify": "^1.0.1",
|
|
@@ -47,12 +47,12 @@
|
|
|
47
47
|
"validate-npm-package-name": "^3.0.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"body-parser": "^1.20.
|
|
50
|
+
"body-parser": "^1.20.1",
|
|
51
51
|
"compression": "^1.7.4",
|
|
52
|
-
"detect-port": "^1.
|
|
52
|
+
"detect-port": "^1.5.1",
|
|
53
53
|
"expand-tilde": "^2.0.2",
|
|
54
|
-
"express": "^4.18.
|
|
54
|
+
"express": "^4.18.2",
|
|
55
55
|
"jest": "^27.5.1"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "ee52d838f0cf97e551d53a6509cb0da7e5f31978"
|
|
58
58
|
}
|