@blocklet/meta 1.8.26 → 1.8.28

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/constants.js CHANGED
@@ -1,191 +1,3 @@
1
- const fromEntry = (entries) => (v) => {
2
- const match = Object.entries(entries).find((x) => x[1] === Number(v));
3
- return match ? match[0] : 'unknown';
4
- };
1
+ const constant = require('@blocklet/constant');
5
2
 
6
- const toEntry = (entries) => (v) => Object.keys(entries).find((x) => entries[x] === Number(v));
7
-
8
- // Blocklet Status
9
-
10
- const BlockletStatus = Object.freeze({
11
- added: 0,
12
- downloading: 1,
13
- downloaded: 2, // Deprecated
14
- installing: 3,
15
- installed: 4,
16
- starting: 5,
17
- running: 6,
18
- stopping: 7,
19
- stopped: 8,
20
- error: 9,
21
- upgrading: 10,
22
- restarting: 11, // Deprecated
23
- corrupted: 12,
24
- waiting: 13,
25
- deleted: 14,
26
- });
27
-
28
- const fromBlockletStatus = fromEntry(BlockletStatus);
29
- const toBlockletStatus = toEntry(BlockletStatus);
30
-
31
- // Blocklet Source
32
-
33
- const BlockletSource = Object.freeze({
34
- // Installed from Blocklet Store
35
- registry: 0,
36
-
37
- // Installed from local development source folder
38
- local: 1,
39
-
40
- // Installed from uploading bundle directly
41
- upload: 2,
42
-
43
- // Installed from a url (similar to Blocklet Store)
44
- url: 3,
45
-
46
- // Installed by custom creation
47
- custom: 4,
48
- });
49
-
50
- const fromBlockletSource = fromEntry(BlockletSource);
51
- const toBlockletSource = toEntry(BlockletSource);
52
-
53
- // Blocklet Group(Type)
54
-
55
- const BlockletGroup = Object.freeze({
56
- // Only static website
57
- // The website is served by by Blocklet Server at runtime
58
- static: 'static',
59
-
60
- // The runtime instance is provided by its own backend server
61
- dapp: 'dapp',
62
-
63
- starter: false, // deprecated
64
-
65
- // This type is used to combine other component blocklets
66
- // No instance will be spawned at runtime
67
- gateway: 'gateway',
68
- });
69
-
70
- const BLOCKLET_GROUPS = ['dapp', 'static', 'gateway'];
71
-
72
- // Blocklet Events
73
-
74
- const BlockletEvents = Object.freeze({
75
- added: 'blocklet.added',
76
- downloadFailed: 'blocklet.downloadFailed',
77
- installed: 'blocklet.installed',
78
- installFailed: 'blocklet.installFailed',
79
- upgraded: 'blocklet.upgraded',
80
- upgradeFailed: 'blocklet.upgradedFailed',
81
- downgraded: 'blocklet.downgraded',
82
- downgradeFailed: 'blocklet.downgradedFailed',
83
- updated: 'blocklet.updated',
84
- statusChange: 'blocklet.statusChange',
85
- removed: 'blocklet.removed',
86
- started: 'blocklet.started',
87
- startFailed: 'blocklet.startFailed',
88
- stopped: 'blocklet.stopped',
89
- reloaded: 'blocklet.reloaded', // Deprecated
90
- purchaseChange: 'blocklet.purchaseChange',
91
- });
92
-
93
- // Blocklet Interface
94
-
95
- const BLOCKLET_INTERFACE_TYPE_WEB = 'web';
96
- const BLOCKLET_INTERFACE_TYPE_SERVICE = 'service';
97
-
98
- // Wellknown interface declares an sub-interface under web interface
99
- // The path of the wellknown interface must starts with /.well-known, e.g. /.well-known/acme-challenge)
100
- // The wellknown interface can be mounted to every endpoint of the abtnode and all blocklets on the abtnode
101
- const BLOCKLET_INTERFACE_TYPE_WELLKNOWN = 'wellknown';
102
- const BLOCKLET_INTERFACE_TYPES = [
103
- BLOCKLET_INTERFACE_TYPE_WEB,
104
- BLOCKLET_INTERFACE_TYPE_SERVICE,
105
- BLOCKLET_INTERFACE_TYPE_WELLKNOWN,
106
- ];
107
-
108
- const BLOCKLET_INTERFACE_PUBLIC = 'publicUrl';
109
- const BLOCKLET_INTERFACE_WELLKNOWN = 'wellknownUrl'; // Deprecated
110
- const BLOCKLET_UI_INTERFACES = [BLOCKLET_INTERFACE_PUBLIC];
111
- const BLOCKLET_STANDARD_INTERFACES = [BLOCKLET_INTERFACE_PUBLIC, BLOCKLET_INTERFACE_WELLKNOWN];
112
-
113
- const BLOCKLET_INTERFACE_PROTOCOL_HTTP = 'http';
114
- const BLOCKLET_INTERFACE_PROTOCOL_TCP = 'tcp';
115
- const BLOCKLET_INTERFACE_PROTOCOL_UDP = 'udp';
116
- const BLOCKLET_INTERFACE_PROTOCOLS = [
117
- BLOCKLET_INTERFACE_PROTOCOL_TCP,
118
- BLOCKLET_INTERFACE_PROTOCOL_UDP,
119
- BLOCKLET_INTERFACE_PROTOCOL_HTTP,
120
- ];
121
-
122
- module.exports = Object.freeze({
123
- BlockletStatus,
124
- fromBlockletStatus,
125
- toBlockletStatus,
126
-
127
- BlockletSource,
128
- fromBlockletSource,
129
- toBlockletSource,
130
-
131
- BlockletGroup,
132
- BLOCKLET_GROUPS,
133
-
134
- BlockletEvents,
135
-
136
- BLOCKLET_PLATFORMS: ['aix', 'darwin', 'freebsd', 'linux', 'openbsd', 'sunos', 'win32'],
137
- BLOCKLET_ARCHITECTURES: ['arm', 'arm64', 'ia32', 'mips', 'mipsel', 'ppc', 'ppc64', 's390', 's390x', 'x32', 'x64'],
138
-
139
- BLOCKLET_MODES: Object.freeze({
140
- PRODUCTION: 'production',
141
- DEVELOPMENT: 'development',
142
- }),
143
-
144
- BLOCKLET_FACTORY_SHARES: { developer: 0.7, store: 0.3 },
145
-
146
- // interface
147
- BLOCKLET_INTERFACE_PUBLIC,
148
- BLOCKLET_INTERFACE_WELLKNOWN, // Deprecated
149
- BLOCKLET_UI_INTERFACES,
150
- BLOCKLET_STANDARD_INTERFACES,
151
-
152
- BLOCKLET_INTERFACE_TYPE_WEB,
153
- BLOCKLET_INTERFACE_TYPE_SERVICE,
154
- BLOCKLET_INTERFACE_TYPE_WELLKNOWN,
155
- BLOCKLET_INTERFACE_TYPES,
156
-
157
- BLOCKLET_INTERFACE_PROTOCOL_HTTP,
158
- BLOCKLET_INTERFACE_PROTOCOL_TCP,
159
- BLOCKLET_INTERFACE_PROTOCOL_UDP,
160
- BLOCKLET_INTERFACE_PROTOCOLS,
161
-
162
- BLOCKLET_DYNAMIC_PATH_PREFIX: '*',
163
- BLOCKLET_DEFAULT_PORT_NAME: 'BLOCKLET_PORT',
164
- BLOCKLET_DEFAULT_PATH_REWRITE: '/',
165
-
166
- // bundle
167
- BLOCKLET_RELEASE_FOLDER: '.blocklet/release',
168
- BLOCKLET_RELEASE_FILE: 'blocklet.json',
169
- BLOCKLET_BUNDLE_FOLDER: '.blocklet/bundle',
170
- BLOCKLET_BUNDLE_FILE: 'blocklet.zip',
171
- BLOCKLET_ENTRY_FILE: 'blocklet.js',
172
- BLOCKLET_META_FILE: 'blocklet.yml',
173
- BLOCKLET_META_FILE_ALT: 'blocklet.yaml',
174
-
175
- BLOCKLET_DEFAULT_VERSION: '1.0.0',
176
-
177
- BLOCKLET_LATEST_SPEC_VERSION: '1.2.7',
178
- BLOCKLET_LATEST_REQUIREMENT_SERVER: '>=1.7.0',
179
- BLOCKLET_LATEST_REQUIREMENT_ABTNODE: '>=1.5.15', // Deprecated
180
-
181
- BLOCKLET_CONFIGURABLE_KEY: {
182
- BLOCKLET_CLUSTER_SIZE: 'BLOCKLET_CLUSTER_SIZE',
183
- BLOCKLET_APP_NAME: 'BLOCKLET_APP_NAME',
184
- BLOCKLET_APP_DESCRIPTION: 'BLOCKLET_APP_DESCRIPTION',
185
- BLOCKLET_APP_SK: 'BLOCKLET_APP_SK',
186
- BLOCKLET_APP_URL: 'BLOCKLET_APP_URL',
187
- BLOCKLET_PASSPORT_COLOR: 'BLOCKLET_PASSPORT_COLOR',
188
- BLOCKLET_WALLET_TYPE: 'BLOCKLET_WALLET_TYPE',
189
- BLOCKLET_DELETABLE: 'BLOCKLET_DELETABLE',
190
- },
191
- });
3
+ module.exports = constant;
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/schema.js CHANGED
@@ -42,6 +42,9 @@ const titleSchema = Joi.string()
42
42
  return value;
