@abtnode/core 1.6.21 → 1.6.22
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.
|
@@ -2,13 +2,18 @@ const yaml = require('js-yaml');
|
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const set = require('lodash/set');
|
|
4
4
|
const omit = require('lodash/omit');
|
|
5
|
-
const {
|
|
5
|
+
const {
|
|
6
|
+
DEFAULT_WILDCARD_CERT_HOST,
|
|
7
|
+
DEFAULT_DID_DOMAIN,
|
|
8
|
+
DEFAULT_DID_REGISTRY,
|
|
9
|
+
DEFAULT_IP_DOMAIN,
|
|
10
|
+
} = require('@abtnode/constant');
|
|
6
11
|
|
|
7
12
|
module.exports = async ({ states, printInfo, configFile }) => {
|
|
8
13
|
printInfo('Try to rename dashboardDomain to ipWildcardDomain in db...');
|
|
9
14
|
|
|
10
15
|
let info = await states.node.read();
|
|
11
|
-
set(info, 'routing.ipWildcardDomain', info.routing.dashboardDomain);
|
|
16
|
+
set(info, 'routing.ipWildcardDomain', info.routing.dashboardDomain || DEFAULT_IP_DOMAIN);
|
|
12
17
|
set(info, 'routing.wildcardCertHost', DEFAULT_WILDCARD_CERT_HOST);
|
|
13
18
|
set(info, 'didDomain', DEFAULT_DID_DOMAIN);
|
|
14
19
|
set(info, 'didRegistry', DEFAULT_DID_REGISTRY);
|
|
@@ -16,12 +21,15 @@ module.exports = async ({ states, printInfo, configFile }) => {
|
|
|
16
21
|
|
|
17
22
|
await states.node.updateNodeInfo(info);
|
|
18
23
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
if (process.env.NODE_ENV !== 'development') {
|
|
25
|
+
let rawConfig = yaml.safeLoad(fs.readFileSync(configFile).toString());
|
|
26
|
+
set(rawConfig, 'node.routing.ipWildcardDomain', info.routing.ipWildcardDomain);
|
|
27
|
+
set(rawConfig, 'node.routing.wildcardCertHost', DEFAULT_WILDCARD_CERT_HOST);
|
|
28
|
+
set(rawConfig, 'node.didDomain', DEFAULT_DID_DOMAIN);
|
|
29
|
+
set(rawConfig, 'node.didRegistry', DEFAULT_DID_REGISTRY);
|
|
30
|
+
rawConfig = omit(rawConfig, 'node.routing.dashboardDomain');
|
|
31
|
+
fs.writeFileSync(configFile, yaml.dump(rawConfig));
|
|
32
|
+
}
|
|
33
|
+
|
|
26
34
|
printInfo(`> Persist new config to file: ${configFile}`);
|
|
27
35
|
};
|
package/lib/migrations/index.js
CHANGED
|
@@ -132,9 +132,13 @@ const runMigrationScripts = async ({
|
|
|
132
132
|
for (let i = 0; i < scripts.length; i++) {
|
|
133
133
|
const { script, version } = scripts[i];
|
|
134
134
|
try {
|
|
135
|
-
|
|
136
|
-
if (executed === false) {
|
|
135
|
+
if (process.env.NODE_ENV === 'development') {
|
|
137
136
|
pending.push(scripts[i]);
|
|
137
|
+
} else {
|
|
138
|
+
const executed = await node.isMigrationExecuted({ script, version });
|
|
139
|
+
if (executed === false) {
|
|
140
|
+
pending.push(scripts[i]);
|
|
141
|
+
}
|
|
138
142
|
}
|
|
139
143
|
} catch (err) {
|
|
140
144
|
printError(`Failed to detect migration script execution status: ${script}, error: ${err.message}`);
|
package/lib/router/helper.js
CHANGED
|
@@ -223,6 +223,19 @@ const ensureServiceRule = async (sites) => {
|
|
|
223
223
|
return site;
|
|
224
224
|
});
|
|
225
225
|
};
|
|
226
|
+
const ensureRootRule = async (sites) => {
|
|
227
|
+
return sites.map((site) => {
|
|
228
|
+
if (!isBasicSite(site.domain) && !site.rules.some((x) => x.from.pathPrefix === '/')) {
|
|
229
|
+
site.rules.push({
|
|
230
|
+
from: { pathPrefix: '/' },
|
|
231
|
+
to: {
|
|
232
|
+
type: ROUTING_RULE_TYPES.NONE,
|
|
233
|
+
},
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
return site;
|
|
237
|
+
});
|
|
238
|
+
};
|
|
226
239
|
|
|
227
240
|
const ensureLatestNodeInfo = async (sites = [], { withDefaultCors = true } = {}) => {
|
|
228
241
|
const info = await states.node.read();
|
|
@@ -1178,6 +1191,7 @@ module.exports = function getRouterHelpers({ dataDirs, routingSnapshot, routerMa
|
|
|
1178
1191
|
sites = await ensureLatestInfo(sites);
|
|
1179
1192
|
sites = await ensureAuthService(sites, blockletManager);
|
|
1180
1193
|
sites = await ensureServiceRule(sites);
|
|
1194
|
+
sites = await ensureRootRule(sites);
|
|
1181
1195
|
|
|
1182
1196
|
const certificates = httpsEnabled ? await certManager.getAllNormal() : [];
|
|
1183
1197
|
|
package/lib/router/index.js
CHANGED
|
@@ -5,7 +5,7 @@ const {
|
|
|
5
5
|
DOMAIN_FOR_DEFAULT_SITE,
|
|
6
6
|
DOMAIN_FOR_IP_SITE_REGEXP,
|
|
7
7
|
ROUTING_RULE_TYPES,
|
|
8
|
-
|
|
8
|
+
DEFAULT_IP_DOMAIN,
|
|
9
9
|
BLOCKLET_PROXY_PATH_PREFIX,
|
|
10
10
|
BLOCKLET_SITE_GROUP_SUFFIX,
|
|
11
11
|
} = require('@abtnode/constant');
|
|
@@ -219,7 +219,7 @@ Router.formatSites = (sites = []) => {
|
|
|
219
219
|
|
|
220
220
|
Router.flattenSitesToRules = (sites = [], info = {}) => {
|
|
221
221
|
const result = [];
|
|
222
|
-
const ipWildcardDomain = get(info, 'routing.ipWildcardDomain',
|
|
222
|
+
const ipWildcardDomain = get(info, 'routing.ipWildcardDomain', DEFAULT_IP_DOMAIN);
|
|
223
223
|
sites.forEach((site) => {
|
|
224
224
|
const aliases = (site.domainAliases || [])
|
|
225
225
|
.map((x) => (typeof x === 'string' ? x : x.value))
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const joinUrl = require('url-join');
|
|
2
2
|
const axios = require('@abtnode/util/lib/axios');
|
|
3
|
-
const {
|
|
3
|
+
const { DEFAULT_IP_DOMAIN, DEFAULT_ADMIN_PATH } = require('@abtnode/constant');
|
|
4
4
|
const { get: getIp } = require('./ip');
|
|
5
5
|
|
|
6
|
-
const getNodeDomain = (ip) => (ip ?
|
|
6
|
+
const getNodeDomain = (ip) => (ip ? DEFAULT_IP_DOMAIN.replace(/^\*/, ip.replace(/\./g, '-')) : '');
|
|
7
7
|
|
|
8
8
|
let cache = null;
|
|
9
9
|
|
package/lib/webhook/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
const logger = require('@abtnode/logger')('@abtnode/core:webhook:index');
|
|
2
|
-
const upperFirst = require('lodash/upperFirst');
|
|
3
2
|
|
|
3
|
+
const sortPriorityUrl = require('@abtnode/util/lib/sort-priority-url');
|
|
4
4
|
const WebHookSender = require('./sender');
|
|
5
5
|
const createQueue = require('../queue');
|
|
6
6
|
const IP = require('../util/ip');
|
|
7
7
|
const states = require('../states');
|
|
8
8
|
const { getBaseUrls } = require('../util');
|
|
9
9
|
|
|
10
|
-
const getSlackUrlInfo = (actionPath = '/notifications', urls) => {
|
|
10
|
+
const getSlackUrlInfo = async (actionPath = '/notifications', urls) => {
|
|
11
11
|
const info = [];
|
|
12
12
|
|
|
13
13
|
if (actionPath && actionPath.startsWith('/blocklet/')) {
|
|
@@ -28,29 +28,27 @@ const getSlackUrlInfo = (actionPath = '/notifications', urls) => {
|
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const normalized = `${x.url}${actionPath}`.replace(`${protocol}//`, '').replace(/\/+/g, '/');
|
|
39
|
-
const url = `${protocol}//${normalized}`;
|
|
40
|
-
elements.push({
|
|
41
|
-
type: 'button',
|
|
42
|
-
text: {
|
|
43
|
-
type: 'plain_text',
|
|
44
|
-
text: `${upperFirst(x.type)} Address`,
|
|
45
|
-
},
|
|
46
|
-
style: 'primary',
|
|
47
|
-
value: `${upperFirst(x.type)} Address`,
|
|
48
|
-
url,
|
|
49
|
-
});
|
|
50
|
-
});
|
|
31
|
+
const prioritys = await sortPriorityUrl(urls);
|
|
32
|
+
const priorityUrl = prioritys[0].url;
|
|
33
|
+
|
|
34
|
+
const { protocol } = new URL(priorityUrl);
|
|
35
|
+
const normalized = `${priorityUrl}${actionPath}`.replace(`${protocol}//`, '').replace(/\/+/g, '/');
|
|
36
|
+
const url = `${protocol}//${normalized}`;
|
|
37
|
+
|
|
51
38
|
info.push({
|
|
52
39
|
type: 'actions',
|
|
53
|
-
elements
|
|
40
|
+
elements: [
|
|
41
|
+
{
|
|
42
|
+
type: 'button',
|
|
43
|
+
text: {
|
|
44
|
+
type: 'plain_text',
|
|
45
|
+
text: 'Click Me',
|
|
46
|
+
},
|
|
47
|
+
style: 'primary',
|
|
48
|
+
value: 'Click Me',
|
|
49
|
+
url,
|
|
50
|
+
},
|
|
51
|
+
],
|
|
54
52
|
});
|
|
55
53
|
|
|
56
54
|
return info;
|
|
@@ -79,7 +77,8 @@ module.exports = ({ events, dataDirs, instance }) => {
|
|
|
79
77
|
const { name } = nodeInfo;
|
|
80
78
|
const options = { ...message, nodeInfo: `*${name}*` };
|
|
81
79
|
if (item.type === 'slack') {
|
|
82
|
-
|
|
80
|
+
// eslint-disable-next-line
|
|
81
|
+
options.urlInfo = await getSlackUrlInfo(message.action, baseUrls);
|
|
83
82
|
}
|
|
84
83
|
try {
|
|
85
84
|
// eslint-disable-next-line
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.6.
|
|
6
|
+
"version": "1.6.22",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -19,28 +19,28 @@
|
|
|
19
19
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@abtnode/certificate-manager": "1.6.
|
|
23
|
-
"@abtnode/constant": "1.6.
|
|
24
|
-
"@abtnode/cron": "1.6.
|
|
25
|
-
"@abtnode/db": "1.6.
|
|
26
|
-
"@abtnode/logger": "1.6.
|
|
27
|
-
"@abtnode/queue": "1.6.
|
|
28
|
-
"@abtnode/rbac": "1.6.
|
|
29
|
-
"@abtnode/router-provider": "1.6.
|
|
30
|
-
"@abtnode/static-server": "1.6.
|
|
31
|
-
"@abtnode/timemachine": "1.6.
|
|
32
|
-
"@abtnode/util": "1.6.
|
|
33
|
-
"@arcblock/did": "^1.14.
|
|
34
|
-
"@arcblock/event-hub": "1.14.
|
|
22
|
+
"@abtnode/certificate-manager": "1.6.22",
|
|
23
|
+
"@abtnode/constant": "1.6.22",
|
|
24
|
+
"@abtnode/cron": "1.6.22",
|
|
25
|
+
"@abtnode/db": "1.6.22",
|
|
26
|
+
"@abtnode/logger": "1.6.22",
|
|
27
|
+
"@abtnode/queue": "1.6.22",
|
|
28
|
+
"@abtnode/rbac": "1.6.22",
|
|
29
|
+
"@abtnode/router-provider": "1.6.22",
|
|
30
|
+
"@abtnode/static-server": "1.6.22",
|
|
31
|
+
"@abtnode/timemachine": "1.6.22",
|
|
32
|
+
"@abtnode/util": "1.6.22",
|
|
33
|
+
"@arcblock/did": "^1.14.16",
|
|
34
|
+
"@arcblock/event-hub": "1.14.16",
|
|
35
35
|
"@arcblock/pm2-events": "^0.0.5",
|
|
36
|
-
"@arcblock/vc": "^1.14.
|
|
37
|
-
"@blocklet/meta": "1.6.
|
|
36
|
+
"@arcblock/vc": "^1.14.16",
|
|
37
|
+
"@blocklet/meta": "1.6.22",
|
|
38
38
|
"@fidm/x509": "^1.2.1",
|
|
39
39
|
"@nedb/core": "^1.2.2",
|
|
40
40
|
"@nedb/multi": "^1.2.2",
|
|
41
|
-
"@ocap/mcrypto": "^1.14.
|
|
42
|
-
"@ocap/util": "^1.14.
|
|
43
|
-
"@ocap/wallet": "^1.14.
|
|
41
|
+
"@ocap/mcrypto": "^1.14.16",
|
|
42
|
+
"@ocap/util": "^1.14.16",
|
|
43
|
+
"@ocap/wallet": "^1.14.16",
|
|
44
44
|
"@slack/webhook": "^5.0.3",
|
|
45
45
|
"axios": "^0.25.0",
|
|
46
46
|
"axon": "^2.0.3",
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"express": "^4.17.1",
|
|
76
76
|
"jest": "^27.4.5"
|
|
77
77
|
},
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "18ac52a439dbd04e4ace98d796b6de517503fb14"
|
|
79
79
|
}
|