@abtnode/core 1.8.63-beta-b71f5f80 → 1.8.63-beta-a36b5e1a
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/blocklet/manager/disk.js +12 -10
- package/lib/cert.js +74 -20
- package/lib/event.js +2 -0
- package/lib/index.js +1 -0
- package/lib/router/helper.js +21 -19
- package/lib/util/blocklet.js +1 -1
- package/package.json +17 -17
|
@@ -3583,16 +3583,18 @@ class BlockletManager extends BaseBlockletManager {
|
|
|
3583
3583
|
fs.removeSync(cacheDir);
|
|
3584
3584
|
await this._cleanBlockletData({ blocklet, keepData, keepLogsDir, keepConfigs });
|
|
3585
3585
|
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3586
|
+
if (blocklet.mode !== BLOCKLET_MODES.DEVELOPMENT) {
|
|
3587
|
+
const nodeInfo = await states.node.read();
|
|
3588
|
+
const { wallet } = getBlockletInfo(blocklet, nodeInfo.sk);
|
|
3589
|
+
didDocument
|
|
3590
|
+
.disableDNS({ wallet, didRegistryUrl: nodeInfo.didRegistry })
|
|
3591
|
+
.then(() => {
|
|
3592
|
+
logger.info(`disabled blocklet ${blocklet.appDid} dns`);
|
|
3593
|
+
})
|
|
3594
|
+
.catch((err) => {
|
|
3595
|
+
logger.error(`disable blocklet ${blocklet.appDid} dns failed`, { error: err });
|
|
3596
|
+
});
|
|
3597
|
+
}
|
|
3596
3598
|
|
|
3597
3599
|
const result = await states.blocklet.deleteBlocklet(did);
|
|
3598
3600
|
logger.info('blocklet removed successfully', { did });
|
package/lib/cert.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
const { EventEmitter } = require('events');
|
|
2
2
|
const CertificateManager = require('@abtnode/certificate-manager/sdk/manager');
|
|
3
3
|
const logger = require('@abtnode/logger')('@abtnode/core:cert');
|
|
4
|
-
const
|
|
4
|
+
const { EVENTS } = require('@abtnode/constant');
|
|
5
|
+
const { BlockletEvents } = require('@blocklet/constant');
|
|
5
6
|
|
|
6
|
-
const onCertExpired = async (cert) => {
|
|
7
|
+
const onCertExpired = async (cert, states) => {
|
|
7
8
|
logger.info('send certificate expire notification', { domain: cert.domain });
|
|
8
9
|
states.notification.create({
|
|
9
10
|
title: 'SSL Certificate Expired',
|
|
@@ -14,7 +15,7 @@ const onCertExpired = async (cert) => {
|
|
|
14
15
|
});
|
|
15
16
|
};
|
|
16
17
|
|
|
17
|
-
const onCertAboutExpire = (cert) => {
|
|
18
|
+
const onCertAboutExpire = (cert, states) => {
|
|
18
19
|
logger.info('send certificate about-expire notification', { domain: cert.domain });
|
|
19
20
|
states.notification.create({
|
|
20
21
|
title: 'SSL Certificate Expire Warning',
|
|
@@ -27,7 +28,7 @@ const onCertAboutExpire = (cert) => {
|
|
|
27
28
|
});
|
|
28
29
|
};
|
|
29
30
|
|
|
30
|
-
const onCertIssued = (cert) => {
|
|
31
|
+
const onCertIssued = (cert, states) => {
|
|
31
32
|
states.notification.create({
|
|
32
33
|
title: 'Certificate Issued',
|
|
33
34
|
description: `The ${cert.domain} certificate is issued successfully`,
|
|
@@ -37,7 +38,7 @@ const onCertIssued = (cert) => {
|
|
|
37
38
|
});
|
|
38
39
|
};
|
|
39
40
|
|
|
40
|
-
const onCertIssueFailed = (cert) => {
|
|
41
|
+
const onCertIssueFailed = (cert, states) => {
|
|
41
42
|
states.notification.create({
|
|
42
43
|
title: 'Certificate Issue Failed',
|
|
43
44
|
description: `Failed to issue certificate for ${cert.domain}`,
|
|
@@ -56,22 +57,21 @@ const getDomainFromInput = (input) => {
|
|
|
56
57
|
};
|
|
57
58
|
|
|
58
59
|
class Cert extends EventEmitter {
|
|
59
|
-
constructor({ maintainerEmail, dataDir }) {
|
|
60
|
+
constructor({ maintainerEmail, dataDir, states }) {
|
|
60
61
|
super();
|
|
61
62
|
|
|
62
63
|
this.manager = new CertificateManager({ maintainerEmail, dataDir });
|
|
63
64
|
|
|
64
|
-
this.manager.on('cert.issued', (
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
this.manager.on('cert.issued', this._onCertIssued.bind(this));
|
|
66
|
+
this.manager.on('cert.expired', this._onCertExpired.bind(this));
|
|
67
|
+
this.manager.on('cert.about_to_expire', this._onCertAboutToExpire.bind(this));
|
|
68
|
+
this.manager.on('cert.error', this._onCertError.bind(this));
|
|
68
69
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
});
|
|
70
|
+
/**
|
|
71
|
+
* Array<{domain: string, did: string}>
|
|
72
|
+
*/
|
|
73
|
+
this._blockletDomains = [];
|
|
74
|
+
this.states = states;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
start() {
|
|
@@ -110,20 +110,29 @@ class Cert extends EventEmitter {
|
|
|
110
110
|
|
|
111
111
|
const result = await this.manager.add(data);
|
|
112
112
|
logger.info('add certificate result', { name: result.name });
|
|
113
|
-
this.emit(
|
|
113
|
+
this.emit(EVENTS.CERT_ADDED, result);
|
|
114
114
|
|
|
115
115
|
return result;
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
|
|
118
|
+
/**
|
|
119
|
+
* @param {{
|
|
120
|
+
* did?:string // blocklet.meta.did
|
|
121
|
+
* }}
|
|
122
|
+
*/
|
|
123
|
+
async issue({ domain, did }) {
|
|
119
124
|
logger.info(`generate certificate for ${domain}`);
|
|
120
125
|
|
|
126
|
+
if (did) {
|
|
127
|
+
this._bindBlocklet({ domain, did });
|
|
128
|
+
}
|
|
129
|
+
|
|
121
130
|
return this.manager.issue(domain);
|
|
122
131
|
}
|
|
123
132
|
|
|
124
133
|
async upsertByDomain(data) {
|
|
125
134
|
const result = await this.manager.upsertByDomain(data);
|
|
126
|
-
this.emit(
|
|
135
|
+
this.emit(EVENTS.CERT_UPDATED, result);
|
|
127
136
|
|
|
128
137
|
return result;
|
|
129
138
|
}
|
|
@@ -135,7 +144,7 @@ class Cert extends EventEmitter {
|
|
|
135
144
|
async remove({ id }) {
|
|
136
145
|
await this.manager.remove(id);
|
|
137
146
|
logger.info('delete certificate', { id });
|
|
138
|
-
this.emit(
|
|
147
|
+
this.emit(EVENTS.CERT_REMOVED);
|
|
139
148
|
|
|
140
149
|
return {};
|
|
141
150
|
}
|
|
@@ -147,6 +156,51 @@ class Cert extends EventEmitter {
|
|
|
147
156
|
async updateWithoutValidations(id, data) {
|
|
148
157
|
return this.manager.updateWithoutValidations(id, data);
|
|
149
158
|
}
|
|
159
|
+
|
|
160
|
+
_bindBlocklet({ domain, did }) {
|
|
161
|
+
// only save 100 domains in memory
|
|
162
|
+
const list = this._blockletDomains.slice(-100).filter((x) => x.domain !== domain);
|
|
163
|
+
list.push({ domain, did });
|
|
164
|
+
this._blockletDomains = list;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* @param {{
|
|
169
|
+
* blocklet: string;
|
|
170
|
+
* server: string;
|
|
171
|
+
* }} event
|
|
172
|
+
* @param {{
|
|
173
|
+
* domain: string
|
|
174
|
+
* }} cert
|
|
175
|
+
*/
|
|
176
|
+
_emitEvent(event, cert) {
|
|
177
|
+
const blockletDomain = this._blockletDomains.find((x) => x.domain === cert.domain);
|
|
178
|
+
if (blockletDomain) {
|
|
179
|
+
this.emit(event.blocklet, { ...cert, meta: { did: blockletDomain.did } });
|
|
180
|
+
} else {
|
|
181
|
+
this.emit(event.server, cert);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
_onCertIssued(cert) {
|
|
186
|
+
this._emitEvent({ blocklet: BlockletEvents.certIssued, server: EVENTS.CERT_ISSUED }, cert);
|
|
187
|
+
|
|
188
|
+
onCertIssued(cert, this.states);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
_onCertError(cert) {
|
|
192
|
+
this._emitEvent({ blocklet: BlockletEvents.certError, server: EVENTS.CERT_ERROR }, cert);
|
|
193
|
+
|
|
194
|
+
onCertIssueFailed(cert, this.states);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
_onCertExpired(cert) {
|
|
198
|
+
onCertExpired(cert, this.states);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
_onCertAboutToExpire(cert) {
|
|
202
|
+
onCertAboutExpire(cert, this.states);
|
|
203
|
+
}
|
|
150
204
|
}
|
|
151
205
|
|
|
152
206
|
module.exports = Cert;
|
package/lib/event.js
CHANGED
|
@@ -332,6 +332,8 @@ module.exports = ({
|
|
|
332
332
|
|
|
333
333
|
listen(certManager, EVENTS.CERT_ISSUED, onEvent);
|
|
334
334
|
listen(certManager, EVENTS.CERT_ERROR, onEvent);
|
|
335
|
+
listen(certManager, BlockletEvents.certIssued, onEvent);
|
|
336
|
+
listen(certManager, BlockletEvents.certError, onEvent);
|
|
335
337
|
|
|
336
338
|
listen(routerManager, BlockletEvents.updated, onEvent);
|
|
337
339
|
|
package/lib/index.js
CHANGED
package/lib/router/helper.js
CHANGED
|
@@ -34,6 +34,7 @@ const {
|
|
|
34
34
|
WELLKNOWN_DID_RESOLVER_PREFIX,
|
|
35
35
|
WELLKNOWN_PING_PREFIX,
|
|
36
36
|
LOG_RETAIN_IN_DAYS,
|
|
37
|
+
EVENTS,
|
|
37
38
|
} = require('@abtnode/constant');
|
|
38
39
|
const {
|
|
39
40
|
BLOCKLET_DYNAMIC_PATH_PREFIX,
|
|
@@ -689,6 +690,21 @@ module.exports = function getRouterHelpers({ dataDirs, routingSnapshot, routerMa
|
|
|
689
690
|
};
|
|
690
691
|
|
|
691
692
|
const existSite = await states.site.findOne({ domain: domainGroup });
|
|
693
|
+
const { wallet } = getBlockletInfo(blocklet, nodeInfo.sk);
|
|
694
|
+
updateBlockletDocument({
|
|
695
|
+
wallet,
|
|
696
|
+
blockletAppDid: blocklet.appDid,
|
|
697
|
+
daemonDidDomain: getServerDidDomain(nodeInfo),
|
|
698
|
+
didRegistryUrl: nodeInfo.didRegistry,
|
|
699
|
+
domain: nodeInfo.didDomain,
|
|
700
|
+
})
|
|
701
|
+
.then(() => {
|
|
702
|
+
logger.info(`updated blocklet ${blocklet.appDid} dns`);
|
|
703
|
+
})
|
|
704
|
+
.catch((err) => {
|
|
705
|
+
logger.error(`update blocklet ${blocklet.appDid} dns failed`, { error: err });
|
|
706
|
+
});
|
|
707
|
+
|
|
692
708
|
if (!existSite) {
|
|
693
709
|
const domainAliases = [];
|
|
694
710
|
|
|
@@ -697,21 +713,6 @@ module.exports = function getRouterHelpers({ dataDirs, routingSnapshot, routerMa
|
|
|
697
713
|
didDomain: nodeInfo.didDomain,
|
|
698
714
|
});
|
|
699
715
|
|
|
700
|
-
const { wallet } = getBlockletInfo(blocklet, nodeInfo.sk);
|
|
701
|
-
updateBlockletDocument({
|
|
702
|
-
wallet,
|
|
703
|
-
blockletAppDid: blocklet.appDid,
|
|
704
|
-
daemonDidDomain: getServerDidDomain(nodeInfo),
|
|
705
|
-
didRegistryUrl: nodeInfo.didRegistry,
|
|
706
|
-
domain: nodeInfo.didDomain,
|
|
707
|
-
})
|
|
708
|
-
.then(() => {
|
|
709
|
-
logger.info(`updated blocklet ${blocklet.appDid} dns`);
|
|
710
|
-
})
|
|
711
|
-
.catch((err) => {
|
|
712
|
-
logger.error(`update blocklet ${blocklet.appDid} dns failed`, { error: err });
|
|
713
|
-
});
|
|
714
|
-
|
|
715
716
|
const ipEchoDnsDomain = getIpDnsDomainForBlocklet(blocklet, webInterface, nodeInfo.did);
|
|
716
717
|
|
|
717
718
|
// let didDomain in front of ipEchoDnsDomain
|
|
@@ -1038,10 +1039,10 @@ module.exports = function getRouterHelpers({ dataDirs, routingSnapshot, routerMa
|
|
|
1038
1039
|
},
|
|
1039
1040
|
});
|
|
1040
1041
|
|
|
1041
|
-
certManager.on(
|
|
1042
|
-
certManager.on(
|
|
1043
|
-
certManager.on(
|
|
1044
|
-
certManager.on(
|
|
1042
|
+
certManager.on(EVENTS.CERT_ADDED, () => providers[providerName].reload());
|
|
1043
|
+
certManager.on(EVENTS.CERT_REMOVED, () => providers[providerName].reload());
|
|
1044
|
+
certManager.on(EVENTS.CERT_ISSUED, () => providers[providerName].reload());
|
|
1045
|
+
certManager.on(EVENTS.CERT_UPDATED, () => providers[providerName].reload());
|
|
1045
1046
|
|
|
1046
1047
|
await providers[providerName].start();
|
|
1047
1048
|
}
|
|
@@ -1248,6 +1249,7 @@ module.exports = function getRouterHelpers({ dataDirs, routingSnapshot, routerMa
|
|
|
1248
1249
|
const addRoutingRule = _proxyToRouterManager('addRoutingRule');
|
|
1249
1250
|
const updateRoutingRule = _proxyToRouterManager('updateRoutingRule');
|
|
1250
1251
|
const deleteRoutingRule = _proxyToRouterManager('deleteRoutingRule');
|
|
1252
|
+
// FIXME: should verify domain owner before added
|
|
1251
1253
|
const addDomainAlias = _proxyToRouterManager('addDomainAlias');
|
|
1252
1254
|
const deleteDomainAlias = _proxyToRouterManager('deleteDomainAlias');
|
|
1253
1255
|
|
package/lib/util/blocklet.js
CHANGED
|
@@ -1459,7 +1459,7 @@ const ensureEnvDefault = (environments, ancestors) => {
|
|
|
1459
1459
|
const fromProperty2Config = (properties = {}, result) => {
|
|
1460
1460
|
Object.keys(properties).forEach((key) => {
|
|
1461
1461
|
const prop = properties[key];
|
|
1462
|
-
if (prop.properties) {
|
|
1462
|
+
if (prop.properties && ['ArrayTable', 'ArrayCards'].includes(prop['x-component']) === false) {
|
|
1463
1463
|
fromProperty2Config(prop.properties, result);
|
|
1464
1464
|
} else if (prop['x-decorator'] === 'FormItem') {
|
|
1465
1465
|
const secure = prop['x-component'] === 'Password';
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.8.63-beta-
|
|
6
|
+
"version": "1.8.63-beta-a36b5e1a",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -19,18 +19,18 @@
|
|
|
19
19
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@abtnode/auth": "1.8.63-beta-
|
|
23
|
-
"@abtnode/certificate-manager": "1.8.63-beta-
|
|
24
|
-
"@abtnode/constant": "1.8.63-beta-
|
|
25
|
-
"@abtnode/cron": "1.8.63-beta-
|
|
26
|
-
"@abtnode/db": "1.8.63-beta-
|
|
27
|
-
"@abtnode/logger": "1.8.63-beta-
|
|
28
|
-
"@abtnode/queue": "1.8.63-beta-
|
|
29
|
-
"@abtnode/rbac": "1.8.63-beta-
|
|
30
|
-
"@abtnode/router-provider": "1.8.63-beta-
|
|
31
|
-
"@abtnode/static-server": "1.8.63-beta-
|
|
32
|
-
"@abtnode/timemachine": "1.8.63-beta-
|
|
33
|
-
"@abtnode/util": "1.8.63-beta-
|
|
22
|
+
"@abtnode/auth": "1.8.63-beta-a36b5e1a",
|
|
23
|
+
"@abtnode/certificate-manager": "1.8.63-beta-a36b5e1a",
|
|
24
|
+
"@abtnode/constant": "1.8.63-beta-a36b5e1a",
|
|
25
|
+
"@abtnode/cron": "1.8.63-beta-a36b5e1a",
|
|
26
|
+
"@abtnode/db": "1.8.63-beta-a36b5e1a",
|
|
27
|
+
"@abtnode/logger": "1.8.63-beta-a36b5e1a",
|
|
28
|
+
"@abtnode/queue": "1.8.63-beta-a36b5e1a",
|
|
29
|
+
"@abtnode/rbac": "1.8.63-beta-a36b5e1a",
|
|
30
|
+
"@abtnode/router-provider": "1.8.63-beta-a36b5e1a",
|
|
31
|
+
"@abtnode/static-server": "1.8.63-beta-a36b5e1a",
|
|
32
|
+
"@abtnode/timemachine": "1.8.63-beta-a36b5e1a",
|
|
33
|
+
"@abtnode/util": "1.8.63-beta-a36b5e1a",
|
|
34
34
|
"@arcblock/did": "1.18.36",
|
|
35
35
|
"@arcblock/did-motif": "^1.1.10",
|
|
36
36
|
"@arcblock/did-util": "1.18.36",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"@arcblock/jwt": "^1.18.36",
|
|
39
39
|
"@arcblock/pm2-events": "^0.0.5",
|
|
40
40
|
"@arcblock/vc": "1.18.36",
|
|
41
|
-
"@blocklet/constant": "1.8.63-beta-
|
|
42
|
-
"@blocklet/meta": "1.8.63-beta-
|
|
43
|
-
"@blocklet/sdk": "1.8.63-beta-
|
|
41
|
+
"@blocklet/constant": "1.8.63-beta-a36b5e1a",
|
|
42
|
+
"@blocklet/meta": "1.8.63-beta-a36b5e1a",
|
|
43
|
+
"@blocklet/sdk": "1.8.63-beta-a36b5e1a",
|
|
44
44
|
"@fidm/x509": "^1.2.1",
|
|
45
45
|
"@ocap/mcrypto": "1.18.36",
|
|
46
46
|
"@ocap/util": "1.18.36",
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"express": "^4.18.2",
|
|
86
86
|
"jest": "^27.5.1"
|
|
87
87
|
},
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "0c5385668fbd6235a3aead7d3a4a1ca5159088dd"
|
|
89
89
|
}
|