@abtnode/core 1.16.11-next-ca5f18b5 → 1.16.11-next-3e55bc95

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.
Files changed (38) hide show
  1. package/lib/api/team.js +5 -5
  2. package/lib/blocklet/downloader/blocklet-downloader.js +2 -2
  3. package/lib/blocklet/downloader/bundle-downloader.js +2 -2
  4. package/lib/blocklet/hooks.js +1 -1
  5. package/lib/blocklet/manager/base.js +9 -9
  6. package/lib/blocklet/manager/disk.js +14 -14
  7. package/lib/blocklet/manager/helper/install-application-from-backup.js +1 -1
  8. package/lib/blocklet/migration.js +2 -2
  9. package/lib/blocklet/storage/backup/base.js +1 -0
  10. package/lib/blocklet/storage/backup/blocklet-extras.js +1 -1
  11. package/lib/blocklet/storage/backup/blocklet.js +1 -1
  12. package/lib/blocklet/storage/backup/disk.js +1 -0
  13. package/lib/blocklet/storage/restore/blocklet-extras.js +1 -1
  14. package/lib/blocklet/storage/restore/blocklet.js +1 -1
  15. package/lib/blocklet/storage/restore/disk.js +1 -1
  16. package/lib/blocklet/storage/restore/spaces.js +1 -1
  17. package/lib/cert.js +5 -5
  18. package/lib/crons/rotate-pm2-logs/index.js +1 -1
  19. package/lib/migrations/index.js +3 -3
  20. package/lib/processes/updater.js +1 -1
  21. package/lib/router/helper.js +5 -5
  22. package/lib/states/audit-log.js +1 -1
  23. package/lib/states/backup.js +5 -4
  24. package/lib/states/blocklet-extras.js +1 -1
  25. package/lib/states/blocklet.js +2 -2
  26. package/lib/states/cache.js +1 -1
  27. package/lib/states/node.js +5 -2
  28. package/lib/states/notification.js +1 -1
  29. package/lib/states/routing-snapshot.js +1 -1
  30. package/lib/states/site.js +1 -1
  31. package/lib/states/user.js +6 -2
  32. package/lib/team/manager.js +6 -6
  33. package/lib/util/blocklet.js +5 -5
  34. package/lib/util/rpc.js +1 -1
  35. package/lib/util/store.js +1 -1
  36. package/lib/webhook/sender/api/index.js +1 -1
  37. package/lib/webhook/sender/slack/index.js +1 -1
  38. package/package.json +17 -17
