@abtnode/core 1.16.4-beta-f058f4e8 → 1.16.4
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/api/team.js +3 -2
- package/lib/blocklet/manager/disk.js +3 -8
- package/lib/blocklet/manager/helper/install-component-from-upload.js +1 -1
- package/lib/blocklet/manager/helper/migrate-application-to-struct-v2.js +8 -4
- package/lib/event.js +3 -4
- package/lib/router/helper.js +5 -2
- package/lib/router/manager.js +20 -4
- package/lib/states/blocklet.js +33 -15
- package/lib/states/user.js +37 -8
- package/lib/util/blocklet.js +2 -8
- package/lib/util/index.js +1 -18
- package/lib/validators/router.js +2 -2
- package/package.json +17 -17
package/lib/api/team.js
CHANGED
|
@@ -12,7 +12,6 @@ const {
|
|
|
12
12
|
WELLKNOWN_SERVICE_PATH_PREFIX,
|
|
13
13
|
MAX_USER_PAGE_SIZE,
|
|
14
14
|
STORE_DETAIL_PAGE_PATH_PREFIX,
|
|
15
|
-
USER_TYPE,
|
|
16
15
|
} = require('@abtnode/constant');
|
|
17
16
|
const { isValid: isValidDid } = require('@arcblock/did');
|
|
18
17
|
const { BlockletEvents } = require('@blocklet/constant');
|
|
@@ -634,7 +633,9 @@ class TeamAPI extends EventEmitter {
|
|
|
634
633
|
const state = await this.getSessionState(teamDid);
|
|
635
634
|
|
|
636
635
|
const currentUser = await this.getUser({ teamDid, user: { did: ownerDid } });
|
|
637
|
-
|
|
636
|
+
const isRawWalletAccount =
|
|
637
|
+
!currentUser?.extraConfigs?.sourceProvider || currentUser?.extraConfigs?.sourceProvider === 'wallet';
|
|
638
|
+
if (!isRawWalletAccount) {
|
|
638
639
|
const userDid = currentUser.did;
|
|
639
640
|
const blocklet = await getBlocklet({ did: teamDid, states: this.states, dataDirs: this.dataDirs });
|
|
640
641
|
const nodeInfo = await this.node.read();
|
|
@@ -34,6 +34,8 @@ const {
|
|
|
34
34
|
getComponentId,
|
|
35
35
|
isPreferenceKey,
|
|
36
36
|
getRolesFromAuthConfig,
|
|
37
|
+
isInProgress,
|
|
38
|
+
isBeforeInstalled,
|
|
37
39
|
} = require('@blocklet/meta/lib/util');
|
|
38
40
|
const getComponentProcessId = require('@blocklet/meta/lib/get-component-process-id');
|
|
39
41
|
const { update: updateMetaFile } = require('@blocklet/meta/lib/file');
|
|
@@ -124,14 +126,7 @@ const BlockletDownloader = require('../downloader/blocklet-downloader');
|
|
|
124
126
|
const RollbackCache = require('./helper/rollback-cache');
|
|
125
127
|
const { migrateApplicationToStructV2 } = require('./helper/migrate-application-to-struct-v2');
|
|
126
128
|
|
|
127
|
-
const {
|
|
128
|
-
isInProgress,
|
|
129
|
-
isBeforeInstalled,
|
|
130
|
-
formatEnvironments,
|
|
131
|
-
shouldUpdateBlockletStatus,
|
|
132
|
-
getBlockletMeta,
|
|
133
|
-
validateOwner,
|
|
134
|
-
} = util;
|
|
129
|
+
const { formatEnvironments, shouldUpdateBlockletStatus, getBlockletMeta, validateOwner } = util;
|
|
135
130
|
|
|
136
131
|
const statusLock = new Lock('blocklet-status-lock');
|
|
137
132
|
|
|
@@ -2,9 +2,9 @@ const path = require('path');
|
|
|
2
2
|
|
|
3
3
|
const logger = require('@abtnode/logger')('@abtnode/core:install-component-upload');
|
|
4
4
|
const getComponentProcessId = require('@blocklet/meta/lib/get-component-process-id');
|
|
5
|
+
const { isInProgress } = require('@blocklet/meta/lib/util');
|
|
5
6
|
|
|
6
7
|
const { BlockletSource, BlockletGroup, fromBlockletStatus } = require('@blocklet/constant');
|
|
7
|
-
const { isInProgress } = require('../../../util');
|
|
8
8
|
const {
|
|
9
9
|
parseComponents,
|
|
10
10
|
filterDuplicateComponents,
|
|
@@ -3,13 +3,18 @@ const fs = require('fs-extra');
|
|
|
3
3
|
const pick = require('lodash/pick');
|
|
4
4
|
const pRetry = require('p-retry');
|
|
5
5
|
const Client = require('@ocap/client');
|
|
6
|
-
const
|
|
6
|
+
const urlPathFriendly = require('@blocklet/meta/lib/url-path-friendly').default;
|
|
7
7
|
const { slugify } = require('transliteration');
|
|
8
8
|
const Lock = require('@abtnode/util/lib/lock');
|
|
9
9
|
|
|
10
10
|
const logger = require('@abtnode/logger')('@abtnode/core:migrate-application-to-struct-v2');
|
|
11
11
|
|
|
12
|
-
const {
|
|
12
|
+
const {
|
|
13
|
+
forEachBlockletSync,
|
|
14
|
+
getSharedConfigObj,
|
|
15
|
+
getBlockletChainInfo,
|
|
16
|
+
isInProgress,
|
|
17
|
+
} = require('@blocklet/meta/lib/util');
|
|
13
18
|
const { SLOT_FOR_IP_DNS_SITE, MAIN_CHAIN_ENDPOINT } = require('@abtnode/constant');
|
|
14
19
|
|
|
15
20
|
const {
|
|
@@ -33,7 +38,6 @@ const { update: updateMetaFile } = require('@blocklet/meta/lib/file');
|
|
|
33
38
|
const getBlockletWallet = require('@blocklet/meta/lib/wallet');
|
|
34
39
|
const { cloneDeep } = require('lodash');
|
|
35
40
|
|
|
36
|
-
const { isInProgress } = require('../../../util');
|
|
37
41
|
const { getBlockletDomainGroupName } = require('../../../util/router');
|
|
38
42
|
const { getIpDnsDomainForBlocklet } = require('../../../util/get-domain-for-blocklet');
|
|
39
43
|
const { getBundleDir } = require('../../../util/blocklet');
|
|
@@ -107,7 +111,7 @@ const ensureAccountOnMainChain = async (blocklet, newWallet) => {
|
|
|
107
111
|
if (!newResultOnMainChain.state) {
|
|
108
112
|
logger.info('declare account on main chain', { address: newWallet.address, did: blocklet.meta.did });
|
|
109
113
|
const hash = await mainChainClient.declare({
|
|
110
|
-
moniker: (
|
|
114
|
+
moniker: (urlPathFriendly(slugify(blocklet.meta.title || blocklet.meta.name)) || 'application').toLowerCase(),
|
|
111
115
|
wallet: newWallet,
|
|
112
116
|
});
|
|
113
117
|
logger.info('declare account on main chain done', { did: blocklet.meta.did, hash });
|
package/lib/event.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const get = require('lodash/get');
|
|
2
2
|
const cloneDeep = require('lodash/cloneDeep');
|
|
3
3
|
const { EventEmitter } = require('events');
|
|
4
|
-
const { wipeSensitiveData } = require('@blocklet/meta/lib/util');
|
|
4
|
+
const { wipeSensitiveData, isBeforeInstalled } = require('@blocklet/meta/lib/util');
|
|
5
5
|
const logger = require('@abtnode/logger')('@abtnode/core:event');
|
|
6
6
|
const { BLOCKLET_MODES, BlockletStatus, BlockletSource, BlockletEvents } = require('@blocklet/constant');
|
|
7
7
|
const { EVENTS } = require('@abtnode/constant');
|
|
@@ -12,7 +12,6 @@ const eventHub =
|
|
|
12
12
|
process.env.NODE_ENV === 'test' ? require('@arcblock/event-hub/single') : require('@arcblock/event-hub');
|
|
13
13
|
|
|
14
14
|
const states = require('./states');
|
|
15
|
-
const { isBeforeInstalled } = require('./util');
|
|
16
15
|
|
|
17
16
|
const routingSnapshotPrefix = (blocklet) => (blocklet.mode === BLOCKLET_MODES.DEVELOPMENT ? '[DEV] ' : '');
|
|
18
17
|
|
|
@@ -104,7 +103,7 @@ module.exports = ({
|
|
|
104
103
|
notificationState.create({
|
|
105
104
|
title: 'Blocklet URL Mapping Error',
|
|
106
105
|
// eslint-disable-next-line max-len
|
|
107
|
-
description: `Failed to create URL mapping for blocklet ${blocklet.meta.
|
|
106
|
+
description: `Failed to create URL mapping for blocklet ${blocklet.meta.title}, due to: ${error.message}`,
|
|
108
107
|
entityType: 'blocklet',
|
|
109
108
|
entityId: blocklet.meta.did,
|
|
110
109
|
severity: 'error',
|
|
@@ -155,7 +154,7 @@ module.exports = ({
|
|
|
155
154
|
notificationState.create({
|
|
156
155
|
title: 'Blocklet URL Mapping Error',
|
|
157
156
|
// eslint-disable-next-line max-len
|
|
158
|
-
description: `Failed to upgrade URL mapping for blocklet ${blocklet.meta.
|
|
157
|
+
description: `Failed to upgrade URL mapping for blocklet ${blocklet.meta.title}, due to: ${error.message}`,
|
|
159
158
|
entityType: 'blocklet',
|
|
160
159
|
entityId: blocklet.meta.did,
|
|
161
160
|
severity: 'error',
|
package/lib/router/helper.js
CHANGED
|
@@ -912,7 +912,10 @@ module.exports = function getRouterHelpers({ dataDirs, routingSnapshot, routerMa
|
|
|
912
912
|
};
|
|
913
913
|
|
|
914
914
|
if (!existedRule) {
|
|
915
|
-
await routerManager.addRoutingRule(
|
|
915
|
+
await routerManager.addRoutingRule(
|
|
916
|
+
{ id: wellknownSite.id, rule, skipCheckDynamicBlacklist: true, formatPathPrefix: false },
|
|
917
|
+
context
|
|
918
|
+
);
|
|
916
919
|
return true;
|
|
917
920
|
}
|
|
918
921
|
|
|
@@ -921,7 +924,7 @@ module.exports = function getRouterHelpers({ dataDirs, routingSnapshot, routerMa
|
|
|
921
924
|
existedRule.to = rule.to;
|
|
922
925
|
|
|
923
926
|
await routerManager.updateRoutingRule(
|
|
924
|
-
{ id: wellknownSite.id, rule: existedRule, skipProtectedRuleChecking: true },
|
|
927
|
+
{ id: wellknownSite.id, rule: existedRule, skipProtectedRuleChecking: true, formatPathPrefix: false },
|
|
925
928
|
context
|
|
926
929
|
);
|
|
927
930
|
|
package/lib/router/manager.js
CHANGED
|
@@ -258,8 +258,16 @@ class RouterManager extends EventEmitter {
|
|
|
258
258
|
return dbSite;
|
|
259
259
|
}
|
|
260
260
|
|
|
261
|
-
async addRoutingRule(
|
|
261
|
+
async addRoutingRule(
|
|
262
|
+
{ id, rule: tempRule, skipCheckDynamicBlacklist = false, formatPathPrefix = true },
|
|
263
|
+
context = {}
|
|
264
|
+
) {
|
|
262
265
|
const { rule } = await validateAddRule({ id, rule: tempRule }, context);
|
|
266
|
+
|
|
267
|
+
if (!formatPathPrefix) {
|
|
268
|
+
rule.from.pathPrefix = tempRule.from.pathPrefix;
|
|
269
|
+
}
|
|
270
|
+
|
|
263
271
|
const dbSite = await states.site.findOne({ _id: id });
|
|
264
272
|
if (!dbSite) {
|
|
265
273
|
throw new Error(`site ${id} does not exist`);
|
|
@@ -275,7 +283,7 @@ class RouterManager extends EventEmitter {
|
|
|
275
283
|
const existedRule = dbSite.rules.find((x) => x.from.pathPrefix === rule.from.pathPrefix);
|
|
276
284
|
|
|
277
285
|
if (existedRule) {
|
|
278
|
-
throw new Error(`path prefix '${originalPathPrefix}' already exists`);
|
|
286
|
+
throw new Error(`addRoutingRule: path prefix '${originalPathPrefix}' already exists`);
|
|
279
287
|
}
|
|
280
288
|
}
|
|
281
289
|
|
|
@@ -294,8 +302,16 @@ class RouterManager extends EventEmitter {
|
|
|
294
302
|
return newSite;
|
|
295
303
|
}
|
|
296
304
|
|
|
297
|
-
async updateRoutingRule(
|
|
305
|
+
async updateRoutingRule(
|
|
306
|
+
{ id, rule: tmpRule, skipProtectedRuleChecking = false, formatPathPrefix = true },
|
|
307
|
+
context = {}
|
|
308
|
+
) {
|
|
298
309
|
const { rule } = await validateEditRule({ id, rule: tmpRule }, context);
|
|
310
|
+
|
|
311
|
+
if (!formatPathPrefix) {
|
|
312
|
+
rule.from.pathPrefix = tmpRule.from.pathPrefix;
|
|
313
|
+
}
|
|
314
|
+
|
|
299
315
|
const dbSite = await states.site.findOne({ _id: id, 'rules.id': rule.id });
|
|
300
316
|
if (!dbSite) {
|
|
301
317
|
throw new Error(`site ${id}, rule ${rule.id} does not exist`);
|
|
@@ -310,7 +326,7 @@ class RouterManager extends EventEmitter {
|
|
|
310
326
|
// Ensure path prefix is unique across the site
|
|
311
327
|
const existedRule = dbSite.rules.find((x) => x.id !== rule.id && x.from.pathPrefix === rule.from.pathPrefix);
|
|
312
328
|
if (existedRule) {
|
|
313
|
-
throw new Error(`path prefix '${originalPathPrefix}' already exists`);
|
|
329
|
+
throw new Error(`updateRoutingRule: path prefix '${originalPathPrefix}' already exists`);
|
|
314
330
|
}
|
|
315
331
|
|
|
316
332
|
// Ensure we are not updating protected rules
|
package/lib/states/blocklet.js
CHANGED
|
@@ -9,14 +9,14 @@ const detectPort = require('detect-port');
|
|
|
9
9
|
const Lock = require('@abtnode/util/lib/lock');
|
|
10
10
|
const security = require('@abtnode/util/lib/security');
|
|
11
11
|
const { fixPerson, fixInterfaces } = require('@blocklet/meta/lib/fix');
|
|
12
|
-
const { getDisplayName, forEachBlocklet, forEachBlockletSync, forEachChildSync } = require('@blocklet/meta/lib/util');
|
|
13
12
|
const {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} = require('@blocklet/
|
|
13
|
+
getDisplayName,
|
|
14
|
+
forEachBlocklet,
|
|
15
|
+
forEachBlockletSync,
|
|
16
|
+
forEachChildSync,
|
|
17
|
+
getBlockletServices,
|
|
18
|
+
} = require('@blocklet/meta/lib/util');
|
|
19
|
+
const { BlockletStatus, BlockletSource, BLOCKLET_MODES, BLOCKLET_DEFAULT_PORT_NAME } = require('@blocklet/constant');
|
|
20
20
|
const { APP_STRUCT_VERSION } = require('@abtnode/constant');
|
|
21
21
|
|
|
22
22
|
const logger = require('@abtnode/logger')('state-blocklet');
|
|
@@ -491,16 +491,34 @@ class BlockletState extends BaseState {
|
|
|
491
491
|
}
|
|
492
492
|
|
|
493
493
|
async getServices() {
|
|
494
|
-
const blocklets = await this.getBlocklets({}, {
|
|
494
|
+
const blocklets = await this.getBlocklets({}, { meta: 1, children: 1, ports: 1 });
|
|
495
495
|
const services = [];
|
|
496
|
+
|
|
496
497
|
blocklets.forEach((blocklet) => {
|
|
497
|
-
const
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
498
|
+
const list = getBlockletServices(blocklet);
|
|
499
|
+
list.forEach((x) => {
|
|
500
|
+
if (!x.port) {
|
|
501
|
+
logger.error('Missing service port', { appId: blocklet.meta.did, x });
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
if (!x.protocol) {
|
|
506
|
+
logger.error('Missing service protocol', { appId: blocklet.meta.did, x });
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
if (!x.upstreamPort) {
|
|
511
|
+
logger.error('Missing service upstreamPort', { appId: blocklet.meta.did, x });
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
if (services.find((s) => s.port === x.port)) {
|
|
516
|
+
// should not be here
|
|
517
|
+
logger.error('Duplicate service port', { appId: blocklet.meta.did, x });
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
services.push(x);
|
|
504
522
|
});
|
|
505
523
|
});
|
|
506
524
|
|
package/lib/states/user.js
CHANGED
|
@@ -24,6 +24,32 @@ const isNullOrUndefined = (x) => x === undefined || x === null;
|
|
|
24
24
|
* @property {string} role - passport's role
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Auth0Account
|
|
29
|
+
* @typedef {Object} Auth0Account
|
|
30
|
+
* @property {'auth0'} provider
|
|
31
|
+
* @property {string} id - id from auth0
|
|
32
|
+
* @property {string} did - did for auth0 account
|
|
33
|
+
* @property {string} pk - pk for auth0 account
|
|
34
|
+
* @property {string} lastLoginAt - Last login time new Date().toISOString()
|
|
35
|
+
* @property {string} firstLoginAt - First login time new Date().toISOString()
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* WalletAccount
|
|
40
|
+
* @typedef {Object} WalletAccount
|
|
41
|
+
* @property {'wallet'} provider
|
|
42
|
+
* @property {string} did - did for auth0 account
|
|
43
|
+
* @property {string} pk - pk for auth0 account
|
|
44
|
+
* @property {string} lastLoginAt - Last login time new Date().toISOString()
|
|
45
|
+
* @property {string} firstLoginAt - First login time new Date().toISOString()
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* ConnectedAccount
|
|
50
|
+
* @typedef {(Auth0Account|WalletAccount)} ConnectedAccount
|
|
51
|
+
*/
|
|
52
|
+
|
|
27
53
|
/**
|
|
28
54
|
* The Data structure of blocklet-service user
|
|
29
55
|
* @typedef {Object} BlockletUser - Blocklet Service User Table
|
|
@@ -31,13 +57,16 @@ const isNullOrUndefined = (x) => x === undefined || x === null;
|
|
|
31
57
|
* @property {('profile')} type - type of user
|
|
32
58
|
* @property {string} fullName - user profile's name
|
|
33
59
|
* @property {string} avatar - url of user's avatar, eg: bn://avatar/7f8848569405f8cdf8b1b2788ebf7d0f.jpg
|
|
34
|
-
* @property {string} did - user's did
|
|
60
|
+
* @property {string} did - user's did -> 实际上变为 uid, 是不可变的;真正的 wallet-did 转移到 extraConfigs 中去了
|
|
61
|
+
* @property {string} pk - user's publicKey
|
|
35
62
|
* @property {('owner'|'admin'|'member'|'guest'|string)} role - user's role
|
|
36
63
|
* @property {UserPassport[]} passports - user's passport list
|
|
37
|
-
* @property {string} pk - user's publicKey
|
|
38
64
|
* @property {boolean} approved - enable user to login
|
|
39
65
|
* @property {string} locale - locale
|
|
40
|
-
* @property {Object} extra - extra data of user
|
|
66
|
+
* @property {Object} [extra] - extra data of user
|
|
67
|
+
* @property {Object} [extraConfigs] - extra data of user
|
|
68
|
+
* @property {ConnectedAccount[]} [extraConfigs.connectedAccounts] - connectedAccounts
|
|
69
|
+
* @property {('wallet'|'auth0')} [extraConfigs.sourceProvider] - sourceProvider, the main account provider
|
|
41
70
|
* @property {Date} firstLoginAt - firstLoginAt
|
|
42
71
|
* @property {Date} lastLoginAt - lastLoginAt
|
|
43
72
|
* @property {string} lastLoginIp - lastLoginIp
|
|
@@ -139,7 +168,7 @@ class User extends BaseState {
|
|
|
139
168
|
/**
|
|
140
169
|
* update user's role
|
|
141
170
|
* @param {string} did user's did
|
|
142
|
-
* @param {BlockletUser.role} role user's
|
|
171
|
+
* @param {BlockletUser.role} role user's role
|
|
143
172
|
* @returns {BlockletUser}
|
|
144
173
|
*/
|
|
145
174
|
async updateRole({ did, role }) {
|
|
@@ -160,7 +189,7 @@ class User extends BaseState {
|
|
|
160
189
|
* @returns {{list: BlockletUser[]; paging: any;}}
|
|
161
190
|
*/
|
|
162
191
|
async getUsers({ query, sort, paging: inputPaging } = {}) {
|
|
163
|
-
const { approved, role, search,
|
|
192
|
+
const { approved, role, search, connectedDid } = query || {};
|
|
164
193
|
|
|
165
194
|
// make query param
|
|
166
195
|
const queryParam = {};
|
|
@@ -191,9 +220,9 @@ class User extends BaseState {
|
|
|
191
220
|
}
|
|
192
221
|
}
|
|
193
222
|
|
|
194
|
-
// 根据
|
|
195
|
-
if (
|
|
196
|
-
queryParam['extraConfigs.
|
|
223
|
+
// 根据 connectedDid 查询 user 信息(wallet 账户绑定 oauth 账户后,会有该字段)
|
|
224
|
+
if (connectedDid) {
|
|
225
|
+
queryParam['extraConfigs.connectedAccounts.did'] = connectedDid;
|
|
197
226
|
}
|
|
198
227
|
|
|
199
228
|
const sortParam = pickBy(sort, (x) => !isNullOrUndefined(x));
|
package/lib/util/blocklet.js
CHANGED
|
@@ -77,6 +77,7 @@ const {
|
|
|
77
77
|
getComponentName,
|
|
78
78
|
isEnvShareable,
|
|
79
79
|
getBlockletAppIdList,
|
|
80
|
+
isBeforeInstalled,
|
|
80
81
|
} = require('@blocklet/meta/lib/util');
|
|
81
82
|
const toBlockletDid = require('@blocklet/meta/lib/did');
|
|
82
83
|
const { titleSchema, descriptionSchema, logoSchema } = require('@blocklet/meta/lib/schema');
|
|
@@ -91,14 +92,7 @@ const { validate: validateEngine, get: getEngine } = require('../blocklet/manage
|
|
|
91
92
|
|
|
92
93
|
const isRequirementsSatisfied = require('./requirement');
|
|
93
94
|
const { getDidDomainForBlocklet } = require('./get-domain-for-blocklet');
|
|
94
|
-
const {
|
|
95
|
-
isBeforeInstalled,
|
|
96
|
-
expandBundle,
|
|
97
|
-
findInterfacePortByName,
|
|
98
|
-
prettyURL,
|
|
99
|
-
getNFTState,
|
|
100
|
-
templateReplace,
|
|
101
|
-
} = require('./index');
|
|
95
|
+
const { expandBundle, findInterfacePortByName, prettyURL, getNFTState, templateReplace } = require('./index');
|
|
102
96
|
|
|
103
97
|
const getComponentConfig = (meta) => {
|
|
104
98
|
const components = meta.components || meta.children || [];
|
package/lib/util/index.js
CHANGED
|
@@ -17,7 +17,7 @@ const axios = require('@abtnode/util/lib/axios');
|
|
|
17
17
|
const { encode: encodeBase32 } = require('@abtnode/util/lib/base32');
|
|
18
18
|
const parseBlockletMeta = require('@blocklet/meta/lib/parse');
|
|
19
19
|
const { BlockletStatus } = require('@blocklet/constant');
|
|
20
|
-
const { replaceSlotToIp } = require('@blocklet/meta/lib/util');
|
|
20
|
+
const { replaceSlotToIp, isInProgress } = require('@blocklet/meta/lib/util');
|
|
21
21
|
const {
|
|
22
22
|
StatusCode,
|
|
23
23
|
DOMAIN_FOR_DEFAULT_SITE,
|
|
@@ -93,21 +93,6 @@ const getBlockletHost = ({ domain, context, nodeIp }) => {
|
|
|
93
93
|
|
|
94
94
|
const isRoutingEnabled = (routing) => !!routing && !!routing.provider;
|
|
95
95
|
|
|
96
|
-
const isInProgress = (status) =>
|
|
97
|
-
[
|
|
98
|
-
BlockletStatus.downloading,
|
|
99
|
-
BlockletStatus.waiting,
|
|
100
|
-
BlockletStatus.starting,
|
|
101
|
-
BlockletStatus.installing,
|
|
102
|
-
BlockletStatus.stopping,
|
|
103
|
-
BlockletStatus.upgrading,
|
|
104
|
-
].includes(status);
|
|
105
|
-
|
|
106
|
-
const isBeforeInstalled = (status) =>
|
|
107
|
-
[BlockletStatus.added, BlockletStatus.waiting, BlockletStatus.downloading, BlockletStatus.installing].includes(
|
|
108
|
-
status
|
|
109
|
-
);
|
|
110
|
-
|
|
111
96
|
// Check whether a domain is setup
|
|
112
97
|
const checkDomainDNS = (domain) =>
|
|
113
98
|
new Promise((resolve) => {
|
|
@@ -479,8 +464,6 @@ const lib = {
|
|
|
479
464
|
toStatus,
|
|
480
465
|
fromStatus,
|
|
481
466
|
formatEnvironments,
|
|
482
|
-
isInProgress,
|
|
483
|
-
isBeforeInstalled,
|
|
484
467
|
replaceDomainSlot,
|
|
485
468
|
getBlockletHost,
|
|
486
469
|
isRoutingEnabled,
|
package/lib/validators/router.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable newline-per-chained-call */
|
|
2
2
|
const Joi = require('joi');
|
|
3
3
|
const { DOMAIN_FOR_DEFAULT_SITE, ROUTING_RULE_TYPES, ROUTER_CACHE_GROUPS } = require('@abtnode/constant');
|
|
4
|
-
const
|
|
4
|
+
const urlPathFriendly = require('@blocklet/meta/lib/url-path-friendly').default;
|
|
5
5
|
const { getMultipleLangParams } = require('./util');
|
|
6
6
|
|
|
7
7
|
const WILDCARD_DOMAIN_REGEX = /^\*.(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]/;
|
|
@@ -29,7 +29,7 @@ const ruleSchema = {
|
|
|
29
29
|
zh: { 'string.empty': 'URL 前缀不能为空', 'string.max': 'URL 前缀的最大长度是 150' },
|
|
30
30
|
en: { 'string.empty': 'URL prefix cannot be empty', 'string.max': 'The maximum length of URL prefix is 150' },
|
|
31
31
|
})
|
|
32
|
-
.custom((value) =>
|
|
32
|
+
.custom((value) => urlPathFriendly(value)),
|
|
33
33
|
groupPathPrefix: Joi.string().trim().min(1).max(150), // path prefix of interface of root blocklet
|
|
34
34
|
header: Joi.any(), // TODO: header does not take effect
|
|
35
35
|
}),
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.4
|
|
6
|
+
"version": "1.16.4",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -19,18 +19,18 @@
|
|
|
19
19
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@abtnode/auth": "1.16.4
|
|
23
|
-
"@abtnode/certificate-manager": "1.16.4
|
|
24
|
-
"@abtnode/constant": "1.16.4
|
|
25
|
-
"@abtnode/cron": "1.16.4
|
|
26
|
-
"@abtnode/db": "1.16.4
|
|
27
|
-
"@abtnode/logger": "1.16.4
|
|
28
|
-
"@abtnode/queue": "1.16.4
|
|
29
|
-
"@abtnode/rbac": "1.16.4
|
|
30
|
-
"@abtnode/router-provider": "1.16.4
|
|
31
|
-
"@abtnode/static-server": "1.16.4
|
|
32
|
-
"@abtnode/timemachine": "1.16.4
|
|
33
|
-
"@abtnode/util": "1.16.4
|
|
22
|
+
"@abtnode/auth": "1.16.4",
|
|
23
|
+
"@abtnode/certificate-manager": "1.16.4",
|
|
24
|
+
"@abtnode/constant": "1.16.4",
|
|
25
|
+
"@abtnode/cron": "1.16.4",
|
|
26
|
+
"@abtnode/db": "1.16.4",
|
|
27
|
+
"@abtnode/logger": "1.16.4",
|
|
28
|
+
"@abtnode/queue": "1.16.4",
|
|
29
|
+
"@abtnode/rbac": "1.16.4",
|
|
30
|
+
"@abtnode/router-provider": "1.16.4",
|
|
31
|
+
"@abtnode/static-server": "1.16.4",
|
|
32
|
+
"@abtnode/timemachine": "1.16.4",
|
|
33
|
+
"@abtnode/util": "1.16.4",
|
|
34
34
|
"@arcblock/did": "1.18.67",
|
|
35
35
|
"@arcblock/did-motif": "^1.1.10",
|
|
36
36
|
"@arcblock/did-util": "1.18.67",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"@arcblock/jwt": "^1.18.67",
|
|
39
39
|
"@arcblock/pm2-events": "^0.0.5",
|
|
40
40
|
"@arcblock/vc": "1.18.67",
|
|
41
|
-
"@blocklet/constant": "1.16.4
|
|
42
|
-
"@blocklet/meta": "1.16.4
|
|
43
|
-
"@blocklet/sdk": "1.16.4
|
|
41
|
+
"@blocklet/constant": "1.16.4",
|
|
42
|
+
"@blocklet/meta": "1.16.4",
|
|
43
|
+
"@blocklet/sdk": "1.16.4",
|
|
44
44
|
"@did-space/client": "^0.2.67",
|
|
45
45
|
"@fidm/x509": "^1.2.1",
|
|
46
46
|
"@ocap/client": "1.18.67",
|
|
@@ -93,5 +93,5 @@
|
|
|
93
93
|
"express": "^4.18.2",
|
|
94
94
|
"jest": "^27.5.1"
|
|
95
95
|
},
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "8d1062af0f4e4f491b6a7205c9d6542328ca6b20"
|
|
97
97
|
}
|