@abtnode/core 1.16.13 → 1.16.14-beta-0c29907f
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 +5 -3
- package/lib/blocklet/manager/disk.js +301 -126
- package/lib/blocklet/manager/helper/install-application-from-backup.js +7 -6
- package/lib/blocklet/manager/helper/install-application-from-general.js +5 -5
- package/lib/blocklet/manager/helper/install-component-from-upload.js +3 -1
- package/lib/blocklet/manager/helper/install-component-from-url.js +22 -5
- package/lib/blocklet/manager/helper/upgrade-components.js +21 -6
- package/lib/event.js +32 -32
- package/lib/index.js +4 -0
- package/lib/states/audit-log.js +64 -70
- package/lib/states/blocklet.js +1 -0
- package/lib/states/notification.js +2 -2
- package/lib/util/blocklet.js +11 -0
- package/lib/util/get-accessible-external-node-ip.js +2 -2
- package/lib/util/get-domain-for-blocklet.js +2 -2
- package/lib/util/launcher.js +11 -5
- package/lib/util/store.js +7 -7
- package/lib/webhook/index.js +25 -14
- package/package.json +32 -32
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const joinUrl = require('url-join');
|
|
2
2
|
const axios = require('@abtnode/util/lib/axios');
|
|
3
|
-
const { DEFAULT_IP_DOMAIN,
|
|
3
|
+
const { DEFAULT_IP_DOMAIN, WELLKNOWN_SERVER_ADMIN_PATH } = require('@abtnode/constant');
|
|
4
4
|
const logger = require('@abtnode/logger')('@abtnode/core:util:get-accessible-external-node-ip');
|
|
5
5
|
const { get: getIp } = require('./ip');
|
|
6
6
|
|
|
@@ -13,7 +13,7 @@ const timeout = process.env.NODE_ENV === 'test' ? 500 : 5000;
|
|
|
13
13
|
// check if node dashboard https endpoint return 2xx
|
|
14
14
|
// FIXME: check connected by wellknown endpoint
|
|
15
15
|
const checkConnected = async ({ ip, nodeInfo }) => {
|
|
16
|
-
const { adminPath =
|
|
16
|
+
const { adminPath = WELLKNOWN_SERVER_ADMIN_PATH } = nodeInfo.routing || {};
|
|
17
17
|
const origin = `https://${getNodeDomain(ip)}`;
|
|
18
18
|
const endpoint = joinUrl(origin, adminPath);
|
|
19
19
|
await axios.get(endpoint, { timeout });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { DEFAULT_IP_DOMAIN_SUFFIX, SLOT_FOR_IP_DNS_SITE } = require('@abtnode/constant');
|
|
1
|
+
const { DEFAULT_IP_DOMAIN_SUFFIX, SLOT_FOR_IP_DNS_SITE, DEFAULT_DID_DOMAIN } = require('@abtnode/constant');
|
|
2
2
|
const { encode: encodeBase32 } = require('@abtnode/util/lib/base32');
|
|
3
3
|
const formatName = require('@abtnode/util/lib/format-name');
|
|
4
4
|
|
|
@@ -7,7 +7,7 @@ const getIpDnsDomainForBlocklet = (blocklet) => {
|
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
const getDidDomainForBlocklet = ({ appPid, didDomain }) => {
|
|
10
|
-
return `${encodeBase32(appPid)}.${didDomain}`;
|
|
10
|
+
return `${encodeBase32(appPid)}.${didDomain || DEFAULT_DID_DOMAIN}`;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
module.exports = { getIpDnsDomainForBlocklet, getDidDomainForBlocklet, formatName };
|
package/lib/util/launcher.js
CHANGED
|
@@ -2,8 +2,13 @@ const path = require('path');
|
|
|
2
2
|
const fs = require('fs-extra');
|
|
3
3
|
const joinUrl = require('url-join');
|
|
4
4
|
const pick = require('lodash/pick');
|
|
5
|
-
const
|
|
6
|
-
|
|
5
|
+
const {
|
|
6
|
+
getUserAvatarUrl,
|
|
7
|
+
extractUserAvatar,
|
|
8
|
+
getAvatarFile,
|
|
9
|
+
getAvatarByUrl,
|
|
10
|
+
getAppAvatarUrl,
|
|
11
|
+
} = require('@abtnode/util/lib/user');
|
|
7
12
|
const { Hasher } = require('@ocap/mcrypto');
|
|
8
13
|
const { getDisplayName } = require('@blocklet/meta/lib/util');
|
|
9
14
|
const getBlockletInfo = require('@blocklet/meta/lib/info');
|
|
@@ -99,7 +104,7 @@ const setupAppOwner = async (node, sessionId) => {
|
|
|
99
104
|
throw new Error(`Owner user not found from launcher: ${launcherUrl}`);
|
|
100
105
|
}
|
|
101
106
|
appOwnerProfile = pick(user, ['fullName', 'email', 'avatar']);
|
|
102
|
-
const avatarBase64 = await getAvatarByUrl(
|
|
107
|
+
const avatarBase64 = await getAvatarByUrl(joinUrl(launcherUrl, user.avatar));
|
|
103
108
|
appOwnerProfile.avatar = await extractUserAvatar(avatarBase64, { dataDir });
|
|
104
109
|
logger.info('Create owner from launcher for blocklet', { appDid, ownerDid, ownerPk, sessionId, appOwnerProfile });
|
|
105
110
|
} else {
|
|
@@ -115,7 +120,7 @@ const setupAppOwner = async (node, sessionId) => {
|
|
|
115
120
|
fs.mkdirpSync(path.dirname(destFile));
|
|
116
121
|
fs.copyFileSync(srcFile, destFile);
|
|
117
122
|
} else {
|
|
118
|
-
appOwnerProfile.avatar = extractUserAvatar(user.avatar, { dataDir });
|
|
123
|
+
appOwnerProfile.avatar = await extractUserAvatar(user.avatar, { dataDir });
|
|
119
124
|
}
|
|
120
125
|
logger.info('Create owner from session for blocklet', { appDid, ownerDid, ownerPk, sessionId, appOwnerProfile });
|
|
121
126
|
}
|
|
@@ -125,6 +130,7 @@ const setupAppOwner = async (node, sessionId) => {
|
|
|
125
130
|
const vc = createPassportVC({
|
|
126
131
|
issuerName: getDisplayName(blocklet),
|
|
127
132
|
issuerWallet: wallet,
|
|
133
|
+
issuerAvatarUrl: getAppAvatarUrl(appUrl),
|
|
128
134
|
ownerDid,
|
|
129
135
|
passport: await createPassport({
|
|
130
136
|
name: role,
|
|
@@ -138,7 +144,7 @@ const setupAppOwner = async (node, sessionId) => {
|
|
|
138
144
|
userDid: ownerDid,
|
|
139
145
|
teamDid: appDid,
|
|
140
146
|
}),
|
|
141
|
-
ownerProfile: { ...appOwnerProfile, avatar:
|
|
147
|
+
ownerProfile: { ...appOwnerProfile, avatar: getUserAvatarUrl(appUrl, appOwnerProfile.avatar) },
|
|
142
148
|
preferredColor: 'default',
|
|
143
149
|
expirationDate: undefined,
|
|
144
150
|
});
|
package/lib/util/store.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const joinUrl = require('url-join');
|
|
2
2
|
const pick = require('lodash/pick');
|
|
3
3
|
const isBase64 = require('is-base64');
|
|
4
4
|
|
|
@@ -47,7 +47,7 @@ const fixAndVerifyMetaFromStore = (meta) => {
|
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
const validateStoreUrl = async (registry) => {
|
|
50
|
-
const url =
|
|
50
|
+
const url = joinUrl(registry, BLOCKLET_STORE_API_PREFIX, `/blocklets.json?__t__=${Date.now()}`);
|
|
51
51
|
try {
|
|
52
52
|
const res = await request.get(url);
|
|
53
53
|
if (Array.isArray(res.data)) {
|
|
@@ -64,7 +64,7 @@ const validateStoreUrl = async (registry) => {
|
|
|
64
64
|
|
|
65
65
|
const getStoreMeta = async (registry) => {
|
|
66
66
|
try {
|
|
67
|
-
const url =
|
|
67
|
+
const url = joinUrl(registry, BLOCKLET_STORE_META_PATH, `?__t__=${Date.now()}`);
|
|
68
68
|
const { data } = await request.get(url);
|
|
69
69
|
|
|
70
70
|
if (!data) {
|
|
@@ -86,7 +86,7 @@ const getStoreMeta = async (registry) => {
|
|
|
86
86
|
} else if (isBase64(logoUrl, { allowMime: true })) {
|
|
87
87
|
result.logoUrl = logoUrl;
|
|
88
88
|
} else {
|
|
89
|
-
result.logoUrl =
|
|
89
|
+
result.logoUrl = joinUrl(registry, logoUrl);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
@@ -141,14 +141,14 @@ const resolveTarballURL = ({ did, tarball = '', storeUrl = '' }) => {
|
|
|
141
141
|
return '';
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
return
|
|
144
|
+
return joinUrl(storeUrl, 'api', 'blocklets', did, tarball);
|
|
145
145
|
};
|
|
146
146
|
|
|
147
147
|
const getBlockletMetaUrl = ({ did, storeUrl }) =>
|
|
148
|
-
|
|
148
|
+
joinUrl(storeUrl, BLOCKLET_STORE_API_PREFIX, `/blocklets/${did}/blocklet.json`);
|
|
149
149
|
|
|
150
150
|
const getBlockletMeta = async ({ did, storeUrl }) => {
|
|
151
|
-
const url =
|
|
151
|
+
const url = joinUrl(storeUrl, BLOCKLET_STORE_API_PREFIX, `/blocklets/${did}/blocklet.json?__t__=${Date.now()}`);
|
|
152
152
|
|
|
153
153
|
const { data } = await request.get(url);
|
|
154
154
|
try {
|
package/lib/webhook/index.js
CHANGED
|
@@ -10,10 +10,18 @@ const IP = require('../util/ip');
|
|
|
10
10
|
const states = require('../states');
|
|
11
11
|
const { getBaseUrls } = require('../util');
|
|
12
12
|
|
|
13
|
-
const getSlackUrlInfo = async (actionPath = '/notifications', urls) => {
|
|
13
|
+
const getSlackUrlInfo = async ({ blockletUrl, path: actionPath = '/notifications', serverUrls: urls }) => {
|
|
14
14
|
const info = [];
|
|
15
15
|
|
|
16
|
-
if (
|
|
16
|
+
if (blockletUrl) {
|
|
17
|
+
info.push({
|
|
18
|
+
type: 'section',
|
|
19
|
+
text: {
|
|
20
|
+
type: 'mrkdwn',
|
|
21
|
+
text: 'Use the following links to visit your Blocklet dashboard:',
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
} else if (actionPath && actionPath.startsWith('/blocklet/')) {
|
|
17
25
|
info.push({
|
|
18
26
|
type: 'section',
|
|
19
27
|
text: {
|
|
@@ -31,15 +39,18 @@ const getSlackUrlInfo = async (actionPath = '/notifications', urls) => {
|
|
|
31
39
|
});
|
|
32
40
|
}
|
|
33
41
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
let url = blockletUrl;
|
|
43
|
+
if (!url) {
|
|
44
|
+
const priorities = await evaluateURLs(
|
|
45
|
+
urls.map((item) => item.url),
|
|
46
|
+
{ checkAccessible: checkURLAccessible }
|
|
47
|
+
);
|
|
48
|
+
const priorityUrl = priorities[0].url;
|
|
49
|
+
|
|
50
|
+
const { protocol } = new URL(priorityUrl);
|
|
51
|
+
const normalized = `${priorityUrl}${actionPath}`.replace(`${protocol}//`, '').replace(/\/+/g, '/');
|
|
52
|
+
url = `${protocol}//${normalized}`;
|
|
53
|
+
}
|
|
43
54
|
|
|
44
55
|
info.push({
|
|
45
56
|
type: 'actions',
|
|
@@ -89,7 +100,7 @@ module.exports = ({ events, dataDirs, instance }) => {
|
|
|
89
100
|
const options = { ...message, nodeInfo, node: instance };
|
|
90
101
|
if (item.type === 'slack') {
|
|
91
102
|
// eslint-disable-next-line
|
|
92
|
-
options.urlInfo = await getSlackUrlInfo(message.action, baseUrls);
|
|
103
|
+
options.urlInfo = await getSlackUrlInfo({ blockletUrl: message.blockletUrl, path: message.action, serverUrls: baseUrls });
|
|
93
104
|
}
|
|
94
105
|
try {
|
|
95
106
|
// eslint-disable-next-line
|
|
@@ -118,8 +129,8 @@ module.exports = ({ events, dataDirs, instance }) => {
|
|
|
118
129
|
});
|
|
119
130
|
|
|
120
131
|
events.on(EVENTS.NOTIFICATION_CREATE, (data) => {
|
|
121
|
-
const { title, description, severity, action, entityType } = data;
|
|
122
|
-
queue.push({ title, description, status: severity, action, entityType });
|
|
132
|
+
const { title, description, severity, action, entityType, blockletUrl } = data;
|
|
133
|
+
queue.push({ title, description, status: severity, action, entityType, blockletUrl });
|
|
123
134
|
});
|
|
124
135
|
|
|
125
136
|
events.on(EVENTS.NODE_STARTED, async (message) => {
|
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.14-beta-0c29907f",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -19,38 +19,38 @@
|
|
|
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.
|
|
23
|
-
"@abtnode/auth": "1.16.
|
|
24
|
-
"@abtnode/certificate-manager": "1.16.
|
|
25
|
-
"@abtnode/constant": "1.16.
|
|
26
|
-
"@abtnode/cron": "1.16.
|
|
27
|
-
"@abtnode/logger": "1.16.
|
|
28
|
-
"@abtnode/models": "1.16.
|
|
29
|
-
"@abtnode/queue": "1.16.
|
|
30
|
-
"@abtnode/rbac": "1.16.
|
|
31
|
-
"@abtnode/router-provider": "1.16.
|
|
32
|
-
"@abtnode/static-server": "1.16.
|
|
33
|
-
"@abtnode/timemachine": "1.16.
|
|
34
|
-
"@abtnode/util": "1.16.
|
|
35
|
-
"@arcblock/did": "1.18.
|
|
36
|
-
"@arcblock/did-auth": "1.18.
|
|
37
|
-
"@arcblock/did-ext": "^1.18.
|
|
38
|
-
"@arcblock/did-motif": "^1.1.
|
|
39
|
-
"@arcblock/did-util": "1.18.
|
|
40
|
-
"@arcblock/event-hub": "1.18.
|
|
41
|
-
"@arcblock/jwt": "^1.18.
|
|
22
|
+
"@abtnode/analytics": "1.16.14-beta-0c29907f",
|
|
23
|
+
"@abtnode/auth": "1.16.14-beta-0c29907f",
|
|
24
|
+
"@abtnode/certificate-manager": "1.16.14-beta-0c29907f",
|
|
25
|
+
"@abtnode/constant": "1.16.14-beta-0c29907f",
|
|
26
|
+
"@abtnode/cron": "1.16.14-beta-0c29907f",
|
|
27
|
+
"@abtnode/logger": "1.16.14-beta-0c29907f",
|
|
28
|
+
"@abtnode/models": "1.16.14-beta-0c29907f",
|
|
29
|
+
"@abtnode/queue": "1.16.14-beta-0c29907f",
|
|
30
|
+
"@abtnode/rbac": "1.16.14-beta-0c29907f",
|
|
31
|
+
"@abtnode/router-provider": "1.16.14-beta-0c29907f",
|
|
32
|
+
"@abtnode/static-server": "1.16.14-beta-0c29907f",
|
|
33
|
+
"@abtnode/timemachine": "1.16.14-beta-0c29907f",
|
|
34
|
+
"@abtnode/util": "1.16.14-beta-0c29907f",
|
|
35
|
+
"@arcblock/did": "1.18.87",
|
|
36
|
+
"@arcblock/did-auth": "1.18.87",
|
|
37
|
+
"@arcblock/did-ext": "^1.18.87",
|
|
38
|
+
"@arcblock/did-motif": "^1.1.13",
|
|
39
|
+
"@arcblock/did-util": "1.18.87",
|
|
40
|
+
"@arcblock/event-hub": "1.18.87",
|
|
41
|
+
"@arcblock/jwt": "^1.18.87",
|
|
42
42
|
"@arcblock/pm2-events": "^0.0.5",
|
|
43
|
-
"@arcblock/validator": "^1.18.
|
|
44
|
-
"@arcblock/vc": "1.18.
|
|
45
|
-
"@blocklet/constant": "1.16.
|
|
46
|
-
"@blocklet/meta": "1.16.
|
|
47
|
-
"@blocklet/resolver": "1.16.
|
|
48
|
-
"@blocklet/sdk": "1.16.
|
|
49
|
-
"@did-space/client": "^0.2.
|
|
43
|
+
"@arcblock/validator": "^1.18.87",
|
|
44
|
+
"@arcblock/vc": "1.18.87",
|
|
45
|
+
"@blocklet/constant": "1.16.14-beta-0c29907f",
|
|
46
|
+
"@blocklet/meta": "1.16.14-beta-0c29907f",
|
|
47
|
+
"@blocklet/resolver": "1.16.14-beta-0c29907f",
|
|
48
|
+
"@blocklet/sdk": "1.16.14-beta-0c29907f",
|
|
49
|
+
"@did-space/client": "^0.2.129",
|
|
50
50
|
"@fidm/x509": "^1.2.1",
|
|
51
|
-
"@ocap/mcrypto": "1.18.
|
|
52
|
-
"@ocap/util": "1.18.
|
|
53
|
-
"@ocap/wallet": "1.18.
|
|
51
|
+
"@ocap/mcrypto": "1.18.87",
|
|
52
|
+
"@ocap/util": "1.18.87",
|
|
53
|
+
"@ocap/wallet": "1.18.87",
|
|
54
54
|
"@slack/webhook": "^5.0.4",
|
|
55
55
|
"archiver": "^5.3.1",
|
|
56
56
|
"axios": "^0.27.2",
|
|
@@ -96,5 +96,5 @@
|
|
|
96
96
|
"express": "^4.18.2",
|
|
97
97
|
"jest": "^27.5.1"
|
|
98
98
|
},
|
|
99
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "1f02851a71861dbf09bfedfa9df6d9fc6d2355a3"
|
|
100
100
|
}
|