package/lib/api/team.js CHANGED
@@ -642,7 +642,7 @@ class TeamAPI extends EventEmitter {
642
642
  /**
643
643
  * this function is only used to create server owner transfer invitation
644
644
  */
645
- async createTransferInvitation({ teamDid, remark }, context = {}) {
645
+ createTransferInvitation({ teamDid, remark }, context = {}) {
646
646
  return this.createMemberInvitation(
647
647
  { teamDid, expireTime: this.transferOwnerExpireTime, remark, role: 'owner' },
648
648
  context
@@ -956,7 +956,7 @@ class TeamAPI extends EventEmitter {
956
956
 
957
957
  // Access Control
958
958
 
959
- async getRoles({ teamDid }) {
959
+ getRoles({ teamDid }) {
960
960
  return this.teamManager.getRoles(teamDid);
961
961
  }
962
962
 
@@ -1171,15 +1171,15 @@ class TeamAPI extends EventEmitter {
1171
1171
  // Private
1172
1172
  // =======
1173
1173
 
1174
- async getRBAC(did) {
1174
+ getRBAC(did) {
1175
1175
  return this.teamManager.getRBAC(did);
1176
1176
  }
1177
1177
 
1178
- async getUserState(did) {
1178
+ getUserState(did) {
1179
1179
  return this.teamManager.getUserState(did);
1180
1180
  }
1181
1181
 
1182
- async getSessionState(did) {
1182
+ getSessionState(did) {
1183
1183
  return this.teamManager.getSessionState(did);
1184
1184
  }
1185
1185
 
@@ -161,7 +161,7 @@ class BlockletDownloader extends EventEmitter {
161
161
  });
162
162
 
163
163
  const results = await Promise.all(
164
- downloadList.map(async (meta) => {
164
+ downloadList.map((meta) => {
165
165
  const url = meta.dist.tarball;
166
166
  return this.bundleDownloader.download(meta, did, url, {
167
167
  ...options,
@@ -188,7 +188,7 @@ class BlockletDownloader extends EventEmitter {
188
188
  return { isCancelled: false };
189
189
  }
190
190
 
191
- async cancelDownload(did) {
191
+ cancelDownload(did) {
192
192
  return this.bundleDownloader.cancelDownload(did);
193
193
  }
194
194
 
@@ -121,7 +121,7 @@ class BundleDownloader extends EventEmitter {
121
121
  }
122
122
 
123
123
  // eslint-disable-next-line no-unused-vars
124
- async cancelDownload(rootDid) {
124
+ cancelDownload(rootDid) {
125
125
  if (this.downloadCtrls[rootDid]) {
126
126
  for (const cancelCtrl of this.downloadCtrls[rootDid].values()) {
127
127
  cancelCtrl.cancel();
@@ -294,7 +294,7 @@ class BundleDownloader extends EventEmitter {
294
294
  await this.cache.set(CACHE_KEY, cacheList);
295
295
  }
296
296
 
297
- async _getCachedTarFile(integrity) {
297
+ _getCachedTarFile(integrity) {
298
298
  // eslint-disable-next-line no-param-reassign
299
299
  integrity = toBase58(integrity);
300
300
 
@@ -57,7 +57,7 @@ const runUserHook = async (label, hookName, args) => {
57
57
  const preInstall = (label, ...args) => runUserHook(label, 'pre-install', ...args);
58
58
  const postInstall = (label, ...args) => runUserHook(label, 'post-install', ...args);
59
59
  const preConfig = (label, ...args) => runUserHook(label, 'pre-config', ...args);
60
- const preStart = async (blocklet, options) => {
60
+ const preStart = (blocklet, options) => {
61
61
  // check required environments
62
62
  let environments = get(blocklet, 'meta.environments', []);
63
63
  if (!Array.isArray(environments)) {
@@ -16,39 +16,39 @@ class BaseBlockletManager extends EventEmitter {
16
16
  }
17
17
  }
18
18
 
19
- async install() {
19
+ install() {
20
20
  throw new Error('Install must be implemented in sub class');
21
21
  }
22
22
 
23
- async start() {
23
+ start() {
24
24
  throw new Error('Install must be implemented in sub class');
25
25
  }
26
26
 
27
- async stop() {
27
+ stop() {
28
28
  throw new Error('Stop must be implemented in sub class');
29
29
  }
30
30
 
31
- async restart() {
31
+ restart() {
32
32
  throw new Error('Restart must be implemented in sub class');
33
33
  }
34
34
 
35
- async reload() {
35
+ reload() {
36
36
  throw new Error('Reload must be implemented in sub class');
37
37
  }
38
38
 
39
- async delete() {
39
+ delete() {
40
40
  throw new Error('Delete must be implemented in sub class');
41
41
  }
42
42
 
43
- async detail() {
43
+ detail() {
44
44
  throw new Error('Detail must be implemented in sub class');
45
45
  }
46
46
 
47
- async list() {
47
+ list() {
48
48
  throw new Error('List must be implemented in sub class');
49
49
  }
50
50
 
51
- async config() {
51
+ config() {
52
52
  throw new Error('Config must be implemented in sub class');
53
53
  }
54
54
  }
@@ -410,7 +410,7 @@ class BlockletManager extends BaseBlockletManager {
410
410
  throw new Error('Unknown source');
411
411
  }
412
412
 
413
- async diff({ did, hashFiles, rootDid }) {
413
+ diff({ did, hashFiles, rootDid }) {
414
414
  return diff({ did, hashFiles, rootDid, states, manager: this });
415
415
  }
416
416
 
@@ -418,7 +418,7 @@ class BlockletManager extends BaseBlockletManager {
418
418
  * After the dev function finished, the caller should send a BlockletEvents.installed event to the daemon
419
419
  * @returns {Object} blocklet
420
420
  */
421
- async dev(folder, { rootDid, mountPoint, defaultStoreUrl } = {}) {
421
+ dev(folder, { rootDid, mountPoint, defaultStoreUrl } = {}) {
422
422
  logger.info('dev component', { folder, rootDid, mountPoint });
423
423
 
424
424
  const meta = getBlockletMeta(folder, { defaultStoreUrl });
@@ -433,15 +433,15 @@ class BlockletManager extends BaseBlockletManager {
433
433
  return installComponentFromDev({ folder, meta, rootDid, mountPoint, manager: this, states });
434
434
  }
435
435
 
436
- async checkComponentsForUpdates({ did }) {
436
+ checkComponentsForUpdates({ did }) {
437
437
  return UpgradeComponents.check({ did, states });
438
438
  }
439
439
 
440
- async upgradeComponents({ updateId, selectedComponents: componentDids }, context = {}) {
440
+ upgradeComponents({ updateId, selectedComponents: componentDids }, context = {}) {
441
441
  return UpgradeComponents.upgrade({ updateId, componentDids, context, states, manager: this });
442
442
  }
443
443
 
444
- async migrateApplicationToStructV2({ did, appSk, context = {} }) {
444
+ migrateApplicationToStructV2({ did, appSk, context = {} }) {
445
445
  return migrateApplicationToStructV2({ did, appSk, context, manager: this, states });
446
446
  }
447
447
 
@@ -660,7 +660,7 @@ class BlockletManager extends BaseBlockletManager {
660
660
  * @memberof BlockletManager
661
661
  */
662
662
  // eslint-disable-next-line no-unused-vars
663
- async restoreBlocklet(input, context) {
663
+ restoreBlocklet(input, context) {
664
664
  const { from, ...param } = input;
665
665
  if (from === 'spaces') {
666
666
  return this._restoreFromSpaces(param, context);
@@ -1060,7 +1060,7 @@ class BlockletManager extends BaseBlockletManager {
1060
1060
  return blocklets;
1061
1061
  }
1062
1062
 
1063
- async listBackups() {
1063
+ listBackups() {
1064
1064
  return getBackupList(this.dataDirs.data);
1065
1065
  }
1066
1066
 
@@ -1390,15 +1390,15 @@ class BlockletManager extends BaseBlockletManager {
1390
1390
  });
1391
1391
  }
1392
1392
 
1393
- async ensureBlocklet(did, opts = {}) {
1393
+ ensureBlocklet(did, opts = {}) {
1394
1394
  return getBlocklet({ ...opts, states, dataDirs: this.dataDirs, did, ensureIntegrity: true });
1395
1395
  }
1396
1396
 
1397
- async getBlocklet(did, opts = {}) {
1397
+ getBlocklet(did, opts = {}) {
1398
1398
  return getBlocklet({ ...opts, states, dataDirs: this.dataDirs, did, ensureIntegrity: false });
1399
1399
  }
1400
1400
 
1401
- async hasBlocklet({ did }) {
1401
+ hasBlocklet({ did }) {
1402
1402
  return states.blocklet.hasBlocklet(did);
1403
1403
  }
1404
1404
 
@@ -1497,7 +1497,7 @@ class BlockletManager extends BaseBlockletManager {
1497
1497
  return blocklet;
1498
1498
  }
1499
1499
 
1500
- async refreshListCache() {
1500
+ refreshListCache() {
1501
1501
  this.list({ useCache: false }).catch((err) => {
1502
1502
  logger.error('refresh blocklet list failed', { error: err });
1503
1503
  });
@@ -1699,7 +1699,7 @@ class BlockletManager extends BaseBlockletManager {
1699
1699
  * @return {Promise<Array<import('@abtnode/client').Backup>>}
1700
1700
  * @memberof BlockletManager
1701
1701
  */
1702
- async getBlockletBackups({ did }) {
1702
+ getBlockletBackups({ did }) {
1703
1703
  return states.backup.getBlockletBackups({ did });
1704
1704
  }
1705
1705
 
@@ -2621,7 +2621,7 @@ class BlockletManager extends BaseBlockletManager {
2621
2621
  * @return {*}
2622
2622
  * @memberof BlockletManager
2623
2623
  */
2624
- async _downloadBlocklet(blocklet, context = {}) {
2624
+ _downloadBlocklet(blocklet, context = {}) {
2625
2625
  const {
2626
2626
  appDid,
2627
2627
  meta: { did },
@@ -2638,7 +2638,7 @@ class BlockletManager extends BaseBlockletManager {
2638
2638
  this.emit(BlockletEvents.statusChange, blocklet1);
2639
2639
  }
2640
2640
  },
2641
- onProgress: async (data) => {
2641
+ onProgress: (data) => {
2642
2642
  this.emit(BlockletEvents.downloadBundleProgress, { appDid: appDid || did, meta: { did }, ...data });
2643
2643
  },
2644
2644
  postDownload: async ({ isCancelled }) => {
@@ -203,7 +203,7 @@ const installApplicationFromBackup = async ({
203
203
  // 从 store 下载 blocklet
204
204
  await manager.blockletDownloader.download(blockletState, {
205
205
  skipCheckIntegrity: true,
206
- onProgress: async (data) => {
206
+ onProgress: (data) => {
207
207
  manager.emit(BlockletEvents.downloadBundleProgress, { appDid: wallet.address, meta: { did }, ...data });
208
208
  },
209
209
  });
@@ -78,14 +78,14 @@ async function runScripts({
78
78
  return true;
79
79
  }
80
80
 
81
- async function doBackup({ dbDir, backupDir, printInfo, printSuccess }) {
81
+ function doBackup({ dbDir, backupDir, printInfo, printSuccess }) {
82
82
  printInfo('Backing up before migration...');
83
83
  fs.emptyDirSync(backupDir);
84
84
  fs.copySync(dbDir, backupDir);
85
85
  printSuccess('Backup success');
86
86
  }
87
87
 
88
- async function doRestore({ dbDir, backupDir, printInfo, printSuccess }) {
88
+ function doRestore({ dbDir, backupDir, printInfo, printSuccess }) {
89
89
  printInfo('Restoring when migration failed...');
90
90
  fs.emptyDirSync(dbDir);
91
91
  fs.copySync(backupDir, dbDir);
@@ -68,6 +68,7 @@ class BaseBackup {
68
68
  this.securityContext = backup.securityContext;
69
69
  }
70
70
 
71
+ // eslint-disable-next-line require-await
71
72
  async export() {
72
73
  throw new Error('not implemented');
73
74
  }
@@ -42,7 +42,7 @@ class BlockletExtrasBackup extends BaseBackup {
42
42
  * @return {Promise<any>}
43
43
  * @memberof BlockletExtrasBackup
44
44
  */
45
- async cleanData(raw) {
45
+ cleanData(raw) {
46
46
  const blockletExtra = cloneDeep(raw);
47
47
 
48
48
  const queue = [blockletExtra];
@@ -28,7 +28,7 @@ class BlockletBackup extends BaseBackup {
28
28
  * @return {Promise<import('@abtnode/client').BlockletState>}
29
29
  * @memberof BlockletBackup
30
30
  */
31
- async cleanData() {
31
+ cleanData() {
32
32
  const clone = cloneDeep(this.blocklet);
33
33
 
34
34
  /** @type {import('@abtnode/client').ComponentState[]} */
@@ -111,6 +111,7 @@ class DiskBackup extends BaseBackup {
111
111
  this.securityContext = await this._getSecurityContext(states);
112
112
  }
113
113
 
114
+ // eslint-disable-next-line require-await
114
115
  async export() {
115
116
  return this._exportData(this.dataBackup, this.storages);
116
117
  }
@@ -8,7 +8,7 @@ const { BaseRestore } = require('./base');
8
8
  class BlockletExtrasRestore extends BaseRestore {
9
9
  filename = 'blocklet-extras.json';
10
10
 
11
- async import(params) {
11
+ import(params) {
12
12
  const extras = this.cleanExtras(this.getExtras(), params);
13
13
  removeSync(join(this.restoreDir, this.filename));
14
14
  outputJsonSync(join(this.restoreDir, this.filename), extras);
@@ -8,7 +8,7 @@ const { BaseRestore } = require('./base');
8
8
  class BlockletRestore extends BaseRestore {
9
9
  filename = 'blocklet.json';
10
10
 
11
- async import(params) {
11
+ import(params) {
12
12
  const blocklet = this.decrypt(this.getBlocklet(), params);
13
13
  removeSync(join(this.restoreDir, this.filename));
14
14
  outputJsonSync(join(this.restoreDir, this.filename), blocklet);
@@ -61,7 +61,7 @@ class DiskRestore extends BaseRestore {
61
61
  }
62
62
  }
63
63
 
64
- async initialize() {
64
+ initialize() {
65
65
  this.serverDir = process.env.ABT_NODE_DATA_DIR;
66
66
  this.restoreDir = getBackupDirs(this.serverDir, this.input.appDid).restoreDir;
67
67
  if (existsSync(this.restoreDir)) {
@@ -82,7 +82,7 @@ class SpacesRestore extends BaseRestore {
82
82
  }
83
83
  }
84
84
 
85
- async initialize() {
85
+ initialize() {
86
86
  this.serverDir = process.env.ABT_NODE_DATA_DIR;
87
87
  this.restoreDir = join(this.serverDir, 'tmp/restore', this.input.appDid);
88
88
  if (existsSync(this.restoreDir)) {
package/lib/cert.js CHANGED
@@ -4,7 +4,7 @@ const logger = require('@abtnode/logger')('@abtnode/core:cert');
4
4
  const { EVENTS } = require('@abtnode/constant');
5
5
  const { BlockletEvents } = require('@blocklet/constant');
6
6
 
7
- const onCertExpired = async (cert, states) => {
7
+ const onCertExpired = (cert, states) => {
8
8
  logger.info('send certificate expire notification', { domain: cert.domain });
9
9
  states.notification.create({
10
10
  title: 'SSL Certificate Expired',
@@ -120,7 +120,7 @@ class Cert extends EventEmitter {
120
120
  * did?:string // blocklet.meta.did
121
121
  * }}
122
122
  */
123
- async issue({ domain, did }) {
123
+ issue({ domain, did }) {
124
124
  logger.info(`generate certificate for ${domain}`);
125
125
 
126
126
  if (did) {
@@ -137,7 +137,7 @@ class Cert extends EventEmitter {
137
137
  return result;
138
138
  }
139
139
 
140
- async update(data) {
140
+ update(data) {
141
141
  return this.manager.update(data.id, { name: data.name, public: data.public });
142
142
  }
143
143
 
@@ -149,11 +149,11 @@ class Cert extends EventEmitter {
149
149
  return {};
150
150
  }
151
151
 
152
- async addWithoutValidations(data) {
152
+ addWithoutValidations(data) {
153
153
  return this.manager.addWithoutValidations(data);
154
154
  }
155
155
 
156
- async updateWithoutValidations(id, data) {
156
+ updateWithoutValidations(id, data) {
157
157
  return this.manager.updateWithoutValidations(id, data);
158
158
  }
159
159
 
@@ -7,7 +7,7 @@ const getCron = () => ({
7
7
  name: 'rotate-pm2-logs',
8
8
  time: '0 0 * * *', // default : every day at midnight
9
9
  options: { runOnInit: false },
10
- fn: async () => {
10
+ fn: () => {
11
11
  console.info(`Log rotator started on ${new Date().toISOString()}`);
12
12
  const child = spawn('node', [path.join(__dirname, './script.js')], {
13
13
  detached: true,
@@ -78,7 +78,7 @@ const getMigrationScripts = (scriptsDir) => {
78
78
  return sorted;
79
79
  };
80
80
 
81
- const doBackup = async ({ dataDir, configFile, printInfo, printSuccess }) => {
81
+ const doBackup = ({ dataDir, configFile, printInfo, printSuccess }) => {
82
82
  printInfo('Backing up state db and config before migration...');
83
83
 
84
84
  const backupDir = path.join(dataDir, 'migration', Date.now().toString());
@@ -96,7 +96,7 @@ const doBackup = async ({ dataDir, configFile, printInfo, printSuccess }) => {
96
96
  return backupDir;
97
97
  };
98
98
 
99
- const doRestore = async ({ dataDir, configFile, backupPath, printInfo, printSuccess }) => {
99
+ const doRestore = ({ dataDir, configFile, backupPath, printInfo, printSuccess }) => {
100
100
  printInfo('Restoring when migration failed...');
101
101
 
102
102
  const dbBackup = path.join(backupPath, BACKUP_FILE_DB);
@@ -309,7 +309,7 @@ const runDataMigrations = async ({
309
309
  }
310
310
  };
311
311
 
312
- const closeDatabaseConnections = async ({
312
+ const closeDatabaseConnections = ({
313
313
  dataDir,
314
314
  blocklets = [],
315
315
  printInfo = console.info, // eslint-disable-line
@@ -109,7 +109,7 @@ const verifyBlockletServer = async (version) => {
109
109
  };
110
110
 
111
111
  // Restart Blocklet Server
112
- const restartBlockletServer = async (dataDir) => {
112
+ const restartBlockletServer = (dataDir) => {
113
113
  // We put this in the event loop because it will terminate the current node process
114
114
  // But we need to wait for the session state to transition from restarting to cleanup
115
115
  process.nextTick(async () => {
@@ -168,7 +168,7 @@ const ensureServiceRule = async (sites) => {
168
168
  return site;
169
169
  });
170
170
  };
171
- const ensureRootRule = async (sites) => {
171
+ const ensureRootRule = (sites) => {
172
172
  return sites.map((site) => {
173
173
  if (!isBasicSite(site.domain) && !site.rules.some((x) => x.from.pathPrefix === '/')) {
174
174
  site.rules.push({
@@ -388,7 +388,7 @@ const ensureCorsForWebWallet = async (sites) => {
388
388
  * @param {Array<import('@abtnode/client').BlockletState>} blocklets
389
389
  * @return {Promise<any>}
390
390
  */
391
- const ensureCorsForDidSpace = async (sites = [], blocklets) => {
391
+ const ensureCorsForDidSpace = (sites = [], blocklets) => {
392
392
  return sites.map((site) => {
393
393
  const blocklet = blocklets.find((x) => x.meta.did === site.blockletDid);
394
394
  if (blocklet) {
@@ -404,7 +404,7 @@ const ensureCorsForDidSpace = async (sites = [], blocklets) => {
404
404
  });
405
405
  };
406
406
 
407
- const filterSitesForRemovedBlocklets = async (sites = [], blocklets) => {
407
+ const filterSitesForRemovedBlocklets = (sites = [], blocklets) => {
408
408
  return sites.filter((site) => {
409
409
  if (!site.domain.endsWith(BLOCKLET_SITE_GROUP_SUFFIX)) {
410
410
  return true;
@@ -420,7 +420,7 @@ const filterSitesForRemovedBlocklets = async (sites = [], blocklets) => {
420
420
  *
421
421
  * @returns {boolean} if routing changed
422
422
  */
423
- const ensureBlockletWellknownRules = async (sites, blocklets) => {
423
+ const ensureBlockletWellknownRules = (sites, blocklets) => {
424
424
  /**
425
425
  * 1. component blocklet 不允许有相同多的 wellknown
426
426
  * 1. wellknown 可以访问的路由:
@@ -488,7 +488,7 @@ const ensureBlockletWellknownRules = async (sites, blocklets) => {
488
488
  .filter(Boolean);
489
489
  };
490
490
 
491
- const ensureBlockletCache = async (sites = [], blocklets) => {
491
+ const ensureBlockletCache = (sites = [], blocklets) => {
492
492
  return sites
493
493
  .map((site) => {
494
494
  if (!site.domain.endsWith(BLOCKLET_SITE_GROUP_SUFFIX)) {
@@ -493,7 +493,7 @@ class AuditLogState extends BaseState {
493
493
  });
494
494
  }
495
495
 
496
- async findPaginated({ scope, category, paging } = {}) {
496
+ findPaginated({ scope, category, paging } = {}) {
497
497
  const conditions = {};
498
498
  if (scope) {
499
499
  conditions.scope = scope;
@@ -35,7 +35,7 @@ class BackupState extends BaseState {
35
35
  /**
36
36
  * @param {Pick<import('@abtnode/models').BackupState, 'appPid' | 'userDid' | 'strategy' | 'sourceUrl' | 'target'>} backup
37
37
  */
38
- async start(backup) {
38
+ start(backup) {
39
39
  const { error, value } = validateBackupStart.validate(backup, {
40
40
  stripUnknown: true,
41
41
  allowUnknown: true,
@@ -52,7 +52,7 @@ class BackupState extends BaseState {
52
52
  * @param {string} id
53
53
  * @param {Pick<import('@abtnode/models').BackupState, 'targetUrl'>} successBackupInfo
54
54
  */
55
- async success(id, successBackupInfo) {
55
+ success(id, successBackupInfo) {
56
56
  const { error, value } = validateBackupSuccess.validate(successBackupInfo, {
57
57
  stripUnknown: true,
58
58
  allowUnknown: true,
@@ -78,7 +78,7 @@ class BackupState extends BaseState {
78
78
  * @param {string} id
79
79
  * @param {Pick<import('@abtnode/models').BackupState, 'message'>} errorBackupInfo
80
80
  */
81
- async fail(id, errorBackupInfo) {
81
+ fail(id, errorBackupInfo) {
82
82
  const { error, value } = validateBackupFail.validate(errorBackupInfo, {
83
83
  stripUnknown: true,
84
84
  allowUnknown: true,
@@ -104,6 +104,7 @@ class BackupState extends BaseState {
104
104
  * @param {import('@abtnode/models').BackupState} backup
105
105
  * @return {Promise<import('@abtnode/models').BackupState>}
106
106
  */
107
+ // eslint-disable-next-line require-await
107
108
  async create(backup) {
108
109
  const { error, value } = validateBackup.validate(backup, {
109
110
  allowUnknown: true,
@@ -121,7 +122,7 @@ class BackupState extends BaseState {
121
122
  * @param {{ did: string }} { did }
122
123
  * @return {Promise<Array<import('@abtnode/models').BackupState>>}
123
124
  */
124
- async getBlockletBackups({ did }) {
125
+ getBlockletBackups({ did }) {
125
126
  return this.find({ appPid: did }, {}, { updatedAt: -1 });
126
127
  }
127
128
  }
@@ -207,7 +207,7 @@ class BlockletExtrasState extends BaseState {
207
207
  return super.upsert({ did }, { $set: entity });
208
208
  }
209
209
 
210
- async getMeta(did) {
210
+ getMeta(did) {
211
211
  return super.findOne({ did }, { did: 1, controller: 1, meta: 1 });
212
212
  }
213
213
 
@@ -540,7 +540,7 @@ class BlockletState extends BaseState {
540
540
  return this.updateBlocklet(did, pick(doc, ['status', 'children']));
541
541
  }
542
542
 
543
- async setInstalledAt(did) {
543
+ setInstalledAt(did) {
544
544
  logger.info('setInstalledAt', { did });
545
545
  return this.updateBlocklet(did, { installedAt: new Date() });
546
546
  }
@@ -638,7 +638,7 @@ class BlockletState extends BaseState {
638
638
  });
639
639
  }
640
640
 
641
- async updateStructV1Did(did, v1Did) {
641
+ updateStructV1Did(did, v1Did) {
642
642
  return this.updateBlocklet(did, { structV1Did: v1Did });
643
643
  }
644
644
  }
@@ -15,7 +15,7 @@ class CacheState extends BaseState {
15
15
  return doc && doc.value;
16
16
  }
17
17
 
18
- async delete(key) {
18
+ delete(key) {
19
19
  return this.remove({ key });
20
20
  }
21
21
  }
@@ -204,7 +204,7 @@ class NodeState extends BaseState {
204
204
  return updated;
205
205
  }
206
206
 
207
- async updateNftHolder(holder) {
207
+ updateNftHolder(holder) {
208
208
  if (!holder) {
209
209
  throw new Error('NFT holder can not be empty');
210
210
  }
@@ -242,6 +242,7 @@ class NodeState extends BaseState {
242
242
  return this.updateNodeInfo({ previousMode: '', mode: info.previousMode });
243
243
  }
244
244
 
245
+ // eslint-disable-next-line require-await
245
246
  async setMode(mode) {
246
247
  if (Object.values(NODE_MODES).includes(mode) === false) {
247
248
  throw new Error(`Can not update server to unsupported mode: ${mode}`);
@@ -250,7 +251,7 @@ class NodeState extends BaseState {
250
251
  return this.updateNodeInfo({ previousMode: '', mode });
251
252
  }
252
253
 
253
- async getEnvironments() {
254
+ getEnvironments() {
254
255
  return this.read().then((info) => ({
255
256
  ABT_NODE: info.version,
256
257
  ABT_NODE_VERSION: info.version,
@@ -280,6 +281,7 @@ class NodeState extends BaseState {
280
281
  return doc.routing;
281
282
  }
282
283
 
284
+ // eslint-disable-next-line require-await
283
285
  async updateStatus(status) {
284
286
  if (!Object.values(SERVER_STATUS).includes(status)) {
285
287
  throw new Error('status is invalid');
@@ -288,6 +290,7 @@ class NodeState extends BaseState {
288
290
  return this.update({ $set: { status } });
289
291
  }
290
292
 
293
+ // eslint-disable-next-line require-await
291
294
  async resetStatus() {
292
295
  return this.updateStatus(SERVER_STATUS.RUNNING);
293
296
  }
@@ -44,7 +44,7 @@ class NotificationState extends BaseState {
44
44
  return doc;
45
45
  }
46
46
 
47
- async findPaginated({ read, paging } = {}) {
47
+ findPaginated({ read, paging } = {}) {
48
48
  const conditions = {};
49
49
  if (typeof read === 'boolean') {
50
50
  conditions.read = read;
@@ -49,7 +49,7 @@ module.exports = class RoutingSnapshot {
49
49
  init() {
50
50
  return this.timemachine
51
51
  .getLastSnapshot(true)
52
- .then(async (hash) => {
52
+ .then((hash) => {
53
53
  if (hash) {
54
54
  return hash;
55
55
  }
@@ -80,7 +80,7 @@ class SiteState extends BaseState {
80
80
  return sites.find((x) => x.domainAliases.some((y) => y.value === domain));
81
81
  }
82
82
 
83
- async findOneByBlocklet(did) {
83
+ findOneByBlocklet(did) {
84
84
  return this.findOne({ domain: getBlockletDomainGroupName(did) });
85
85
  }
86
86
 
@@ -105,11 +105,11 @@ class User extends ExtendBase {
105
105
  return this.getUser(did);
106
106
  }
107
107
 
108
- async revokePassportById({ did, id }) {
108
+ revokePassportById({ did, id }) {
109
109
  return this._setPassportStatusById({ did, id, status: PASSPORT_STATUS.REVOKED });
110
110
  }
111
111
 
112
- async enablePassportById({ did, id }) {
112
+ enablePassportById({ did, id }) {
113
113
  return this._setPassportStatusById({ did, id, status: PASSPORT_STATUS.VALID });
114
114
  }
115
115
 
@@ -160,6 +160,7 @@ class User extends ExtendBase {
160
160
  /**
161
161
  * Get blocklet service user list
162
162
  */
163
+ // eslint-disable-next-line require-await
163
164
  async getUsers({ query, sort, paging } = {}) {
164
165
  const where = {};
165
166
  const { approved, role, search } = query || {};
@@ -201,6 +202,7 @@ class User extends ExtendBase {
201
202
  return this.paginate({ where }, sorting, paging);
202
203
  }
203
204
 
205
+ // eslint-disable-next-line require-await
204
206
  async getUsersByDids({ dids, query }) {
205
207
  const { approved } = query || {};
206
208
  const condition = { did: dids };
@@ -211,6 +213,7 @@ class User extends ExtendBase {
211
213
  return this.find({ where: condition });
212
214
  }
213
215
 
216
+ // eslint-disable-next-line require-await
214
217
  async countByPassport({ name, status = PASSPORT_STATUS.VALID }) {
215
218
  if (name === '$none') {
216
219
  return this.count({
@@ -338,6 +341,7 @@ class User extends ExtendBase {
338
341
  return { ...updated, _action: exist ? 'update' : 'add' };
339
342
  }
340
343
 
344
+ // eslint-disable-next-line require-await
341
345
  async getUserByDid(did) {
342
346
  return this.findOne({ did }, { did: 1, pk: 1, fullName: 1, email: 1, role: 1, approved: 1 });
343
347
  }
@@ -96,19 +96,19 @@ class TeamManager extends EventEmitter {
96
96
  };
97
97
  }
98
98
 
99
- async getUserState(teamDid) {
99
+ getUserState(teamDid) {
100
100
  return this.getState(teamDid, 'user');
101
101
  }
102
102
 
103
- async getPassportState(teamDid) {
103
+ getPassportState(teamDid) {
104
104
  return this.getState(teamDid, 'passport');
105
105
  }
106
106
 
107
- async getConnectedAccountState(teamDid) {
107
+ getConnectedAccountState(teamDid) {
108
108
  return this.getState(teamDid, 'connectedAccount');
109
109
  }
110
110
 
111
- async getSessionState(teamDid) {
111
+ getSessionState(teamDid) {
112
112
  return this.getState(teamDid, 'session');
113
113
  }
114
114
 
@@ -207,7 +207,7 @@ class TeamManager extends EventEmitter {
207
207
  return this.states.blockletExtras.setSettings(metaDid, { trustedPassports });
208
208
  }
209
209
 
210
- async configTrustedFactories(did, trustedFactories) {
210
+ configTrustedFactories(did, trustedFactories) {
211
211
  if (this.isNodeTeam(did)) {
212
212
  return this.states.node.updateNodeInfo({ trustedFactories });
213
213
  }
@@ -408,7 +408,7 @@ class TeamManager extends EventEmitter {
408
408
  }
409
409
  }
410
410
 
411
- async getPid(did) {
411
+ getPid(did) {
412
412
  return this.isNodeTeam(did) ? did : this.states.blocklet.getBlockletMetaDid(did);
413
413
  }
414
414
  }
@@ -635,7 +635,7 @@ const startBlockletProcess = async (
635
635
  * Stop all precesses of a blocklet
636
636
  * @param {*} blocklet should contain env props
637
637
  */
638
- const stopBlockletProcess = async (blocklet, { preStop = noop, skippedProcessIds = [], componentDids } = {}) => {
638
+ const stopBlockletProcess = (blocklet, { preStop = noop, skippedProcessIds = [], componentDids } = {}) => {
639
639
  return deleteBlockletProcess(blocklet, { preDelete: preStop, skippedProcessIds, componentDids });
640
640
  };
641
641
 
@@ -673,7 +673,7 @@ const deleteBlockletProcess = async (blocklet, { preDelete = noop, skippedProces
673
673
  * Reload all precesses of a blocklet
674
674
  * @param {*} blocklet should contain env props
675
675
  */
676
- const reloadBlockletProcess = async (blocklet, { componentDids } = {}) =>
676
+ const reloadBlockletProcess = (blocklet, { componentDids } = {}) =>
677
677
  forEachBlocklet(
678
678
  blocklet,
679
679
  async (b) => {
@@ -714,7 +714,7 @@ const getProcessInfo = (processId, { throwOnNotExist = true } = {}) =>
714
714
 
715
715
  const deleteProcess = (processId) =>
716
716
  new Promise((resolve, reject) => {
717
- pm2.delete(processId, async (err) => {
717
+ pm2.delete(processId, (err) => {
718
718
  if (isUsefulError(err)) {
719
719
  logger.error('blocklet process delete failed', { error: err });
720
720
  return reject(err);
@@ -725,7 +725,7 @@ const deleteProcess = (processId) =>
725
725
 
726
726
  const reloadProcess = (processId) =>
727
727
  new Promise((resolve, reject) => {
728
- pm2.reload(processId, async (err) => {
728
+ pm2.reload(processId, (err) => {
729
729
  if (err) {
730
730
  if (isUsefulError(err)) {
731
731
  logger.error('blocklet reload failed', { error: err });
@@ -859,7 +859,7 @@ const parseComponents = async (component, context = {}) => {
859
859
  };
860
860
 
861
861
  const validateBlocklet = (blocklet) =>
862
- forEachBlocklet(blocklet, async (b) => {
862
+ forEachBlocklet(blocklet, (b) => {
863
863
  isRequirementsSatisfied(b.meta.requirements);
864
864
  validateEngine(getBlockletEngineNameByPlatform(b.meta));
865
865
  });
package/lib/util/rpc.js CHANGED
@@ -9,7 +9,7 @@ const logger = require('@abtnode/logger')('@abtnode/core:rpc');
9
9
  const host = '127.0.0.1';
10
10
  const port = Number(process.env.ABT_NODE_UPDATER_PORT || 40405);
11
11
 
12
- const doRpcCall = async (message) =>
12
+ const doRpcCall = (message) =>
13
13
  new Promise((resolve) => {
14
14
  logger.info('try send rpc request', message);
15
15
  const sock = axon.socket('req');
package/lib/util/store.js CHANGED
@@ -120,7 +120,7 @@ const parseSourceUrl = async (url) => {
120
120
  };
121
121
  };
122
122
 
123
- const resolveTarballURL = async ({ did, tarball = '', storeUrl = '' }) => {
123
+ const resolveTarballURL = ({ did, tarball = '', storeUrl = '' }) => {
124
124
  if (!tarball) {
125
125
  return '';
126
126
  }
@@ -20,7 +20,7 @@ class APISender extends BaseSender {
20
20
  }
21
21
  }
22
22
 
23
- async sendTestMessage(params, message) {
23
+ sendTestMessage(params, message) {
24
24
  return this.send(params, {
25
25
  description: message,
26
26
  status: 'info',
@@ -64,7 +64,7 @@ class SlackSender extends BaseSender {
64
64
  }
65
65
  }
66
66
 
67
- async sendTestMessage(params, message) {
67
+ sendTestMessage(params, message) {
68
68
  return this.send(
69
69
  params,
70
70
  {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.11-next-ca5f18b5",
6
+ "version": "1.16.11-next-3e55bc95",
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": "Apache-2.0",
21
21
  "dependencies": {
22
- "@abtnode/auth": "1.16.11-next-ca5f18b5",
23
- "@abtnode/certificate-manager": "1.16.11-next-ca5f18b5",
24
- "@abtnode/constant": "1.16.11-next-ca5f18b5",
25
- "@abtnode/cron": "1.16.11-next-ca5f18b5",
26
- "@abtnode/logger": "1.16.11-next-ca5f18b5",
27
- "@abtnode/models": "1.16.11-next-ca5f18b5",
28
- "@abtnode/queue": "1.16.11-next-ca5f18b5",
29
- "@abtnode/rbac": "1.16.11-next-ca5f18b5",
30
- "@abtnode/router-provider": "1.16.11-next-ca5f18b5",
31
- "@abtnode/static-server": "1.16.11-next-ca5f18b5",
32
- "@abtnode/timemachine": "1.16.11-next-ca5f18b5",
33
- "@abtnode/util": "1.16.11-next-ca5f18b5",
22
+ "@abtnode/auth": "1.16.11-next-3e55bc95",
23
+ "@abtnode/certificate-manager": "1.16.11-next-3e55bc95",
24
+ "@abtnode/constant": "1.16.11-next-3e55bc95",
25
+ "@abtnode/cron": "1.16.11-next-3e55bc95",
26
+ "@abtnode/logger": "1.16.11-next-3e55bc95",
27
+ "@abtnode/models": "1.16.11-next-3e55bc95",
28
+ "@abtnode/queue": "1.16.11-next-3e55bc95",
29
+ "@abtnode/rbac": "1.16.11-next-3e55bc95",
30
+ "@abtnode/router-provider": "1.16.11-next-3e55bc95",
31
+ "@abtnode/static-server": "1.16.11-next-3e55bc95",
32
+ "@abtnode/timemachine": "1.16.11-next-3e55bc95",
33
+ "@abtnode/util": "1.16.11-next-3e55bc95",
34
34
  "@arcblock/did": "1.18.80",
35
35
  "@arcblock/did-auth": "1.18.80",
36
36
  "@arcblock/did-ext": "^1.18.80",
@@ -41,9 +41,9 @@
41
41
  "@arcblock/pm2-events": "^0.0.5",
42
42
  "@arcblock/validator": "^1.18.80",
43
43
  "@arcblock/vc": "1.18.80",
44
- "@blocklet/constant": "1.16.11-next-ca5f18b5",
45
- "@blocklet/meta": "1.16.11-next-ca5f18b5",
46
- "@blocklet/sdk": "1.16.11-next-ca5f18b5",
44
+ "@blocklet/constant": "1.16.11-next-3e55bc95",
45
+ "@blocklet/meta": "1.16.11-next-3e55bc95",
46
+ "@blocklet/sdk": "1.16.11-next-3e55bc95",
47
47
  "@did-space/client": "^0.2.113",
48
48
  "@fidm/x509": "^1.2.1",
49
49
  "@ocap/mcrypto": "1.18.80",
@@ -96,5 +96,5 @@
96
96
  "express": "^4.18.2",
97
97
  "jest": "^27.5.1"
98
98
  },
99
- "gitHead": "d797d0177d585b66d17876c99c994fda4d812f37"
99
+ "gitHead": "cf0251c2d85c617b03151495b5944061ceb373e5"
100
100
  }