@abtnode/core 1.16.52 → 1.16.53-beta-20251009-113612-7a16b6a0
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 +46 -15
- package/lib/blocklet/manager/helper/blue-green-start-blocklet.js +17 -8
- package/lib/blocklet/manager/helper/blue-green-upgrade-blocklet.js +1 -0
- package/lib/blocklet/migration-dist/migration.cjs +5 -1
- package/lib/index.js +18 -1
- package/lib/util/blocklet.js +2 -4
- package/package.json +24 -24
package/lib/api/team.js
CHANGED
|
@@ -223,7 +223,7 @@ class TeamAPI extends EventEmitter {
|
|
|
223
223
|
*
|
|
224
224
|
* @param {object} states abtnode core StateDB
|
|
225
225
|
*/
|
|
226
|
-
constructor({ teamManager, states, dataDirs, nodeAPI, passportAPI }) {
|
|
226
|
+
constructor({ teamManager, states, dataDirs, nodeAPI, passportAPI, passportIssueQueue }) {
|
|
227
227
|
super();
|
|
228
228
|
|
|
229
229
|
this.notification = states.notification;
|
|
@@ -236,6 +236,7 @@ class TeamAPI extends EventEmitter {
|
|
|
236
236
|
this.nodeAPI = nodeAPI;
|
|
237
237
|
this.passportAPI = passportAPI;
|
|
238
238
|
this.throttleMap = new Map();
|
|
239
|
+
this.passportIssueQueue = passportIssueQueue;
|
|
239
240
|
// 创建一个通用的节流发送函数
|
|
240
241
|
this.throttledEmit = throttle(
|
|
241
242
|
(eventName, payload) => {
|
|
@@ -249,6 +250,12 @@ class TeamAPI extends EventEmitter {
|
|
|
249
250
|
this.runtimeMonitor = new BlockletRuntimeMonitor({ states });
|
|
250
251
|
}
|
|
251
252
|
|
|
253
|
+
async onJob(job) {
|
|
254
|
+
if (job.entity === 'blocklet' && job.action === 'issueOrgOwnerPassport') {
|
|
255
|
+
await this.issueOrgOwnerPassport(job.params);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
252
259
|
getThrottledEmit(teamDid) {
|
|
253
260
|
if (!this.throttleMap.has(teamDid)) {
|
|
254
261
|
this.throttleMap.set(teamDid, this.throttledEmit);
|
|
@@ -2840,13 +2847,29 @@ class TeamAPI extends EventEmitter {
|
|
|
2840
2847
|
}
|
|
2841
2848
|
}
|
|
2842
2849
|
|
|
2843
|
-
async
|
|
2850
|
+
async issueOrgOwnerPassport({ teamDid, org }) {
|
|
2851
|
+
try {
|
|
2852
|
+
// 创建 org 的 owner passport, 并赋值给 owner
|
|
2853
|
+
const roleName = md5(`${org.id}-owner`); // 避免 name 重复
|
|
2854
|
+
await this.createRole({ teamDid, name: roleName, title: org.name, description: 'Owner', orgId: org.id });
|
|
2855
|
+
await this.issuePassportToUser({
|
|
2856
|
+
teamDid,
|
|
2857
|
+
userDid: org.ownerDid,
|
|
2858
|
+
role: roleName,
|
|
2859
|
+
notification: {},
|
|
2860
|
+
});
|
|
2861
|
+
} catch (err) {
|
|
2862
|
+
logger.error('Failed to create passport to org owner', { err, teamDid, org });
|
|
2863
|
+
}
|
|
2864
|
+
}
|
|
2865
|
+
|
|
2866
|
+
async createOrg({ teamDid, deferPassport = false, ...rest }, context) {
|
|
2844
2867
|
try {
|
|
2845
2868
|
// 1. 对输入进行转义
|
|
2846
2869
|
const sanitizedOrg = {
|
|
2847
2870
|
...rest,
|
|
2848
|
-
description: sanitizeTag(rest.description),
|
|
2849
|
-
name: sanitizeTag(rest.name),
|
|
2871
|
+
description: sanitizeTag(rest.description || ''),
|
|
2872
|
+
name: sanitizeTag(rest.name || ''),
|
|
2850
2873
|
};
|
|
2851
2874
|
|
|
2852
2875
|
const { error } = createOrgInputSchema.validate(sanitizedOrg);
|
|
@@ -2861,7 +2884,8 @@ class TeamAPI extends EventEmitter {
|
|
|
2861
2884
|
dataDirs: this.dataDirs,
|
|
2862
2885
|
useCache: true,
|
|
2863
2886
|
});
|
|
2864
|
-
const
|
|
2887
|
+
const checkedUserDid = rest.ownerDid || context.user.did || '';
|
|
2888
|
+
const orgCount = await state.getOrgCountByUser(checkedUserDid);
|
|
2865
2889
|
|
|
2866
2890
|
const { veriftMaxOrgPerUser } = createOrgValidators(blocklet);
|
|
2867
2891
|
|
|
@@ -2870,16 +2894,23 @@ class TeamAPI extends EventEmitter {
|
|
|
2870
2894
|
const result = await state.create({ ...sanitizedOrg }, context);
|
|
2871
2895
|
|
|
2872
2896
|
// 创建 org 的 owner passport, 并赋值给 owner
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2897
|
+
if (!deferPassport) {
|
|
2898
|
+
await this.issueOrgOwnerPassport({ teamDid, org: result });
|
|
2899
|
+
} else {
|
|
2900
|
+
const jobId = md5(`${teamDid}-${result.id}-${checkedUserDid}`);
|
|
2901
|
+
this.passportIssueQueue.push(
|
|
2902
|
+
{
|
|
2903
|
+
action: 'issueOrgOwnerPassport',
|
|
2904
|
+
entity: 'blocklet',
|
|
2905
|
+
params: {
|
|
2906
|
+
teamDid,
|
|
2907
|
+
org: result,
|
|
2908
|
+
},
|
|
2909
|
+
},
|
|
2910
|
+
jobId,
|
|
2911
|
+
true
|
|
2912
|
+
);
|
|
2913
|
+
}
|
|
2883
2914
|
|
|
2884
2915
|
return result;
|
|
2885
2916
|
} catch (err) {
|
|
@@ -125,7 +125,7 @@ const blueGreenStartBlocklet = async (
|
|
|
125
125
|
await states.blocklet.setBlockletStatus(did, BlockletStatus.running, {
|
|
126
126
|
componentDids: nonEntryComponentIds,
|
|
127
127
|
operator,
|
|
128
|
-
|
|
128
|
+
isGreenAndBlue: true,
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
131
|
|
|
@@ -173,13 +173,6 @@ const blueGreenStartBlocklet = async (
|
|
|
173
173
|
if (!item.componentDids.length) {
|
|
174
174
|
continue;
|
|
175
175
|
}
|
|
176
|
-
const nextBlocklet = await ensureAppPortsNotOccupied({
|
|
177
|
-
blocklet: blocklet1,
|
|
178
|
-
componentDids: item.componentDids,
|
|
179
|
-
states,
|
|
180
|
-
manager,
|
|
181
|
-
isGreen: item.changeToGreen,
|
|
182
|
-
});
|
|
183
176
|
|
|
184
177
|
try {
|
|
185
178
|
const doc1 = await states.blocklet.setBlockletStatus(did, BlockletStatus.starting, {
|
|
@@ -187,6 +180,15 @@ const blueGreenStartBlocklet = async (
|
|
|
187
180
|
operator,
|
|
188
181
|
isGreen: item.changeToGreen,
|
|
189
182
|
});
|
|
183
|
+
|
|
184
|
+
const nextBlocklet = await ensureAppPortsNotOccupied({
|
|
185
|
+
blocklet: blocklet1,
|
|
186
|
+
componentDids: item.componentDids,
|
|
187
|
+
states,
|
|
188
|
+
manager,
|
|
189
|
+
isGreen: item.changeToGreen,
|
|
190
|
+
});
|
|
191
|
+
|
|
190
192
|
nextBlocklet.greenStatus = BlockletStatus.starting;
|
|
191
193
|
manager.emit(BlockletEvents.statusChange, doc1);
|
|
192
194
|
|
|
@@ -263,6 +265,13 @@ const blueGreenStartBlocklet = async (
|
|
|
263
265
|
|
|
264
266
|
try {
|
|
265
267
|
await manager.deleteProcess({ did, componentDids: item.componentDids, isGreen: item.changeToGreen });
|
|
268
|
+
// 如果需要把失败状态设置成 error:
|
|
269
|
+
// const doc1 = await states.blocklet.setBlockletStatus(did, BlockletStatus.error, {
|
|
270
|
+
// componentDids: item.componentDids,
|
|
271
|
+
// operator,
|
|
272
|
+
// isGreen: item.changeToGreen,
|
|
273
|
+
// });
|
|
274
|
+
// manager.emit(BlockletEvents.statusChange, doc1);
|
|
266
275
|
manager.emit(BlockletEvents.statusChange, blocklet1);
|
|
267
276
|
} catch (cleanupError) {
|
|
268
277
|
logger.error('Failed to cleanup green environment', { cleanupError });
|
|
@@ -159,6 +159,7 @@ const blueGreenUpgradeBlocklet = async (
|
|
|
159
159
|
return blocklet;
|
|
160
160
|
} catch (err) {
|
|
161
161
|
logger.error('failed to upgrade blocklet', { did, version, name, error: err });
|
|
162
|
+
await states.blocklet.upgradeBlocklet({ ...oldBlocklet });
|
|
162
163
|
manager.configSynchronizer.throttledSyncAppConfig(oldBlocklet);
|
|
163
164
|
await manager._updateDependents(did);
|
|
164
165
|
|
|
@@ -759,6 +759,10 @@ module.exports = Object.freeze({
|
|
|
759
759
|
checkDomains: true,
|
|
760
760
|
isDidDomain: true,
|
|
761
761
|
},
|
|
762
|
+
SDK_ALLOWED_METHODS: {
|
|
763
|
+
configBlocklet: true,
|
|
764
|
+
configNavigations: true,
|
|
765
|
+
},
|
|
762
766
|
// 这些接口可以跳过 ACCESS VERIFY
|
|
763
767
|
SKIP_ACCESS_VERIFY_METHODS: {
|
|
764
768
|
makeAllNotificationsAsRead: true,
|
|
@@ -38950,7 +38954,7 @@ module.exports = require("zlib");
|
|
|
38950
38954
|
/***/ ((module) => {
|
|
38951
38955
|
|
|
38952
38956
|
"use strict";
|
|
38953
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@abtnode/core","publishConfig":{"access":"public"},"version":"1.16.
|
|
38957
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@abtnode/core","publishConfig":{"access":"public"},"version":"1.16.52","description":"","main":"lib/index.js","files":["lib"],"scripts":{"lint":"eslint tests lib --ignore-pattern \'tests/assets/*\'","lint:fix":"eslint --fix tests lib","test":"node tools/jest.js","test:disk":"CI=true npm run test tests/blocklet/manager/disk.spec.js","test:blue":"CI=true npm run test tests/blocklet/manager/disk-blue-green.spec.js","coverage":"npm run test -- --coverage"},"keywords":[],"author":"wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)","license":"Apache-2.0","dependencies":{"@abtnode/analytics":"1.16.52","@abtnode/auth":"1.16.52","@abtnode/certificate-manager":"1.16.52","@abtnode/constant":"1.16.52","@abtnode/cron":"1.16.52","@abtnode/db-cache":"1.16.52","@abtnode/docker-utils":"1.16.52","@abtnode/logger":"1.16.52","@abtnode/models":"1.16.52","@abtnode/queue":"1.16.52","@abtnode/rbac":"1.16.52","@abtnode/router-provider":"1.16.52","@abtnode/static-server":"1.16.52","@abtnode/timemachine":"1.16.52","@abtnode/util":"1.16.52","@aigne/aigne-hub":"^0.10.0","@arcblock/did":"1.25.6","@arcblock/did-connect-js":"1.25.6","@arcblock/did-ext":"1.25.6","@arcblock/did-motif":"^1.1.14","@arcblock/did-util":"1.25.6","@arcblock/event-hub":"1.25.6","@arcblock/jwt":"1.25.6","@arcblock/pm2-events":"^0.0.5","@arcblock/validator":"1.25.6","@arcblock/vc":"1.25.6","@blocklet/constant":"1.16.52","@blocklet/did-space-js":"^1.1.29","@blocklet/env":"1.16.52","@blocklet/error":"^0.2.5","@blocklet/meta":"1.16.52","@blocklet/resolver":"1.16.52","@blocklet/sdk":"1.16.52","@blocklet/server-js":"1.16.52","@blocklet/store":"1.16.52","@blocklet/theme":"^3.1.45","@fidm/x509":"^1.2.1","@ocap/mcrypto":"1.25.6","@ocap/util":"1.25.6","@ocap/wallet":"1.25.6","@slack/webhook":"^5.0.4","archiver":"^7.0.1","axios":"^1.7.9","axon":"^2.0.3","chalk":"^4.1.2","cross-spawn":"^7.0.3","dayjs":"^1.11.13","deep-diff":"^1.0.2","detect-port":"^1.5.1","envfile":"^7.1.0","escape-string-regexp":"^4.0.0","fast-glob":"^3.3.2","filesize":"^10.1.1","flat":"^5.0.2","fs-extra":"^11.2.0","get-port":"^5.1.1","hasha":"^5.2.2","is-base64":"^1.1.0","is-cidr":"4","is-ip":"3","is-url":"^1.2.4","joi":"17.12.2","joi-extension-semver":"^5.0.0","js-yaml":"^4.1.0","kill-port":"^2.0.1","lodash":"^4.17.21","node-stream-zip":"^1.15.0","p-all":"^3.0.0","p-limit":"^3.1.0","p-map":"^4.0.0","p-retry":"^4.6.2","p-wait-for":"^3.2.0","private-ip":"^2.3.4","rate-limiter-flexible":"^5.0.5","read-last-lines":"^1.8.0","semver":"^7.6.3","sequelize":"^6.35.0","shelljs":"^0.8.5","slugify":"^1.6.6","ssri":"^8.0.1","stream-throttle":"^0.1.3","stream-to-promise":"^3.0.0","systeminformation":"^5.23.3","tail":"^2.2.4","tar":"^6.1.11","transliteration":"^2.3.5","ua-parser-js":"^1.0.2","ufo":"^1.5.3","uuid":"^11.1.0","valid-url":"^1.0.9","which":"^2.0.2","xbytes":"^1.8.0"},"devDependencies":{"expand-tilde":"^2.0.2","express":"^4.18.2","jest":"^29.7.0","unzipper":"^0.10.11"},"gitHead":"e5764f753181ed6a7c615cd4fc6682aacf0cb7cd"}');
|
|
38954
38958
|
|
|
38955
38959
|
/***/ }),
|
|
38956
38960
|
|
package/lib/index.js
CHANGED
|
@@ -222,6 +222,23 @@ function ABTNode(options) {
|
|
|
222
222
|
},
|
|
223
223
|
});
|
|
224
224
|
|
|
225
|
+
const passportIssueQueue = createQueue({
|
|
226
|
+
daemon: options.daemon,
|
|
227
|
+
model: states.job,
|
|
228
|
+
name: 'passport_issue_queue',
|
|
229
|
+
onJob: async (job) => {
|
|
230
|
+
if (typeof teamAPI.onJob === 'function') {
|
|
231
|
+
await teamAPI.onJob(job);
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
options: {
|
|
235
|
+
concurrency,
|
|
236
|
+
maxRetries: 30,
|
|
237
|
+
retryDelay: 60 * 1000, // retry after 1 minute
|
|
238
|
+
maxTimeout: 60 * 1000 * 30, // throw timeout error after 30 minutes
|
|
239
|
+
},
|
|
240
|
+
});
|
|
241
|
+
|
|
225
242
|
// 3. init team manager
|
|
226
243
|
const teamManager = new TeamManager({ nodeDid: options.nodeDid, dataDirs, states });
|
|
227
244
|
|
|
@@ -265,7 +282,7 @@ function ABTNode(options) {
|
|
|
265
282
|
|
|
266
283
|
const nodeAPI = new NodeAPI(states, options.nodeDid);
|
|
267
284
|
const passportAPI = new PassportAPI({ states, teamManager, nodeAPI, teamDid: options.nodeDid });
|
|
268
|
-
const teamAPI = new TeamAPI({ states, teamManager, dataDirs, nodeAPI, passportAPI });
|
|
285
|
+
const teamAPI = new TeamAPI({ states, teamManager, dataDirs, nodeAPI, passportAPI, passportIssueQueue });
|
|
269
286
|
|
|
270
287
|
// 5. init blocklet manager
|
|
271
288
|
const blockletManager = new BlockletManager({
|
package/lib/util/blocklet.js
CHANGED
|
@@ -854,11 +854,9 @@ const startBlockletProcess = async (
|
|
|
854
854
|
}
|
|
855
855
|
|
|
856
856
|
// run hook
|
|
857
|
-
|
|
858
|
-
await postStart(b, { env });
|
|
859
|
-
} catch (err) {
|
|
857
|
+
postStart(b, { env }).catch((err) => {
|
|
860
858
|
logger.error('blocklet post start failed', { processId: processIdName, error: err });
|
|
861
|
-
}
|
|
859
|
+
});
|
|
862
860
|
};
|
|
863
861
|
|
|
864
862
|
await forEachBlocklet(
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.
|
|
6
|
+
"version": "1.16.53-beta-20251009-113612-7a16b6a0",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -21,21 +21,21 @@
|
|
|
21
21
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
22
22
|
"license": "Apache-2.0",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@abtnode/analytics": "1.16.
|
|
25
|
-
"@abtnode/auth": "1.16.
|
|
26
|
-
"@abtnode/certificate-manager": "1.16.
|
|
27
|
-
"@abtnode/constant": "1.16.
|
|
28
|
-
"@abtnode/cron": "1.16.
|
|
29
|
-
"@abtnode/db-cache": "1.16.
|
|
30
|
-
"@abtnode/docker-utils": "1.16.
|
|
31
|
-
"@abtnode/logger": "1.16.
|
|
32
|
-
"@abtnode/models": "1.16.
|
|
33
|
-
"@abtnode/queue": "1.16.
|
|
34
|
-
"@abtnode/rbac": "1.16.
|
|
35
|
-
"@abtnode/router-provider": "1.16.
|
|
36
|
-
"@abtnode/static-server": "1.16.
|
|
37
|
-
"@abtnode/timemachine": "1.16.
|
|
38
|
-
"@abtnode/util": "1.16.
|
|
24
|
+
"@abtnode/analytics": "1.16.53-beta-20251009-113612-7a16b6a0",
|
|
25
|
+
"@abtnode/auth": "1.16.53-beta-20251009-113612-7a16b6a0",
|
|
26
|
+
"@abtnode/certificate-manager": "1.16.53-beta-20251009-113612-7a16b6a0",
|
|
27
|
+
"@abtnode/constant": "1.16.53-beta-20251009-113612-7a16b6a0",
|
|
28
|
+
"@abtnode/cron": "1.16.53-beta-20251009-113612-7a16b6a0",
|
|
29
|
+
"@abtnode/db-cache": "1.16.53-beta-20251009-113612-7a16b6a0",
|
|
30
|
+
"@abtnode/docker-utils": "1.16.53-beta-20251009-113612-7a16b6a0",
|
|
31
|
+
"@abtnode/logger": "1.16.53-beta-20251009-113612-7a16b6a0",
|
|
32
|
+
"@abtnode/models": "1.16.53-beta-20251009-113612-7a16b6a0",
|
|
33
|
+
"@abtnode/queue": "1.16.53-beta-20251009-113612-7a16b6a0",
|
|
34
|
+
"@abtnode/rbac": "1.16.53-beta-20251009-113612-7a16b6a0",
|
|
35
|
+
"@abtnode/router-provider": "1.16.53-beta-20251009-113612-7a16b6a0",
|
|
36
|
+
"@abtnode/static-server": "1.16.53-beta-20251009-113612-7a16b6a0",
|
|
37
|
+
"@abtnode/timemachine": "1.16.53-beta-20251009-113612-7a16b6a0",
|
|
38
|
+
"@abtnode/util": "1.16.53-beta-20251009-113612-7a16b6a0",
|
|
39
39
|
"@aigne/aigne-hub": "^0.10.0",
|
|
40
40
|
"@arcblock/did": "1.25.6",
|
|
41
41
|
"@arcblock/did-connect-js": "1.25.6",
|
|
@@ -47,15 +47,15 @@
|
|
|
47
47
|
"@arcblock/pm2-events": "^0.0.5",
|
|
48
48
|
"@arcblock/validator": "1.25.6",
|
|
49
49
|
"@arcblock/vc": "1.25.6",
|
|
50
|
-
"@blocklet/constant": "1.16.
|
|
50
|
+
"@blocklet/constant": "1.16.53-beta-20251009-113612-7a16b6a0",
|
|
51
51
|
"@blocklet/did-space-js": "^1.1.29",
|
|
52
|
-
"@blocklet/env": "1.16.
|
|
52
|
+
"@blocklet/env": "1.16.53-beta-20251009-113612-7a16b6a0",
|
|
53
53
|
"@blocklet/error": "^0.2.5",
|
|
54
|
-
"@blocklet/meta": "1.16.
|
|
55
|
-
"@blocklet/resolver": "1.16.
|
|
56
|
-
"@blocklet/sdk": "1.16.
|
|
57
|
-
"@blocklet/server-js": "1.16.
|
|
58
|
-
"@blocklet/store": "1.16.
|
|
54
|
+
"@blocklet/meta": "1.16.53-beta-20251009-113612-7a16b6a0",
|
|
55
|
+
"@blocklet/resolver": "1.16.53-beta-20251009-113612-7a16b6a0",
|
|
56
|
+
"@blocklet/sdk": "1.16.53-beta-20251009-113612-7a16b6a0",
|
|
57
|
+
"@blocklet/server-js": "1.16.53-beta-20251009-113612-7a16b6a0",
|
|
58
|
+
"@blocklet/store": "1.16.53-beta-20251009-113612-7a16b6a0",
|
|
59
59
|
"@blocklet/theme": "^3.1.45",
|
|
60
60
|
"@fidm/x509": "^1.2.1",
|
|
61
61
|
"@ocap/mcrypto": "1.25.6",
|
|
@@ -120,5 +120,5 @@
|
|
|
120
120
|
"jest": "^29.7.0",
|
|
121
121
|
"unzipper": "^0.10.11"
|
|
122
122
|
},
|
|
123
|
-
"gitHead": "
|
|
123
|
+
"gitHead": "cb28aceba798cdfe4073bb6df9514c09aa3587ba"
|
|
124
124
|
}
|