@abtnode/blocklet-services 1.16.13-beta-0656f92f → 1.16.13-beta-2eb54cbc
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/api/index.js +15 -11
- package/api/libs/jwt.js +2 -1
- package/api/routes/blocklet.js +6 -1
- package/api/services/studio/index.js +26 -1
- package/api/util/attach-shared-utils.js +0 -1
- package/api/util/index.js +15 -8
- package/build/asset-manifest.json +15 -15
- package/build/index.html +1 -1
- package/build/service-worker.js +1 -1
- package/build/static/css/{125.1bbe7d61.chunk.css → 557.9597837e.chunk.css} +1 -1
- package/build/static/js/{189.602863fd.chunk.js → 189.971a999d.chunk.js} +3 -3
- package/build/static/js/{189.602863fd.chunk.js.LICENSE.txt → 189.971a999d.chunk.js.LICENSE.txt} +4 -0
- package/build/static/js/557.ae37498c.chunk.js +3 -0
- package/build/static/js/737.3e7feae2.chunk.js +2 -0
- package/build/static/js/846.bf982abb.chunk.js +2 -0
- package/build/static/js/{868.30686f6c.chunk.js → 868.cd5abe55.chunk.js} +2 -2
- package/build/static/js/main.1a83f798.js +3 -0
- package/build/static/js/{main.8df96c85.js.LICENSE.txt → main.1a83f798.js.LICENSE.txt} +0 -4
- package/package.json +24 -24
- package/build/static/js/125.910ae6fb.chunk.js +0 -3
- package/build/static/js/343.89b6cdac.chunk.js +0 -2
- package/build/static/js/737.1f59e1c3.chunk.js +0 -2
- package/build/static/js/main.8df96c85.js +0 -3
- /package/build/static/js/{125.910ae6fb.chunk.js.LICENSE.txt → 557.ae37498c.chunk.js.LICENSE.txt} +0 -0
package/api/index.js
CHANGED
|
@@ -8,7 +8,7 @@ const compression = require('compression');
|
|
|
8
8
|
const cookieParser = require('cookie-parser');
|
|
9
9
|
const bodyParser = require('body-parser');
|
|
10
10
|
const httpProxy = require('@arcblock/http-proxy');
|
|
11
|
-
const dayjs = require('dayjs');
|
|
11
|
+
const dayjs = require('@abtnode/util/lib/dayjs');
|
|
12
12
|
const minimatch = require('minimatch');
|
|
13
13
|
|
|
14
14
|
const { getAccessLogStream } = require('@abtnode/logger');
|
|
@@ -224,7 +224,7 @@ module.exports = function createServer(node, serverOptions = {}) {
|
|
|
224
224
|
StaticService.attachStaticResources({ app: server, proxy });
|
|
225
225
|
|
|
226
226
|
// Studio service
|
|
227
|
-
StudioService.init({ app: server });
|
|
227
|
+
StudioService.init({ app: server, node });
|
|
228
228
|
|
|
229
229
|
// API: notification
|
|
230
230
|
notificationService.sendToUser.attach(server);
|
|
@@ -291,15 +291,19 @@ module.exports = function createServer(node, serverOptions = {}) {
|
|
|
291
291
|
});
|
|
292
292
|
|
|
293
293
|
// After all service middleware, we can now safely pass all traffic to blocklets
|
|
294
|
-
server.use(async (req, res
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
294
|
+
server.use(async (req, res) => {
|
|
295
|
+
try {
|
|
296
|
+
const { target } = await ensureProxyUrl(req);
|
|
297
|
+
if (target) {
|
|
298
|
+
proxy.safeWeb(req, res, {
|
|
299
|
+
target,
|
|
300
|
+
});
|
|
301
|
+
} else {
|
|
302
|
+
throw new Error('empty proxy target');
|
|
303
|
+
}
|
|
304
|
+
} catch (err) {
|
|
305
|
+
logger.error('Failed to get component target', { url: req.url, error: err });
|
|
306
|
+
res.status(500).send(`Blocklet Service: failed to get component target: ${err.message}`);
|
|
303
307
|
}
|
|
304
308
|
});
|
|
305
309
|
|
package/api/libs/jwt.js
CHANGED
|
@@ -15,7 +15,7 @@ const initJwt = (node, options) => {
|
|
|
15
15
|
// 保持默认有效期为 1 天
|
|
16
16
|
const ttl = options.sessionTtl || '1d';
|
|
17
17
|
|
|
18
|
-
const createSessionToken = (did, { role, secret, passport, expiresIn, tokenType }) =>
|
|
18
|
+
const createSessionToken = (did, { role, secret, passport, expiresIn, tokenType, fullName }) =>
|
|
19
19
|
createAuthToken({
|
|
20
20
|
did,
|
|
21
21
|
passport,
|
|
@@ -23,6 +23,7 @@ const initJwt = (node, options) => {
|
|
|
23
23
|
secret,
|
|
24
24
|
expiresIn: expiresIn || ttl,
|
|
25
25
|
tokenType,
|
|
26
|
+
fullName,
|
|
26
27
|
});
|
|
27
28
|
|
|
28
29
|
const verifySessionToken = (token, secret, { checkFromDb, teamDid, checkToken } = {}) =>
|
package/api/routes/blocklet.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const cloneDeep = require('lodash/cloneDeep');
|
|
4
|
-
const dayjs = require('dayjs');
|
|
4
|
+
const dayjs = require('@abtnode/util/lib/dayjs');
|
|
5
5
|
const JWT = require('@arcblock/jwt');
|
|
6
6
|
const joinUrl = require('url-join');
|
|
7
7
|
const handleInstanceInStore = require('@abtnode/core/lib/util/public-to-store');
|
|
@@ -147,6 +147,7 @@ module.exports = {
|
|
|
147
147
|
did: blocklet.meta.did,
|
|
148
148
|
checkHealthImmediately: true,
|
|
149
149
|
throwOnError: true,
|
|
150
|
+
atomic: true,
|
|
150
151
|
});
|
|
151
152
|
} catch (error) {
|
|
152
153
|
startError = error;
|
|
@@ -423,16 +424,20 @@ module.exports = {
|
|
|
423
424
|
description,
|
|
424
425
|
start_url: `${WELLKNOWN_SERVICE_PATH_PREFIX}/admin`,
|
|
425
426
|
display: 'standalone',
|
|
427
|
+
theme_color: '#000000',
|
|
428
|
+
background_color: '#ffffff',
|
|
426
429
|
icons: [
|
|
427
430
|
{
|
|
428
431
|
src: `${WELLKNOWN_SERVICE_PATH_PREFIX}/blocklet/logo`,
|
|
429
432
|
sizes: '192x192',
|
|
430
433
|
type: 'image/png',
|
|
434
|
+
purpose: 'any maskable',
|
|
431
435
|
},
|
|
432
436
|
{
|
|
433
437
|
src: `${WELLKNOWN_SERVICE_PATH_PREFIX}/blocklet/logo`,
|
|
434
438
|
sizes: '512x512',
|
|
435
439
|
type: 'image/png',
|
|
440
|
+
purpose: 'any maskable',
|
|
436
441
|
},
|
|
437
442
|
],
|
|
438
443
|
});
|
|
@@ -5,6 +5,7 @@ const serveStatic = require('serve-static');
|
|
|
5
5
|
const path = require('path');
|
|
6
6
|
const nocache = require('nocache');
|
|
7
7
|
const { BLOCKLET_PREFERENCE_FILE, BLOCKLET_UPLOADS_DIR } = require('@blocklet/constant');
|
|
8
|
+
const { getHtmlResultPath } = require('@abtnode/analytics');
|
|
8
9
|
|
|
9
10
|
const builderPath = path.dirname(require.resolve('@blocklet/form-builder'));
|
|
10
11
|
const collectorPath = path.dirname(require.resolve('@blocklet/form-collector'));
|
|
@@ -12,7 +13,7 @@ const collectorPath = path.dirname(require.resolve('@blocklet/form-collector'));
|
|
|
12
13
|
const { PREFIXES } = require('../../util/constants');
|
|
13
14
|
|
|
14
15
|
module.exports = {
|
|
15
|
-
init({ app }) {
|
|
16
|
+
init({ app, node }) {
|
|
16
17
|
PREFIXES.forEach((prefix) => {
|
|
17
18
|
const preferenceUrl = `${prefix}/api/studio/preferences`;
|
|
18
19
|
|
|
@@ -78,6 +79,30 @@ module.exports = {
|
|
|
78
79
|
|
|
79
80
|
express.static(path.join(blocklet.env.dataDir, BLOCKLET_UPLOADS_DIR), staticOptions)(req, res, next);
|
|
80
81
|
});
|
|
82
|
+
|
|
83
|
+
// FIXME: @wangshijun should ensurePermission here
|
|
84
|
+
app.get(`${prefix}/api/analytics/traffic`, async (req, res) => {
|
|
85
|
+
const blocklet = await req.getBlocklet();
|
|
86
|
+
if (!blocklet) {
|
|
87
|
+
return res.status(400).send('Blocklet not found');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (blocklet.mode !== 'production') {
|
|
91
|
+
return res.status(400).send('Traffic analytics are only available for production blocklets');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const { date } = req.query;
|
|
95
|
+
if (!date) {
|
|
96
|
+
return res.status(400).send('Date is required to load traffic analytics');
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const filePath = getHtmlResultPath(node.dataDirs.data, date, blocklet.appPid);
|
|
100
|
+
if (fs.existsSync(filePath) === false) {
|
|
101
|
+
return res.status(400).send('Traffic insight for selected date not found');
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return res.sendFile(filePath);
|
|
105
|
+
});
|
|
81
106
|
});
|
|
82
107
|
},
|
|
83
108
|
};
|
|
@@ -10,7 +10,6 @@ const getDynamicServiceConfig = require('./get-dynamic-service-config');
|
|
|
10
10
|
const getStaticServiceConfig = require('./get-static-service-config');
|
|
11
11
|
|
|
12
12
|
module.exports = ({ node, req, options }) => {
|
|
13
|
-
req.getBlockletUrl = () => req.headers['x-blocklet-url'] || get(options, 'blockletUrl', '');
|
|
14
13
|
req.getBlockletDid = () => req.headers['x-blocklet-did'] || get(options, 'blockletDid', '');
|
|
15
14
|
req.getBlockletComponentId = () => req.headers['x-blocklet-component-id'] || get(options, 'blockletComponentId', '');
|
|
16
15
|
req.getRoutingRuleId = () => req.headers['x-routing-rule-id'] || get(options, 'routingRuleId', '');
|
package/api/util/index.js
CHANGED
|
@@ -2,7 +2,7 @@ const joinUrl = require('url-join');
|
|
|
2
2
|
const get = require('lodash/get');
|
|
3
3
|
const { ROLES, WHO_CAN_ACCESS } = require('@abtnode/constant');
|
|
4
4
|
const { BlockletSource, BLOCKLET_MODES, BlockletGroup } = require('@blocklet/constant');
|
|
5
|
-
const { findWebInterface } = require('@blocklet/meta/lib/util');
|
|
5
|
+
const { findWebInterface, findWebInterfacePort, findComponentByIdV2 } = require('@blocklet/meta/lib/util');
|
|
6
6
|
const { WELLKNOWN_SERVICE_PATH_PREFIX } = require('@abtnode/constant');
|
|
7
7
|
|
|
8
8
|
const getGroupPrefix = (req) => {
|
|
@@ -91,11 +91,12 @@ const findRootWebPort = (blocklet) => {
|
|
|
91
91
|
};
|
|
92
92
|
|
|
93
93
|
const ensureProxyUrl = async (req) => {
|
|
94
|
+
const blocklet = await req.getBlocklet();
|
|
94
95
|
if (req.url.startsWith('/favicon')) {
|
|
95
96
|
// convert all faviconXXX to favicon to ensure file exists in root blocklet
|
|
96
97
|
req.url = '/favicon.ico';
|
|
97
98
|
|
|
98
|
-
const port = findRootWebPort(
|
|
99
|
+
const port = findRootWebPort(blocklet);
|
|
99
100
|
if (port) {
|
|
100
101
|
return { target: `http://127.0.0.1:${port}` };
|
|
101
102
|
}
|
|
@@ -103,14 +104,20 @@ const ensureProxyUrl = async (req) => {
|
|
|
103
104
|
return { target: null };
|
|
104
105
|
}
|
|
105
106
|
|
|
106
|
-
const
|
|
107
|
+
const componentId = req.getBlockletComponentId();
|
|
108
|
+
const component = findComponentByIdV2(blocklet, componentId) || blocklet;
|
|
109
|
+
const port = findWebInterfacePort(component);
|
|
107
110
|
|
|
108
|
-
if (
|
|
109
|
-
|
|
111
|
+
if (!port) {
|
|
112
|
+
return { target: null };
|
|
113
|
+
}
|
|
110
114
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
115
|
+
const target = `http://127.0.0.1:${port}`;
|
|
116
|
+
|
|
117
|
+
// TODO: path prefix check can be removed after meta.interfaces.path|prefix need not supported
|
|
118
|
+
const pathPrefix = req.headers['x-routing-rule-path-prefix'];
|
|
119
|
+
if (pathPrefix && pathPrefix !== '/') {
|
|
120
|
+
req.url = `${pathPrefix}${req.url}`;
|
|
114
121
|
}
|
|
115
122
|
|
|
116
123
|
return { target };
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"files": {
|
|
3
3
|
"main.css": "/.well-known/service/static/static/css/main.7ea79dc8.css",
|
|
4
|
-
"main.js": "/.well-known/service/static/static/js/main.
|
|
4
|
+
"main.js": "/.well-known/service/static/static/js/main.1a83f798.js",
|
|
5
5
|
"static/js/716.1c25a58a.chunk.js": "/.well-known/service/static/static/js/716.1c25a58a.chunk.js",
|
|
6
6
|
"static/js/359.0eb124b0.chunk.js": "/.well-known/service/static/static/js/359.0eb124b0.chunk.js",
|
|
7
7
|
"static/js/255.279b1bca.chunk.js": "/.well-known/service/static/static/js/255.279b1bca.chunk.js",
|
|
8
8
|
"static/js/371.f67a06b4.chunk.js": "/.well-known/service/static/static/js/371.f67a06b4.chunk.js",
|
|
9
|
-
"static/js/737.
|
|
9
|
+
"static/js/737.3e7feae2.chunk.js": "/.well-known/service/static/static/js/737.3e7feae2.chunk.js",
|
|
10
10
|
"static/js/158.0f09b75c.chunk.js": "/.well-known/service/static/static/js/158.0f09b75c.chunk.js",
|
|
11
|
-
"static/js/868.
|
|
11
|
+
"static/js/868.cd5abe55.chunk.js": "/.well-known/service/static/static/js/868.cd5abe55.chunk.js",
|
|
12
12
|
"static/js/547.ce4b87b4.chunk.js": "/.well-known/service/static/static/js/547.ce4b87b4.chunk.js",
|
|
13
|
-
"static/js/
|
|
13
|
+
"static/js/846.bf982abb.chunk.js": "/.well-known/service/static/static/js/846.bf982abb.chunk.js",
|
|
14
14
|
"static/js/682.a8bf723a.chunk.js": "/.well-known/service/static/static/js/682.a8bf723a.chunk.js",
|
|
15
15
|
"static/js/711.56427a24.chunk.js": "/.well-known/service/static/static/js/711.56427a24.chunk.js",
|
|
16
16
|
"static/js/437.075e8453.chunk.js": "/.well-known/service/static/static/js/437.075e8453.chunk.js",
|
|
17
17
|
"static/js/690.afb99ee7.chunk.js": "/.well-known/service/static/static/js/690.afb99ee7.chunk.js",
|
|
18
18
|
"static/js/42.c390a3f4.chunk.js": "/.well-known/service/static/static/js/42.c390a3f4.chunk.js",
|
|
19
|
-
"static/js/189.
|
|
19
|
+
"static/js/189.971a999d.chunk.js": "/.well-known/service/static/static/js/189.971a999d.chunk.js",
|
|
20
20
|
"static/js/162.8c29e450.chunk.js": "/.well-known/service/static/static/js/162.8c29e450.chunk.js",
|
|
21
21
|
"static/js/610.40349d57.chunk.js": "/.well-known/service/static/static/js/610.40349d57.chunk.js",
|
|
22
|
-
"static/css/
|
|
23
|
-
"static/js/
|
|
22
|
+
"static/css/557.9597837e.chunk.css": "/.well-known/service/static/static/css/557.9597837e.chunk.css",
|
|
23
|
+
"static/js/557.ae37498c.chunk.js": "/.well-known/service/static/static/js/557.ae37498c.chunk.js",
|
|
24
24
|
"static/js/199.3d76c24b.chunk.js": "/.well-known/service/static/static/js/199.3d76c24b.chunk.js",
|
|
25
25
|
"static/js/573.5db9b322.chunk.js": "/.well-known/service/static/static/js/573.5db9b322.chunk.js",
|
|
26
26
|
"static/media/ubuntu-mono-all-400-normal.woff": "/.well-known/service/static/static/media/ubuntu-mono-all-400-normal.c879328bc62e9c68268f.woff",
|
|
@@ -46,31 +46,31 @@
|
|
|
46
46
|
"router-template-styles/styles.css": "/.well-known/service/static/router-template-styles/styles.css",
|
|
47
47
|
"index.html": "/.well-known/service/static/index.html",
|
|
48
48
|
"main.7ea79dc8.css.map": "/.well-known/service/static/static/css/main.7ea79dc8.css.map",
|
|
49
|
-
"main.
|
|
49
|
+
"main.1a83f798.js.map": "/.well-known/service/static/static/js/main.1a83f798.js.map",
|
|
50
50
|
"716.1c25a58a.chunk.js.map": "/.well-known/service/static/static/js/716.1c25a58a.chunk.js.map",
|
|
51
51
|
"359.0eb124b0.chunk.js.map": "/.well-known/service/static/static/js/359.0eb124b0.chunk.js.map",
|
|
52
52
|
"255.279b1bca.chunk.js.map": "/.well-known/service/static/static/js/255.279b1bca.chunk.js.map",
|
|
53
53
|
"371.f67a06b4.chunk.js.map": "/.well-known/service/static/static/js/371.f67a06b4.chunk.js.map",
|
|
54
|
-
"737.
|
|
54
|
+
"737.3e7feae2.chunk.js.map": "/.well-known/service/static/static/js/737.3e7feae2.chunk.js.map",
|
|
55
55
|
"158.0f09b75c.chunk.js.map": "/.well-known/service/static/static/js/158.0f09b75c.chunk.js.map",
|
|
56
|
-
"868.
|
|
56
|
+
"868.cd5abe55.chunk.js.map": "/.well-known/service/static/static/js/868.cd5abe55.chunk.js.map",
|
|
57
57
|
"547.ce4b87b4.chunk.js.map": "/.well-known/service/static/static/js/547.ce4b87b4.chunk.js.map",
|
|
58
|
-
"
|
|
58
|
+
"846.bf982abb.chunk.js.map": "/.well-known/service/static/static/js/846.bf982abb.chunk.js.map",
|
|
59
59
|
"682.a8bf723a.chunk.js.map": "/.well-known/service/static/static/js/682.a8bf723a.chunk.js.map",
|
|
60
60
|
"711.56427a24.chunk.js.map": "/.well-known/service/static/static/js/711.56427a24.chunk.js.map",
|
|
61
61
|
"437.075e8453.chunk.js.map": "/.well-known/service/static/static/js/437.075e8453.chunk.js.map",
|
|
62
62
|
"690.afb99ee7.chunk.js.map": "/.well-known/service/static/static/js/690.afb99ee7.chunk.js.map",
|
|
63
63
|
"42.c390a3f4.chunk.js.map": "/.well-known/service/static/static/js/42.c390a3f4.chunk.js.map",
|
|
64
|
-
"189.
|
|
64
|
+
"189.971a999d.chunk.js.map": "/.well-known/service/static/static/js/189.971a999d.chunk.js.map",
|
|
65
65
|
"162.8c29e450.chunk.js.map": "/.well-known/service/static/static/js/162.8c29e450.chunk.js.map",
|
|
66
66
|
"610.40349d57.chunk.js.map": "/.well-known/service/static/static/js/610.40349d57.chunk.js.map",
|
|
67
|
-
"
|
|
68
|
-
"
|
|
67
|
+
"557.9597837e.chunk.css.map": "/.well-known/service/static/static/css/557.9597837e.chunk.css.map",
|
|
68
|
+
"557.ae37498c.chunk.js.map": "/.well-known/service/static/static/js/557.ae37498c.chunk.js.map",
|
|
69
69
|
"199.3d76c24b.chunk.js.map": "/.well-known/service/static/static/js/199.3d76c24b.chunk.js.map",
|
|
70
70
|
"573.5db9b322.chunk.js.map": "/.well-known/service/static/static/js/573.5db9b322.chunk.js.map"
|
|
71
71
|
},
|
|
72
72
|
"entrypoints": [
|
|
73
73
|
"static/css/main.7ea79dc8.css",
|
|
74
|
-
"static/js/main.
|
|
74
|
+
"static/js/main.1a83f798.js"
|
|
75
75
|
]
|
|
76
76
|
}
|
package/build/index.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"/><meta name="theme-color" content="#000000"/><title>Blocklet Service</title><link rel="manifest" href="/.well-known/service/manifest.json"/><script src="/.well-known/service/api/env"></script><script src="/__blocklet__.js"></script><script defer="defer" src="/.well-known/service/static/static/js/main.
|
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"/><meta name="theme-color" content="#000000"/><title>Blocklet Service</title><link rel="manifest" href="/.well-known/service/manifest.json"/><script src="/.well-known/service/api/env"></script><script src="/__blocklet__.js"></script><script defer="defer" src="/.well-known/service/static/static/js/main.1a83f798.js"></script><link href="/.well-known/service/static/static/css/main.7ea79dc8.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|