43
43
  });
44
44
  const descriptionSchema = Joi.string().trim().min(3).max(160);
45
+ const logoSchema = Joi.string()
46
+ .uri({ scheme: ['http', 'https'], allowRelative: true })
47
+ .allow('');
45
48
  const mountPointSchema = Joi.string().trim().min(1);
46
49
 
47
50
  const blockletNameSchema = Joi.string()
@@ -515,6 +518,7 @@ module.exports = {
515
518
  distSchema,
516
519
  titleSchema,
517
520
  descriptionSchema,
521
+ logoSchema,
518
522
  navigationSchema,
519
523
  themeSchema,
520
524
  mountPointSchema,
package/lib/util-meta.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const fs = require('fs');
2
- const axios = require('axios');
2
+ const axios = require('@abtnode/util/lib/axios');
3
3
  const any = require('promise.any');
4
4
  const joinUrl = require('url-join');
5
5
 
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) {
@@ -334,6 +345,10 @@ const hasRunnableComponent = (blocklet) => {
334
345
  * @returns blocklet display name
335
346
  */
336
347
  const getDisplayName = (blocklet, onlyUseMeta = false) => {
348
+ if (!blocklet) {
349
+ return '';
350
+ }
351
+
337
352
  const { meta } = blocklet;
338
353
  let displayName;
339
354
 
@@ -438,6 +453,14 @@ const replaceSlotToIp = (url, ip) => (url || '').replace(SLOT_FOR_IP_DNS_SITE, (
438
453
 
439
454
  const urlFriendly = (name) => slugify(name.replace(/^[@./-]/, '').replace(/[@./_]/g, '-'));
440
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
+
441
464
  module.exports = {
442
465
  isFreeBlocklet,
443
466
  isFreeComponent,
@@ -450,6 +473,7 @@ module.exports = {
450
473
  getSharedConfigObj,
451
474
  getAppMissingConfigs,
452
475
  getComponentMissingConfigs,
476
+ isEnvShareable,
453
477
  wipeSensitiveData,
454
478
  hasRunnableComponent,
455
479
  getDisplayName,
@@ -465,4 +489,5 @@ module.exports = {
465
489
  findComponentById,
466
490
  getParentComponentName,
467
491
  getConnectAppUrl,
492
+ getChainInfo,
468
493
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.8.26",
6
+ "version": "1.8.28",
7
7
  "description": "Library to parse/validate/fix blocklet meta",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -18,16 +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.26",
22
- "@abtnode/util": "1.8.26",
23
- "@arcblock/did": "1.17.19",
24
- "@arcblock/did-ext": "1.17.19",
25
- "@arcblock/did-util": "1.17.19",
26
- "@arcblock/jwt": "1.17.19",
27
- "@ocap/asset": "1.17.19",
28
- "@ocap/mcrypto": "1.17.19",
29
- "@ocap/util": "1.17.19",
30
- "@ocap/wallet": "1.17.19",
21
+ "@abtnode/constant": "1.8.28",
22
+ "@abtnode/util": "1.8.28",
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.28",
28
+ "@ocap/asset": "1.17.23",
29
+ "@ocap/mcrypto": "1.17.23",
30
+ "@ocap/util": "1.17.23",
31
+ "@ocap/wallet": "1.17.23",
31
32
  "ajv": "^8.11.0",
32
33
  "axios": "^0.27.2",
33
34
  "cjk-length": "^1.0.0",
@@ -35,7 +36,7 @@
35
36
  "fs-extra": "^10.1.0",
36
37
  "hosted-git-info": "3.0.8",
37
38
  "is-glob": "^4.0.3",
38
- "joi": "^17.6.0",
39
+ "joi": "^17.6.2",
39
40
  "joi-extension-semver": "^5.0.0",
40
41
  "js-yaml": "^4.1.0",
41
42
  "json-stable-stringify": "^1.0.1",
@@ -46,12 +47,12 @@
46
47
  "validate-npm-package-name": "^3.0.0"
47
48
  },
48
49
  "devDependencies": {
49
- "body-parser": "^1.20.0",
50
+ "body-parser": "^1.20.1",
50
51
  "compression": "^1.7.4",
51
- "detect-port": "^1.3.0",
52
+ "detect-port": "^1.5.1",
52
53
  "expand-tilde": "^2.0.2",
53
- "express": "^4.18.1",
54
+ "express": "^4.18.2",
54
55
  "jest": "^27.5.1"
55
56
  },
56
- "gitHead": "71937dabc196a98a1bb514789bc32aee44a1e8c4"
57
+ "gitHead": "af7aacf5507177600ae563ab597cb42d7223b113"
57
58
  }