@abtnode/core 1.16.26-beta-4831bf3f → 1.16.26-beta-346cba92
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
CHANGED
|
@@ -1329,6 +1329,11 @@ class TeamAPI extends EventEmitter {
|
|
|
1329
1329
|
|
|
1330
1330
|
const store = await StoreUtil.getStoreMeta(sanitized);
|
|
1331
1331
|
|
|
1332
|
+
const existById = storeList.find((x) => x.id === store.id);
|
|
1333
|
+
if (existById) {
|
|
1334
|
+
throw new Error(`Blocklet registry already exist: ${sanitized}`);
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1332
1337
|
storeList.push({ ...store, url: sanitized, protected: false });
|
|
1333
1338
|
|
|
1334
1339
|
return this.teamManager.updateStoreList(teamDid, storeList);
|
|
@@ -11,6 +11,7 @@ const pick = require('lodash/pick');
|
|
|
11
11
|
const isEmpty = require('lodash/isEmpty');
|
|
12
12
|
const cloneDeep = require('lodash/cloneDeep');
|
|
13
13
|
const { sign } = require('@arcblock/jwt');
|
|
14
|
+
const { isInServerlessMode } = require('@abtnode/util/lib/serverless');
|
|
14
15
|
const sleep = require('@abtnode/util/lib/sleep');
|
|
15
16
|
const getBlockletInfo = require('@blocklet/meta/lib/info');
|
|
16
17
|
const joinUrl = require('url-join');
|
|
@@ -21,7 +22,6 @@ const {
|
|
|
21
22
|
WHO_CAN_ACCESS,
|
|
22
23
|
WHO_CAN_ACCESS_PREFIX_ROLES,
|
|
23
24
|
BLOCKLET_INSTALL_TYPE,
|
|
24
|
-
NODE_MODES,
|
|
25
25
|
APP_STRUCT_VERSION,
|
|
26
26
|
BLOCKLET_CACHE_TTL,
|
|
27
27
|
MONITOR_RECORD_INTERVAL_SEC,
|
|
@@ -60,7 +60,7 @@ const { titleSchema, updateMountPointSchema, environmentNameSchema } = require('
|
|
|
60
60
|
const { emailConfigSchema } = require('@blocklet/sdk/lib/validators/email');
|
|
61
61
|
const { encrypt } = require('@blocklet/sdk/lib/security');
|
|
62
62
|
const Lock = require('@abtnode/util/lib/lock');
|
|
63
|
-
const { getComponentApiKey } = require('@abtnode/util/lib/blocklet');
|
|
63
|
+
const { getComponentApiKey, getBlockletLogos } = require('@abtnode/util/lib/blocklet');
|
|
64
64
|
const defaults = require('lodash/defaults');
|
|
65
65
|
|
|
66
66
|
const {
|
|
@@ -230,6 +230,8 @@ const getWalletAppNotification = async (blocklet, tempBlockletInfo) => {
|
|
|
230
230
|
blockletInfo = getBlockletInfo(blocklet, nodeInfo.sk);
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
+
const { appLogo } = getBlockletLogos(blocklet);
|
|
234
|
+
|
|
233
235
|
return {
|
|
234
236
|
actions: [
|
|
235
237
|
{
|
|
@@ -243,12 +245,7 @@ const getWalletAppNotification = async (blocklet, tempBlockletInfo) => {
|
|
|
243
245
|
data: {
|
|
244
246
|
url: blockletInfo.appUrl,
|
|
245
247
|
appDID: blocklet.appPid,
|
|
246
|
-
logo:
|
|
247
|
-
blocklet.environmentObj.BLOCKLET_APP_LOGO ||
|
|
248
|
-
joinUrl(
|
|
249
|
-
blockletInfo.appUrl,
|
|
250
|
-
normalizePathPrefix(joinUrl(WELLKNOWN_SERVICE_PATH_PREFIX, '/blocklet/logo')) || '/'
|
|
251
|
-
),
|
|
248
|
+
logo: appLogo,
|
|
252
249
|
title: blockletInfo.name,
|
|
253
250
|
desc: blockletInfo.description,
|
|
254
251
|
},
|
|
@@ -528,7 +525,7 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
528
525
|
if (file) {
|
|
529
526
|
// TODO: 如何触发这种场景?
|
|
530
527
|
const info = await states.node.read();
|
|
531
|
-
if (info
|
|
528
|
+
if (isInServerlessMode(info)) {
|
|
532
529
|
throw new Error("Can't install component in serverless-mode server via upload");
|
|
533
530
|
}
|
|
534
531
|
|
|
@@ -547,7 +544,7 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
547
544
|
|
|
548
545
|
if (url) {
|
|
549
546
|
const info = await states.node.read();
|
|
550
|
-
if (info
|
|
547
|
+
if (isInServerlessMode(info)) {
|
|
551
548
|
validateStore(info, url);
|
|
552
549
|
}
|
|
553
550
|
|
|
@@ -874,6 +871,8 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
874
871
|
|
|
875
872
|
logger.info('blocklet stopped successfully', { processId, did });
|
|
876
873
|
|
|
874
|
+
launcher.notifyBlockletUpdated(blocklet);
|
|
875
|
+
|
|
877
876
|
if (updateStatus) {
|
|
878
877
|
const res = await states.blocklet.setBlockletStatus(did, BlockletStatus.stopped, { componentDids });
|
|
879
878
|
// send notification to websocket channel
|
|
@@ -1571,6 +1570,12 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
1571
1570
|
];
|
|
1572
1571
|
|
|
1573
1572
|
const shouldSendWalletNotification = observableConfigs.some((x) => newConfigs.some((y) => y.key === x));
|
|
1573
|
+
|
|
1574
|
+
if (shouldSendWalletNotification) {
|
|
1575
|
+
// notify launcher config changed
|
|
1576
|
+
launcher.notifyBlockletUpdated(blocklet);
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1574
1579
|
const receiverUsers = await this.teamManager.getOwnerAndAdminUsers(newState.appPid, 1);
|
|
1575
1580
|
const receivers = receiverUsers.map((x) => x.did);
|
|
1576
1581
|
|
|
@@ -2081,7 +2086,7 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
2081
2086
|
},
|
|
2082
2087
|
];
|
|
2083
2088
|
|
|
2084
|
-
if (info
|
|
2089
|
+
if (isInServerlessMode(info)) {
|
|
2085
2090
|
const serverlessJobs = [
|
|
2086
2091
|
{
|
|
2087
2092
|
name: 'check-renewed-blocklet',
|
|
@@ -2666,6 +2671,8 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
2666
2671
|
severity: 'success',
|
|
2667
2672
|
});
|
|
2668
2673
|
|
|
2674
|
+
launcher.notifyBlockletUpdated(blocklet);
|
|
2675
|
+
|
|
2669
2676
|
logger.info('blocklet healthy', { did, name, time: Date.now() - startedAt });
|
|
2670
2677
|
} catch (error) {
|
|
2671
2678
|
const status = await states.blocklet.getBlockletStatus(did);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const joi = require('joi');
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const { isInServerlessMode } = require('@abtnode/util/lib/serverless');
|
|
4
|
+
const { BLOCKLET_INSTALL_TYPE, INSTALL_ACTIONS } = require('@abtnode/constant');
|
|
4
5
|
const { BlockletStatus, BlockletEvents, BLOCKLET_CONFIGURABLE_KEY } = require('@blocklet/constant');
|
|
5
6
|
|
|
6
7
|
const logger = require('@abtnode/logger')('@abtnode/core:install-app-general');
|
|
@@ -64,7 +65,7 @@ const installApplicationFromGeneral = async ({
|
|
|
64
65
|
blockletWalletType = blockletWalletTypeEnv.default;
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
if (nodeInfo
|
|
68
|
+
if (isInServerlessMode(nodeInfo)) {
|
|
68
69
|
validateInServerless({ blockletMeta: meta });
|
|
69
70
|
}
|
|
70
71
|
|
package/lib/team/manager.js
CHANGED
|
@@ -301,14 +301,25 @@ class TeamManager extends EventEmitter {
|
|
|
301
301
|
}
|
|
302
302
|
|
|
303
303
|
async getStoreList(did) {
|
|
304
|
+
const nodeInfo = await this.states.node.read();
|
|
305
|
+
const blockletRegistryList = nodeInfo.blockletRegistryList || [];
|
|
304
306
|
if (this.isNodeTeam(did)) {
|
|
305
|
-
|
|
306
|
-
return nodeInfo.blockletRegistryList || [];
|
|
307
|
+
return blockletRegistryList;
|
|
307
308
|
}
|
|
308
309
|
|
|
309
310
|
const metaDid = await this.states.blocklet.getBlockletMetaDid(did);
|
|
310
311
|
const settings = await this.states.blockletExtras.getSettings(metaDid);
|
|
311
|
-
|
|
312
|
+
const storeList = get(settings, 'storeList', []) || [];
|
|
313
|
+
|
|
314
|
+
blockletRegistryList.forEach((store) => {
|
|
315
|
+
if (!storeList.find((x) => x.id === store.id)) {
|
|
316
|
+
storeList.push({
|
|
317
|
+
...store,
|
|
318
|
+
protected: true,
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
return storeList;
|
|
312
323
|
}
|
|
313
324
|
|
|
314
325
|
async updateStoreList(did, list) {
|
package/lib/util/blocklet.js
CHANGED
|
@@ -37,7 +37,8 @@ const {
|
|
|
37
37
|
BLOCKLET_MAX_MEM_LIMIT_IN_MB,
|
|
38
38
|
BLOCKLET_INSTALL_TYPE,
|
|
39
39
|
APP_STRUCT_VERSION,
|
|
40
|
-
|
|
40
|
+
BLOCKLET_STORE,
|
|
41
|
+
BLOCKLET_STORE_DEV,
|
|
41
42
|
} = require('@abtnode/constant');
|
|
42
43
|
const {
|
|
43
44
|
parseComponents,
|
|
@@ -97,6 +98,7 @@ const { getComponentsInternalInfo } = require('@blocklet/meta/lib/blocklet');
|
|
|
97
98
|
const { titleSchema, descriptionSchema, logoSchema } = require('@blocklet/meta/lib/schema');
|
|
98
99
|
const { getBlockletMetaFromUrl } = require('@blocklet/meta/lib/util-meta');
|
|
99
100
|
const getComponentProcessId = require('@blocklet/meta/lib/get-component-process-id');
|
|
101
|
+
const { isInServerlessMode } = require('@abtnode/util/lib/serverless');
|
|
100
102
|
const md5 = require('@abtnode/util/lib/md5');
|
|
101
103
|
|
|
102
104
|
const { validate: validateEngine, get: getEngine } = require('../blocklet/manager/engine');
|
|
@@ -1304,6 +1306,27 @@ const getBlocklet = async ({
|
|
|
1304
1306
|
|
|
1305
1307
|
const nodeInfo = await states.node.read();
|
|
1306
1308
|
|
|
1309
|
+
// FIXME: 梁柱, 下面的代码块, 在 1.16.29 之后的版本, 可以删除
|
|
1310
|
+
{
|
|
1311
|
+
// 对于历史项目, server.db -> servers -> blockletRegistryList 已经存储了没有 id 的 store, 这里需要兼容处理
|
|
1312
|
+
let isNeedFixRedundantData = false;
|
|
1313
|
+
const urlToId = {
|
|
1314
|
+
[BLOCKLET_STORE.url]: BLOCKLET_STORE.id,
|
|
1315
|
+
[BLOCKLET_STORE_DEV.url]: BLOCKLET_STORE_DEV.id,
|
|
1316
|
+
};
|
|
1317
|
+
(nodeInfo?.blockletRegistryList || []).forEach((store) => {
|
|
1318
|
+
if (!store.id) {
|
|
1319
|
+
store.id = urlToId[store.url];
|
|
1320
|
+
isNeedFixRedundantData = true;
|
|
1321
|
+
}
|
|
1322
|
+
});
|
|
1323
|
+
|
|
1324
|
+
// 更新历史数据中遗漏的 store id, 方便后期删除这段代码
|
|
1325
|
+
if (isNeedFixRedundantData) {
|
|
1326
|
+
await states.node.updateNodeInfo({ blockletRegistryList: nodeInfo.blockletRegistryList });
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1307
1330
|
(nodeInfo?.blockletRegistryList || []).forEach((store) => {
|
|
1308
1331
|
if (!blocklet.settings.storeList.find((x) => x.url === store.url)) {
|
|
1309
1332
|
blocklet.settings.storeList.push({
|
|
@@ -1313,7 +1336,6 @@ const getBlocklet = async ({
|
|
|
1313
1336
|
}
|
|
1314
1337
|
});
|
|
1315
1338
|
|
|
1316
|
-
// app site
|
|
1317
1339
|
blocklet.site = await states.site.findOneByBlocklet(blocklet.meta.did);
|
|
1318
1340
|
|
|
1319
1341
|
await forEachBlocklet(blocklet, async (component, { id, level, ancestors }) => {
|
|
@@ -1859,7 +1881,7 @@ const shouldEnableSlpDomain = ({ mode, launcher }) => {
|
|
|
1859
1881
|
return true;
|
|
1860
1882
|
}
|
|
1861
1883
|
|
|
1862
|
-
return mode
|
|
1884
|
+
return isInServerlessMode({ mode }) && !!launcher;
|
|
1863
1885
|
};
|
|
1864
1886
|
|
|
1865
1887
|
const getSlpDid = (serverDid, appPid) => {
|
package/lib/util/launcher.js
CHANGED
|
@@ -15,12 +15,13 @@ const {
|
|
|
15
15
|
const { Hasher } = require('@ocap/mcrypto');
|
|
16
16
|
const { getDisplayName } = require('@blocklet/meta/lib/util');
|
|
17
17
|
const getBlockletInfo = require('@blocklet/meta/lib/info');
|
|
18
|
+
const { getBlockletLogos } = require('@abtnode/util/lib/blocklet');
|
|
18
19
|
|
|
19
20
|
const { getLauncherUser, getLauncherSession: getLauncherSessionRaw, doRequest } = require('@abtnode/auth/lib/launcher');
|
|
20
21
|
const { createAuthToken, getPassportStatusEndpoint } = require('@abtnode/auth/lib/auth');
|
|
21
22
|
const { createPassportVC, createPassport, createUserPassport } = require('@abtnode/auth/lib/passport');
|
|
22
23
|
|
|
23
|
-
const { LOGIN_PROVIDER } = require('@blocklet/constant');
|
|
24
|
+
const { LOGIN_PROVIDER, fromBlockletStatus } = require('@blocklet/constant');
|
|
24
25
|
const {
|
|
25
26
|
WELLKNOWN_SERVICE_PATH_PREFIX,
|
|
26
27
|
NODE_DATA_DIR_NAME,
|
|
@@ -94,6 +95,55 @@ const reportComponentsEvent = async ({ blocklet, dids, type, time }) => {
|
|
|
94
95
|
}
|
|
95
96
|
};
|
|
96
97
|
|
|
98
|
+
const notifyBlockletUpdated = async (blocklet) => {
|
|
99
|
+
const { controller } = blocklet;
|
|
100
|
+
|
|
101
|
+
if (!controller) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
logger.info('notify blocklet updated', { controller, blockletPid: blocklet.appPid });
|
|
106
|
+
|
|
107
|
+
try {
|
|
108
|
+
const info = await states.node.read();
|
|
109
|
+
|
|
110
|
+
const blockletInfo = getBlockletInfo(blocklet, info.sk);
|
|
111
|
+
const { appLogo, appLogoRect } = getBlockletLogos(blocklet);
|
|
112
|
+
|
|
113
|
+
const payload = {
|
|
114
|
+
type: 'serverless.blocklet.updated',
|
|
115
|
+
payload: {
|
|
116
|
+
did: blocklet.appDid,
|
|
117
|
+
appId: blocklet.appDid,
|
|
118
|
+
appName: blockletInfo.name,
|
|
119
|
+
appDescription: blockletInfo.description,
|
|
120
|
+
status: fromBlockletStatus(blocklet.status),
|
|
121
|
+
appUrl: blockletInfo.url,
|
|
122
|
+
appLogo,
|
|
123
|
+
appLogoRect,
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
logger.info('notify blocklet updated payload', { controller, blockletPid: blocklet.appPid, payload });
|
|
128
|
+
|
|
129
|
+
const result = await doRequest(info.sk, {
|
|
130
|
+
launcherUrl: controller.launcherUrl,
|
|
131
|
+
pathname: `/api/launches/${controller.launcherSessionId}/webhook`,
|
|
132
|
+
payload,
|
|
133
|
+
method: 'post',
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
logger.info('notified blocklet updated', {
|
|
137
|
+
controller,
|
|
138
|
+
blockletPid: blocklet.appPid,
|
|
139
|
+
result,
|
|
140
|
+
});
|
|
141
|
+
} catch (error) {
|
|
142
|
+
logger.error('notify blocklet updated failed', { controller, blockletPid: blocklet.appPid, error });
|
|
143
|
+
throw new Error(`notify blocklet updated failed ${blocklet.appPid}`);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
|
|
97
147
|
const consumeLauncherSession = async ({ params, blocklet }) => {
|
|
98
148
|
try {
|
|
99
149
|
const info = await states.node.read();
|
|
@@ -340,4 +390,5 @@ module.exports = {
|
|
|
340
390
|
isLauncherSessionConsumed,
|
|
341
391
|
isBlockletExpired,
|
|
342
392
|
isBlockletTerminated,
|
|
393
|
+
notifyBlockletUpdated,
|
|
343
394
|
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.26-beta-
|
|
6
|
+
"version": "1.16.26-beta-346cba92",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -19,19 +19,19 @@
|
|
|
19
19
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
20
20
|
"license": "Apache-2.0",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@abtnode/analytics": "1.16.26-beta-
|
|
23
|
-
"@abtnode/auth": "1.16.26-beta-
|
|
24
|
-
"@abtnode/certificate-manager": "1.16.26-beta-
|
|
25
|
-
"@abtnode/constant": "1.16.26-beta-
|
|
26
|
-
"@abtnode/cron": "1.16.26-beta-
|
|
27
|
-
"@abtnode/logger": "1.16.26-beta-
|
|
28
|
-
"@abtnode/models": "1.16.26-beta-
|
|
29
|
-
"@abtnode/queue": "1.16.26-beta-
|
|
30
|
-
"@abtnode/rbac": "1.16.26-beta-
|
|
31
|
-
"@abtnode/router-provider": "1.16.26-beta-
|
|
32
|
-
"@abtnode/static-server": "1.16.26-beta-
|
|
33
|
-
"@abtnode/timemachine": "1.16.26-beta-
|
|
34
|
-
"@abtnode/util": "1.16.26-beta-
|
|
22
|
+
"@abtnode/analytics": "1.16.26-beta-346cba92",
|
|
23
|
+
"@abtnode/auth": "1.16.26-beta-346cba92",
|
|
24
|
+
"@abtnode/certificate-manager": "1.16.26-beta-346cba92",
|
|
25
|
+
"@abtnode/constant": "1.16.26-beta-346cba92",
|
|
26
|
+
"@abtnode/cron": "1.16.26-beta-346cba92",
|
|
27
|
+
"@abtnode/logger": "1.16.26-beta-346cba92",
|
|
28
|
+
"@abtnode/models": "1.16.26-beta-346cba92",
|
|
29
|
+
"@abtnode/queue": "1.16.26-beta-346cba92",
|
|
30
|
+
"@abtnode/rbac": "1.16.26-beta-346cba92",
|
|
31
|
+
"@abtnode/router-provider": "1.16.26-beta-346cba92",
|
|
32
|
+
"@abtnode/static-server": "1.16.26-beta-346cba92",
|
|
33
|
+
"@abtnode/timemachine": "1.16.26-beta-346cba92",
|
|
34
|
+
"@abtnode/util": "1.16.26-beta-346cba92",
|
|
35
35
|
"@arcblock/did": "1.18.115",
|
|
36
36
|
"@arcblock/did-auth": "1.18.115",
|
|
37
37
|
"@arcblock/did-ext": "^1.18.115",
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
"@arcblock/pm2-events": "^0.0.5",
|
|
43
43
|
"@arcblock/validator": "^1.18.115",
|
|
44
44
|
"@arcblock/vc": "1.18.115",
|
|
45
|
-
"@blocklet/constant": "1.16.26-beta-
|
|
46
|
-
"@blocklet/env": "1.16.26-beta-
|
|
47
|
-
"@blocklet/meta": "1.16.26-beta-
|
|
48
|
-
"@blocklet/resolver": "1.16.26-beta-
|
|
49
|
-
"@blocklet/sdk": "1.16.26-beta-
|
|
50
|
-
"@blocklet/store": "1.16.26-beta-
|
|
45
|
+
"@blocklet/constant": "1.16.26-beta-346cba92",
|
|
46
|
+
"@blocklet/env": "1.16.26-beta-346cba92",
|
|
47
|
+
"@blocklet/meta": "1.16.26-beta-346cba92",
|
|
48
|
+
"@blocklet/resolver": "1.16.26-beta-346cba92",
|
|
49
|
+
"@blocklet/sdk": "1.16.26-beta-346cba92",
|
|
50
|
+
"@blocklet/store": "1.16.26-beta-346cba92",
|
|
51
51
|
"@did-space/client": "^0.3.76",
|
|
52
52
|
"@fidm/x509": "^1.2.1",
|
|
53
53
|
"@ocap/mcrypto": "1.18.115",
|
|
@@ -103,5 +103,5 @@
|
|
|
103
103
|
"jest": "^29.7.0",
|
|
104
104
|
"unzipper": "^0.10.11"
|
|
105
105
|
},
|
|
106
|
-
"gitHead": "
|
|
106
|
+
"gitHead": "389bb6584585302b9b12ec7133c73cb28b0d663b"
|
|
107
107
|
}
|