@abtnode/core 1.16.18-beta-adeeb0b3 → 1.16.18-beta-aa01bd8e
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 +70 -31
- package/lib/blocklet/extras.js +1 -1
- package/lib/blocklet/manager/disk.js +24 -26
- package/lib/blocklet/manager/helper/install-component-from-upload.js +8 -3
- package/lib/blocklet/manager/helper/install-component-from-url.js +4 -3
- package/lib/blocklet/project/index.js +26 -21
- package/lib/event/auto-backup-handler.js +1 -1
- package/lib/index.js +1 -0
- package/lib/states/audit-log.js +1 -1
- package/lib/states/blocklet.js +7 -0
- package/lib/states/project.js +13 -4
- package/lib/util/federated.js +19 -0
- package/package.json +32 -32
package/lib/api/team.js
CHANGED
|
@@ -42,7 +42,7 @@ const { validateCreatePermission, validateUpdatePermission } = require('../valid
|
|
|
42
42
|
const { getBlocklet } = require('../util/blocklet');
|
|
43
43
|
const StoreUtil = require('../util/store');
|
|
44
44
|
const { profileSchema } = require('../validators/user');
|
|
45
|
-
const { callFederated } = require('../util/federated');
|
|
45
|
+
const { callFederated, getFederatedMaster, findFederatedSite } = require('../util/federated');
|
|
46
46
|
|
|
47
47
|
const sanitizeUrl = (url) => {
|
|
48
48
|
if (!url) {
|
|
@@ -1409,7 +1409,20 @@ class TeamAPI extends EventEmitter {
|
|
|
1409
1409
|
return result;
|
|
1410
1410
|
}
|
|
1411
1411
|
|
|
1412
|
-
|
|
1412
|
+
/**
|
|
1413
|
+
* 新增|更新一个 userSession
|
|
1414
|
+
* @param {string} params.teamDid - 当前更新的这个应用的 teamDid
|
|
1415
|
+
* @param {string} params.appPid - 记录的 userSession 中应用的 appPid
|
|
1416
|
+
* @param {string} params.userDid - 记录的 userSession 中当前用户的 did
|
|
1417
|
+
* @param {string} params.visitorId - 记录的 userSession 中当前用户所使用设备的 visitorId
|
|
1418
|
+
* @param {string} params.ua - 记录的 userSession 中当前用户所使用设备的 ua
|
|
1419
|
+
* @param {string} params.lastLoginIp - 记录的 userSession 中当前用户的最后登录 ip
|
|
1420
|
+
* @param {string} params.passportId - 记录的 userSession 中当前用户登录所使用的 passportId
|
|
1421
|
+
* @param {string} params.status - 记录的 userSession 的状态
|
|
1422
|
+
* @returns
|
|
1423
|
+
*/
|
|
1424
|
+
|
|
1425
|
+
async upsertUserSession({ teamDid, appPid, userDid, visitorId, ua, lastLoginIp, passportId, status }) {
|
|
1413
1426
|
if (!userDid) {
|
|
1414
1427
|
throw new Error('userDid are required');
|
|
1415
1428
|
}
|
|
@@ -1443,62 +1456,88 @@ class TeamAPI extends EventEmitter {
|
|
|
1443
1456
|
}
|
|
1444
1457
|
}
|
|
1445
1458
|
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1459
|
+
return data;
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
/**
|
|
1463
|
+
* 同步一个 userSession(userSession 只能向 master 同步,或 master 向 member 同步,不能由 member 向 member 同步)
|
|
1464
|
+
* @param {string} params.teamDid - 当前更新的这个应用的 teamDid
|
|
1465
|
+
* @param {string} params.targetAppPid - 同步的 userSession 的目标站点 appPid
|
|
1466
|
+
* @param {string} params.userDid - 同步的 userSession 中当前用户的 did
|
|
1467
|
+
* @param {string} params.visitorId - 同步的 userSession 中当前用户所使用设备的 visitorId
|
|
1468
|
+
* @param {string} params.ua - 同步的 userSession 中当前用户所使用设备的 ua
|
|
1469
|
+
* @param {string} params.lastLoginIp - 同步的 userSession 中当前用户的最后登录 ip
|
|
1470
|
+
* @param {string} params.passportId - 同步的 userSession 中当前用户登录所使用的 passportId
|
|
1471
|
+
* @returns
|
|
1472
|
+
*/
|
|
1473
|
+
async syncUserSession({ teamDid, targetAppPid, userDid, visitorId, ua, lastLoginIp, passportId }) {
|
|
1474
|
+
if (!targetAppPid) return;
|
|
1475
|
+
|
|
1476
|
+
const blocklet = await getBlocklet({ did: teamDid, states: this.states, dataDirs: this.dataDirs });
|
|
1477
|
+
const nodeInfo = await this.node.read();
|
|
1478
|
+
const { permanentWallet } = getBlockletInfo(blocklet, nodeInfo.sk);
|
|
1479
|
+
|
|
1480
|
+
const targetSite = findFederatedSite(blocklet, targetAppPid);
|
|
1481
|
+
const masterSite = getFederatedMaster(blocklet);
|
|
1482
|
+
|
|
1483
|
+
let syncSite = null;
|
|
1484
|
+
let appPid;
|
|
1485
|
+
if (masterSite && targetSite) {
|
|
1486
|
+
if (targetSite.appPid === masterSite.appPid) {
|
|
1487
|
+
if (teamDid !== masterSite.appPid) {
|
|
1488
|
+
syncSite = masterSite;
|
|
1489
|
+
appPid = teamDid;
|
|
1490
|
+
}
|
|
1491
|
+
} else if (teamDid === masterSite.appPid) {
|
|
1492
|
+
syncSite = targetSite;
|
|
1493
|
+
appPid = targetAppPid;
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
if (syncSite) {
|
|
1456
1497
|
try {
|
|
1498
|
+
const userSession = {
|
|
1499
|
+
action: 'login',
|
|
1500
|
+
userDid,
|
|
1501
|
+
visitorId,
|
|
1502
|
+
ua,
|
|
1503
|
+
lastLoginIp,
|
|
1504
|
+
appPid,
|
|
1505
|
+
passportId,
|
|
1506
|
+
};
|
|
1457
1507
|
await callFederated({
|
|
1458
1508
|
action: 'sync',
|
|
1459
1509
|
permanentWallet,
|
|
1460
|
-
site:
|
|
1510
|
+
site: targetSite,
|
|
1461
1511
|
data: {
|
|
1462
|
-
userSessions: [
|
|
1463
|
-
{
|
|
1464
|
-
action: 'login',
|
|
1465
|
-
userDid,
|
|
1466
|
-
visitorId: data.visitorId,
|
|
1467
|
-
ua,
|
|
1468
|
-
lastLoginIp,
|
|
1469
|
-
appPid: teamDid,
|
|
1470
|
-
passportId,
|
|
1471
|
-
},
|
|
1472
|
-
],
|
|
1512
|
+
userSessions: [userSession],
|
|
1473
1513
|
},
|
|
1474
1514
|
});
|
|
1475
1515
|
logger.info('sync userSession to federated site successfully', {
|
|
1476
1516
|
userDid,
|
|
1477
|
-
visitorId
|
|
1517
|
+
visitorId,
|
|
1478
1518
|
ua,
|
|
1479
1519
|
lastLoginIp,
|
|
1480
|
-
appPid
|
|
1520
|
+
appPid,
|
|
1481
1521
|
passportId,
|
|
1522
|
+
targetSite,
|
|
1482
1523
|
});
|
|
1483
1524
|
} catch (err) {
|
|
1484
1525
|
logger.info(
|
|
1485
1526
|
'sync userSession to federated site failed',
|
|
1486
1527
|
{
|
|
1487
1528
|
userDid,
|
|
1488
|
-
visitorId
|
|
1529
|
+
visitorId,
|
|
1489
1530
|
ua,
|
|
1490
1531
|
lastLoginIp,
|
|
1491
|
-
appPid
|
|
1532
|
+
appPid,
|
|
1492
1533
|
passportId,
|
|
1534
|
+
targetSite,
|
|
1493
1535
|
},
|
|
1494
1536
|
err
|
|
1495
1537
|
);
|
|
1496
|
-
throw err;
|
|
1497
1538
|
}
|
|
1498
1539
|
}
|
|
1499
1540
|
}
|
|
1500
|
-
|
|
1501
|
-
return data;
|
|
1502
1541
|
}
|
|
1503
1542
|
|
|
1504
1543
|
async logoutUser({ teamDid, userDid, visitorId, appPid }) {
|
package/lib/blocklet/extras.js
CHANGED
|
@@ -63,7 +63,7 @@ const mergeConfigs = ({ old: oldConfigs, cur: newConfigs = [], did = '', dek = '
|
|
|
63
63
|
|
|
64
64
|
if (enableSecurity) {
|
|
65
65
|
newConfig.forEach((x) => {
|
|
66
|
-
if (x.secure) {
|
|
66
|
+
if (x.secure || oldConfig[x.key]?.secure) {
|
|
67
67
|
x.value = security.encrypt(x.value, did, dek);
|
|
68
68
|
if (x.default) {
|
|
69
69
|
x.default = security.encrypt(x.default, did, dek);
|
|
@@ -230,13 +230,13 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
230
230
|
*
|
|
231
231
|
* @param {{
|
|
232
232
|
* id: string,
|
|
233
|
-
* job: {
|
|
233
|
+
* job: { did: string }
|
|
234
234
|
* }} param0
|
|
235
235
|
*/
|
|
236
236
|
const handleBackupComplete = async ({ id: jobId, job }) => {
|
|
237
237
|
await this.backupQueue.delete(jobId);
|
|
238
238
|
|
|
239
|
-
const autoBackup = await this.getAutoBackup({ did: job.
|
|
239
|
+
const autoBackup = await this.getAutoBackup({ did: job.did });
|
|
240
240
|
if (autoBackup?.enabled) {
|
|
241
241
|
this.backupQueue.push(job, jobId, true, BACKUPS.JOB.INTERVAL);
|
|
242
242
|
}
|
|
@@ -359,23 +359,9 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
359
359
|
* @param {ConfigEntry} configs pre configs
|
|
360
360
|
*/
|
|
361
361
|
async installComponent(
|
|
362
|
-
{
|
|
363
|
-
rootDid,
|
|
364
|
-
mountPoint: tmpMountPoint,
|
|
365
|
-
url,
|
|
366
|
-
file,
|
|
367
|
-
did,
|
|
368
|
-
diffVersion,
|
|
369
|
-
deleteSet,
|
|
370
|
-
title,
|
|
371
|
-
name,
|
|
372
|
-
configs,
|
|
373
|
-
sync,
|
|
374
|
-
downloadTokenList,
|
|
375
|
-
},
|
|
362
|
+
{ rootDid, mountPoint, url, file, did, diffVersion, deleteSet, title, name, configs, sync, downloadTokenList },
|
|
376
363
|
context = {}
|
|
377
364
|
) {
|
|
378
|
-
const mountPoint = await updateMountPointSchema.validateAsync(tmpMountPoint);
|
|
379
365
|
logger.debug('start install component', { rootDid, mountPoint, url });
|
|
380
366
|
|
|
381
367
|
if (file) {
|
|
@@ -1916,13 +1902,11 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
1916
1902
|
logger.info('updateAutoBackup.$value', value);
|
|
1917
1903
|
|
|
1918
1904
|
if (value.enabled) {
|
|
1919
|
-
const blocklet = await states.blocklet.getBlocklet(did);
|
|
1920
|
-
|
|
1921
1905
|
this.backupQueue.push(
|
|
1922
1906
|
{
|
|
1923
1907
|
entity: 'blocklet',
|
|
1924
1908
|
action: 'backupToSpaces',
|
|
1925
|
-
|
|
1909
|
+
did,
|
|
1926
1910
|
context,
|
|
1927
1911
|
},
|
|
1928
1912
|
jobId,
|
|
@@ -1970,8 +1954,8 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
1970
1954
|
return createProject({ did, ...params, manager: this });
|
|
1971
1955
|
}
|
|
1972
1956
|
|
|
1973
|
-
getProjects({ did } = {}) {
|
|
1974
|
-
return getProjects({ did, manager: this });
|
|
1957
|
+
getProjects({ did, componentDid } = {}) {
|
|
1958
|
+
return getProjects({ did, componentDid, manager: this });
|
|
1975
1959
|
}
|
|
1976
1960
|
|
|
1977
1961
|
getProject({ did, projectId } = {}) {
|
|
@@ -2331,6 +2315,7 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
2331
2315
|
|
|
2332
2316
|
/**
|
|
2333
2317
|
* @param {{
|
|
2318
|
+
* did: string,
|
|
2334
2319
|
* blocklet: import('@abtnode/client').BlockletState,
|
|
2335
2320
|
* context: {
|
|
2336
2321
|
* referrer: string;
|
|
@@ -2342,11 +2327,13 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
2342
2327
|
* }} { blocklet, context }
|
|
2343
2328
|
* @memberof BlockletManager
|
|
2344
2329
|
*/
|
|
2345
|
-
async _onBackupToSpaces({
|
|
2330
|
+
async _onBackupToSpaces({ did, context, backupState }) {
|
|
2346
2331
|
const {
|
|
2347
2332
|
referrer,
|
|
2348
2333
|
user: { did: userDid, locale },
|
|
2349
2334
|
} = context;
|
|
2335
|
+
|
|
2336
|
+
const blocklet = await states.blocklet.getBlocklet(did);
|
|
2350
2337
|
const {
|
|
2351
2338
|
appDid,
|
|
2352
2339
|
meta: { did: appPid },
|
|
@@ -3589,7 +3576,7 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
3589
3576
|
{
|
|
3590
3577
|
entity: 'blocklet',
|
|
3591
3578
|
action: 'backupToSpaces',
|
|
3592
|
-
|
|
3579
|
+
did,
|
|
3593
3580
|
context,
|
|
3594
3581
|
backupState: {
|
|
3595
3582
|
strategy: BACKUPS.STRATEGY.MANUAL,
|
|
@@ -4071,7 +4058,7 @@ class FederatedBlockletManager extends DiskBlockletManager {
|
|
|
4071
4058
|
* @param {{users?:Array; sites?:Array}} options.data - 需要同步的数据
|
|
4072
4059
|
* @returns
|
|
4073
4060
|
*/
|
|
4074
|
-
async syncFederated({ did, data = {} } = {}) {
|
|
4061
|
+
async syncFederated({ did, data = {}, syncSites } = {}) {
|
|
4075
4062
|
const blocklet = await this.getBlocklet(did);
|
|
4076
4063
|
|
|
4077
4064
|
const federated = defaults(cloneDeep(blocklet.settings.federated || {}), {
|
|
@@ -4115,7 +4102,18 @@ class FederatedBlockletManager extends DiskBlockletManager {
|
|
|
4115
4102
|
const { permanentWallet } = getBlockletInfo(blocklet, nodeInfo.sk);
|
|
4116
4103
|
|
|
4117
4104
|
const waitingList = federated.sites
|
|
4118
|
-
.filter((item) =>
|
|
4105
|
+
.filter((item) => {
|
|
4106
|
+
// 未指定 syncSites 向全员通知(除了自己)
|
|
4107
|
+
if (isUndefined(syncSites)) {
|
|
4108
|
+
// 排除通知自己
|
|
4109
|
+
return item.appPid !== blocklet.appPid;
|
|
4110
|
+
}
|
|
4111
|
+
// 如果指定了要通知的站点,则按指定的站点来过滤
|
|
4112
|
+
if (Array.isArray(syncSites)) {
|
|
4113
|
+
return syncSites.some((x) => x.appPid === item.appPid);
|
|
4114
|
+
}
|
|
4115
|
+
return false;
|
|
4116
|
+
})
|
|
4119
4117
|
.map((item) => {
|
|
4120
4118
|
return limitSync(async () => {
|
|
4121
4119
|
try {
|
|
@@ -2,10 +2,11 @@ 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
|
+
const { isInProgress, hasStartEngine } = require('@blocklet/meta/lib/util');
|
|
6
6
|
|
|
7
7
|
const { BlockletSource, BlockletGroup, fromBlockletStatus } = require('@blocklet/constant');
|
|
8
8
|
const { INSTALL_ACTIONS } = require('@abtnode/constant');
|
|
9
|
+
const { updateMountPointSchema } = require('@blocklet/meta/lib/schema');
|
|
9
10
|
const {
|
|
10
11
|
parseComponents,
|
|
11
12
|
filterDuplicateComponents,
|
|
@@ -20,7 +21,7 @@ const { resolveDownload, resolveDiffDownload, downloadFromUpload } = require('..
|
|
|
20
21
|
|
|
21
22
|
const installComponentFromUpload = async ({
|
|
22
23
|
rootDid,
|
|
23
|
-
mountPoint,
|
|
24
|
+
mountPoint: tmpMountPoint,
|
|
24
25
|
file,
|
|
25
26
|
did,
|
|
26
27
|
diffVersion,
|
|
@@ -83,11 +84,15 @@ const installComponentFromUpload = async ({
|
|
|
83
84
|
|
|
84
85
|
const newChild = {
|
|
85
86
|
meta: ensureMeta(meta),
|
|
86
|
-
mountPoint,
|
|
87
87
|
source: BlockletSource.upload,
|
|
88
88
|
deployedFrom: `Upload by ${context.user.fullName}`,
|
|
89
89
|
bundleSource: null,
|
|
90
90
|
};
|
|
91
|
+
if (hasStartEngine(newChild.meta)) {
|
|
92
|
+
const mountPoint = await updateMountPointSchema.validateAsync(tmpMountPoint);
|
|
93
|
+
newChild.mountPoint = mountPoint;
|
|
94
|
+
}
|
|
95
|
+
|
|
91
96
|
const index = newBlocklet.children.findIndex((child) => child.meta.did === meta.did);
|
|
92
97
|
if (index >= 0) {
|
|
93
98
|
// if upgrade, do not update mountPoint
|
|
@@ -3,7 +3,7 @@ const { sign } = require('@arcblock/jwt');
|
|
|
3
3
|
const logger = require('@abtnode/logger')('@abtnode/core:install-component-url');
|
|
4
4
|
|
|
5
5
|
const { isFreeBlocklet, hasStartEngine } = require('@blocklet/meta/lib/util');
|
|
6
|
-
const { titleSchema } = require('@blocklet/meta/lib/schema');
|
|
6
|
+
const { titleSchema, updateMountPointSchema } = require('@blocklet/meta/lib/schema');
|
|
7
7
|
const hasReservedKey = require('@blocklet/meta/lib/has-reserved-key');
|
|
8
8
|
|
|
9
9
|
const { BlockletStatus, BlockletEvents, BlockletGroup } = require('@blocklet/constant');
|
|
@@ -23,7 +23,7 @@ const { formatName } = require('../../../util/get-domain-for-blocklet');
|
|
|
23
23
|
|
|
24
24
|
const installComponentFromUrl = async ({
|
|
25
25
|
rootDid,
|
|
26
|
-
mountPoint,
|
|
26
|
+
mountPoint: tmpMountPoint,
|
|
27
27
|
url,
|
|
28
28
|
context,
|
|
29
29
|
title,
|
|
@@ -86,6 +86,7 @@ const installComponentFromUrl = async ({
|
|
|
86
86
|
};
|
|
87
87
|
|
|
88
88
|
if (hasStartEngine(newChildMeta)) {
|
|
89
|
+
const mountPoint = await updateMountPointSchema.validateAsync(tmpMountPoint);
|
|
89
90
|
newChild.mountPoint = mountPoint || formatName(newChildMeta.title) || formatName(newChildMeta.name);
|
|
90
91
|
}
|
|
91
92
|
|
|
@@ -156,7 +157,7 @@ const installComponentFromUrl = async ({
|
|
|
156
157
|
// backup rollback data
|
|
157
158
|
await manager._rollbackCache.backup({ did: rootDid, action, oldBlocklet });
|
|
158
159
|
|
|
159
|
-
logger.info('install component from url', { rootDid, url, mountPoint, sync, componentDids });
|
|
160
|
+
logger.info('install component from url', { rootDid, url, mountPoint: tmpMountPoint, sync, componentDids });
|
|
160
161
|
|
|
161
162
|
if (sync) {
|
|
162
163
|
await manager._downloadAndInstall({ ...downloadParams, throwOnError: true });
|
|
@@ -15,9 +15,11 @@ const { createReleaseSchema } = require('../../validators/project');
|
|
|
15
15
|
|
|
16
16
|
const createRandomStr = () => Math.random().toString(36).substring(2, 8);
|
|
17
17
|
|
|
18
|
+
const COMPONENT_CONFIG_MAP_DIR = '.component_config';
|
|
19
|
+
|
|
18
20
|
// project
|
|
19
21
|
|
|
20
|
-
const createProject = async ({ did, type, blockletTitle, blockletDid, manager }) => {
|
|
22
|
+
const createProject = async ({ did, type, blockletTitle, blockletDid, componentDid, manager }) => {
|
|
21
23
|
await titleSchema.validateAsync(blockletTitle);
|
|
22
24
|
validateNewDid(blockletDid);
|
|
23
25
|
if (!PROJECT.TYPES[type]) {
|
|
@@ -27,7 +29,7 @@ const createProject = async ({ did, type, blockletTitle, blockletDid, manager })
|
|
|
27
29
|
const blocklet = await manager.getBlocklet(did, { useCache: true });
|
|
28
30
|
const { projectState } = await manager._getProjectState(did);
|
|
29
31
|
|
|
30
|
-
const project = await projectState.createProject({ blockletTitle, blockletDid, type });
|
|
32
|
+
const project = await projectState.createProject({ blockletTitle, blockletDid, type, componentDid });
|
|
31
33
|
|
|
32
34
|
// create project dir
|
|
33
35
|
const projectDir = path.join(blocklet.env.dataDir, PROJECT.DIR, `${project.id}`);
|
|
@@ -41,9 +43,9 @@ const createProject = async ({ did, type, blockletTitle, blockletDid, manager })
|
|
|
41
43
|
return project;
|
|
42
44
|
};
|
|
43
45
|
|
|
44
|
-
const getProjects = async ({ did, manager }) => {
|
|
46
|
+
const getProjects = async ({ did, manager, componentDid }) => {
|
|
45
47
|
const { projectState } = await manager._getProjectState(did);
|
|
46
|
-
const projects = await projectState.getProjects();
|
|
48
|
+
const projects = await projectState.getProjects({ componentDid });
|
|
47
49
|
return { projects };
|
|
48
50
|
};
|
|
49
51
|
|
|
@@ -237,22 +239,6 @@ const createRelease = async ({
|
|
|
237
239
|
await fs.outputFile(path.join(tmpBundleDir, 'README.md'), blockletIntroduction);
|
|
238
240
|
}
|
|
239
241
|
|
|
240
|
-
// create blocklet.yml
|
|
241
|
-
const meta = {
|
|
242
|
-
did: blockletDid,
|
|
243
|
-
name: blockletDid,
|
|
244
|
-
title: blockletTitle,
|
|
245
|
-
description: blockletDescription,
|
|
246
|
-
version: blockletVersion,
|
|
247
|
-
logo: logoFileName,
|
|
248
|
-
resources: ['/resource'],
|
|
249
|
-
components: [],
|
|
250
|
-
files: ['screenshots'],
|
|
251
|
-
screenshots: project.blockletScreenshots || [],
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
await updateMetaFile(path.join(tmpBundleDir, BLOCKLET_META_FILE), meta);
|
|
255
|
-
|
|
256
242
|
// changelog
|
|
257
243
|
const changelogDistFile = path.join(tmpBundleDir, 'CHANGELOG.md');
|
|
258
244
|
const releases = await releaseState.getReleases({ projectId, status: PROJECT.RELEASE_STATUS.published });
|
|
@@ -270,6 +256,25 @@ const createRelease = async ({
|
|
|
270
256
|
await fs.remove(tmpResourceDir);
|
|
271
257
|
await fs.copy(resourceDir, tmpResourceDir);
|
|
272
258
|
|
|
259
|
+
// create blocklet.yml
|
|
260
|
+
const resourceList = await fs.readdir(resourceDir);
|
|
261
|
+
const resourcesPaths = resourceList
|
|
262
|
+
.filter((x) => x !== COMPONENT_CONFIG_MAP_DIR)
|
|
263
|
+
.map((x) => path.join('/resource', x));
|
|
264
|
+
const meta = {
|
|
265
|
+
did: blockletDid,
|
|
266
|
+
name: blockletDid,
|
|
267
|
+
title: blockletTitle,
|
|
268
|
+
description: blockletDescription,
|
|
269
|
+
version: blockletVersion,
|
|
270
|
+
logo: logoFileName,
|
|
271
|
+
resources: resourcesPaths.length ? resourcesPaths : undefined,
|
|
272
|
+
components: [],
|
|
273
|
+
files: ['screenshots'],
|
|
274
|
+
screenshots: project.blockletScreenshots || [],
|
|
275
|
+
};
|
|
276
|
+
await updateMetaFile(path.join(tmpBundleDir, BLOCKLET_META_FILE), meta);
|
|
277
|
+
|
|
273
278
|
// create release
|
|
274
279
|
await createBlockletRelease(tmpExportDir, { printError: logger.error, printInfo: logger.info });
|
|
275
280
|
|
|
@@ -319,7 +324,7 @@ const getSelectedResourcesFile = ({ app, projectId, releaseId, componentDid }) =
|
|
|
319
324
|
dirArr.push(PROJECT.RELEASE_DIR, releaseId || '/');
|
|
320
325
|
}
|
|
321
326
|
dirArr.push(PROJECT.RESOURCE_DIR);
|
|
322
|
-
dirArr.push(
|
|
327
|
+
dirArr.push(COMPONENT_CONFIG_MAP_DIR);
|
|
323
328
|
dirArr.push(`${componentDid}.json`);
|
|
324
329
|
return path.join(...dirArr);
|
|
325
330
|
};
|
package/lib/index.js
CHANGED
|
@@ -385,6 +385,7 @@ function ABTNode(options) {
|
|
|
385
385
|
// user-session
|
|
386
386
|
getUserSession: teamAPI.getUserSession.bind(teamAPI),
|
|
387
387
|
upsertUserSession: teamAPI.upsertUserSession.bind(teamAPI),
|
|
388
|
+
syncUserSession: teamAPI.syncUserSession.bind(teamAPI),
|
|
388
389
|
logoutUser: teamAPI.logoutUser.bind(teamAPI),
|
|
389
390
|
getPassportById: teamAPI.getPassportById.bind(teamAPI),
|
|
390
391
|
getPassportFromFederated: teamAPI.getPassportFromFederated.bind(teamAPI),
|
package/lib/states/audit-log.js
CHANGED
|
@@ -245,7 +245,7 @@ ${JSON.stringify(syncData, null, 2)}
|
|
|
245
245
|
case 'switchPassport':
|
|
246
246
|
return `${args.provider} user ${user} switched passport to ${args.passport.name}`;
|
|
247
247
|
case 'login':
|
|
248
|
-
return `${args.provider} user ${user} logged in with passport ${args.passport
|
|
248
|
+
return `${args.provider} user ${user} logged in with passport ${args.passport?.name}`;
|
|
249
249
|
case 'updateWhoCanAccess':
|
|
250
250
|
return `updated access control policy of **${
|
|
251
251
|
args.did[1] ? getComponentNames(result, [args.did[1]]) : 'application'
|
package/lib/states/blocklet.js
CHANGED
|
@@ -159,6 +159,13 @@ class BlockletState extends BaseState {
|
|
|
159
159
|
this.statusLocks = new Map();
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
+
/**
|
|
163
|
+
* @description
|
|
164
|
+
* @param {string} did
|
|
165
|
+
* @param {*} [{ decryptSk = true }={}]
|
|
166
|
+
* @return {Promise<import('@abtnode/client').BlockletState>}
|
|
167
|
+
* @memberof BlockletState
|
|
168
|
+
*/
|
|
162
169
|
async getBlocklet(did, { decryptSk = true } = {}) {
|
|
163
170
|
if (!did) {
|
|
164
171
|
return null;
|
package/lib/states/project.js
CHANGED
|
@@ -8,13 +8,22 @@ const isUndefinedOrNull = (x) => x === undefined || x === null;
|
|
|
8
8
|
* @extends BaseState<import('@abtnode/models').ProjectState>
|
|
9
9
|
*/
|
|
10
10
|
class Project extends BaseState {
|
|
11
|
-
createProject({ type, blockletDid, blockletTitle }) {
|
|
12
|
-
|
|
11
|
+
createProject({ type, blockletDid, blockletTitle, componentDid }) {
|
|
12
|
+
const doc = { id: blockletDid, type, blockletDid, blockletTitle };
|
|
13
|
+
if (componentDid) {
|
|
14
|
+
doc.componentDid = componentDid;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return this.insert(doc);
|
|
13
18
|
}
|
|
14
19
|
|
|
15
|
-
getProjects() {
|
|
20
|
+
getProjects({ componentDid }) {
|
|
21
|
+
const query = {};
|
|
22
|
+
if (componentDid) {
|
|
23
|
+
query.componentDid = componentDid;
|
|
24
|
+
}
|
|
16
25
|
return this.find(
|
|
17
|
-
|
|
26
|
+
query,
|
|
18
27
|
{},
|
|
19
28
|
{
|
|
20
29
|
createdAt: -1,
|
package/lib/util/federated.js
CHANGED
|
@@ -5,6 +5,22 @@ const joinUrl = require('url-join');
|
|
|
5
5
|
|
|
6
6
|
const request = require('./request');
|
|
7
7
|
|
|
8
|
+
function isMaster(site) {
|
|
9
|
+
return site?.isMaster !== false;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function getFederatedMaster(blocklet) {
|
|
13
|
+
const { sites } = blocklet?.settings?.federated || {};
|
|
14
|
+
const masterSite = (sites || []).find((item) => isMaster(item));
|
|
15
|
+
return masterSite || null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function findFederatedSite(blocklet, targetAppPid) {
|
|
19
|
+
const { sites } = blocklet?.settings?.federated || {};
|
|
20
|
+
const targetSite = (sites || []).find((item) => item.appPid === targetAppPid);
|
|
21
|
+
return targetSite || null;
|
|
22
|
+
}
|
|
23
|
+
|
|
8
24
|
async function callFederated({ site, permanentWallet, data, action }) {
|
|
9
25
|
const url = new URL(site.appUrl);
|
|
10
26
|
url.pathname = joinUrl(WELLKNOWN_SERVICE_PATH_PREFIX, `/api/federated/${action}`);
|
|
@@ -21,4 +37,7 @@ async function callFederated({ site, permanentWallet, data, action }) {
|
|
|
21
37
|
|
|
22
38
|
module.exports = {
|
|
23
39
|
callFederated,
|
|
40
|
+
getFederatedMaster,
|
|
41
|
+
findFederatedSite,
|
|
42
|
+
isMaster,
|
|
24
43
|
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.18-beta-
|
|
6
|
+
"version": "1.16.18-beta-aa01bd8e",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -19,39 +19,39 @@
|
|
|
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.18-beta-
|
|
23
|
-
"@abtnode/auth": "1.16.18-beta-
|
|
24
|
-
"@abtnode/certificate-manager": "1.16.18-beta-
|
|
25
|
-
"@abtnode/constant": "1.16.18-beta-
|
|
26
|
-
"@abtnode/cron": "1.16.18-beta-
|
|
27
|
-
"@abtnode/logger": "1.16.18-beta-
|
|
28
|
-
"@abtnode/models": "1.16.18-beta-
|
|
29
|
-
"@abtnode/queue": "1.16.18-beta-
|
|
30
|
-
"@abtnode/rbac": "1.16.18-beta-
|
|
31
|
-
"@abtnode/router-provider": "1.16.18-beta-
|
|
32
|
-
"@abtnode/static-server": "1.16.18-beta-
|
|
33
|
-
"@abtnode/timemachine": "1.16.18-beta-
|
|
34
|
-
"@abtnode/util": "1.16.18-beta-
|
|
35
|
-
"@arcblock/did": "1.18.
|
|
36
|
-
"@arcblock/did-auth": "1.18.
|
|
37
|
-
"@arcblock/did-ext": "^1.18.
|
|
22
|
+
"@abtnode/analytics": "1.16.18-beta-aa01bd8e",
|
|
23
|
+
"@abtnode/auth": "1.16.18-beta-aa01bd8e",
|
|
24
|
+
"@abtnode/certificate-manager": "1.16.18-beta-aa01bd8e",
|
|
25
|
+
"@abtnode/constant": "1.16.18-beta-aa01bd8e",
|
|
26
|
+
"@abtnode/cron": "1.16.18-beta-aa01bd8e",
|
|
27
|
+
"@abtnode/logger": "1.16.18-beta-aa01bd8e",
|
|
28
|
+
"@abtnode/models": "1.16.18-beta-aa01bd8e",
|
|
29
|
+
"@abtnode/queue": "1.16.18-beta-aa01bd8e",
|
|
30
|
+
"@abtnode/rbac": "1.16.18-beta-aa01bd8e",
|
|
31
|
+
"@abtnode/router-provider": "1.16.18-beta-aa01bd8e",
|
|
32
|
+
"@abtnode/static-server": "1.16.18-beta-aa01bd8e",
|
|
33
|
+
"@abtnode/timemachine": "1.16.18-beta-aa01bd8e",
|
|
34
|
+
"@abtnode/util": "1.16.18-beta-aa01bd8e",
|
|
35
|
+
"@arcblock/did": "1.18.95",
|
|
36
|
+
"@arcblock/did-auth": "1.18.95",
|
|
37
|
+
"@arcblock/did-ext": "^1.18.95",
|
|
38
38
|
"@arcblock/did-motif": "^1.1.13",
|
|
39
|
-
"@arcblock/did-util": "1.18.
|
|
40
|
-
"@arcblock/event-hub": "1.18.
|
|
41
|
-
"@arcblock/jwt": "^1.18.
|
|
39
|
+
"@arcblock/did-util": "1.18.95",
|
|
40
|
+
"@arcblock/event-hub": "1.18.95",
|
|
41
|
+
"@arcblock/jwt": "^1.18.95",
|
|
42
42
|
"@arcblock/pm2-events": "^0.0.5",
|
|
43
|
-
"@arcblock/validator": "^1.18.
|
|
44
|
-
"@arcblock/vc": "1.18.
|
|
45
|
-
"@blocklet/constant": "1.16.18-beta-
|
|
46
|
-
"@blocklet/env": "1.16.18-beta-
|
|
47
|
-
"@blocklet/meta": "1.16.18-beta-
|
|
48
|
-
"@blocklet/resolver": "1.16.18-beta-
|
|
49
|
-
"@blocklet/sdk": "1.16.18-beta-
|
|
50
|
-
"@did-space/client": "^0.3.
|
|
43
|
+
"@arcblock/validator": "^1.18.95",
|
|
44
|
+
"@arcblock/vc": "1.18.95",
|
|
45
|
+
"@blocklet/constant": "1.16.18-beta-aa01bd8e",
|
|
46
|
+
"@blocklet/env": "1.16.18-beta-aa01bd8e",
|
|
47
|
+
"@blocklet/meta": "1.16.18-beta-aa01bd8e",
|
|
48
|
+
"@blocklet/resolver": "1.16.18-beta-aa01bd8e",
|
|
49
|
+
"@blocklet/sdk": "1.16.18-beta-aa01bd8e",
|
|
50
|
+
"@did-space/client": "^0.3.20",
|
|
51
51
|
"@fidm/x509": "^1.2.1",
|
|
52
|
-
"@ocap/mcrypto": "1.18.
|
|
53
|
-
"@ocap/util": "1.18.
|
|
54
|
-
"@ocap/wallet": "1.18.
|
|
52
|
+
"@ocap/mcrypto": "1.18.95",
|
|
53
|
+
"@ocap/util": "1.18.95",
|
|
54
|
+
"@ocap/wallet": "1.18.95",
|
|
55
55
|
"@slack/webhook": "^5.0.4",
|
|
56
56
|
"archiver": "^5.3.1",
|
|
57
57
|
"axios": "^0.27.2",
|
|
@@ -101,5 +101,5 @@
|
|
|
101
101
|
"jest": "^27.5.1",
|
|
102
102
|
"unzipper": "^0.10.11"
|
|
103
103
|
},
|
|
104
|
-
"gitHead": "
|
|
104
|
+
"gitHead": "2bfa63d05ad290f13eee359661e4175b857d9f9d"
|
|
105
105
|
}
|