@lowdefy/server-e2e 6.0.0 → 6.1.0

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.
@@ -0,0 +1,25 @@
1
+ /*
2
+ Copyright 2020-2026 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import { createSecretScrubber } from '@lowdefy/node-utils';
18
+
19
+ import getE2eSecrets from './getE2eSecrets.js';
20
+
21
+ // E2E logs stay unscrubbed, but _error reads this off the context like every
22
+ // other server package, so a thrown message behaves identically in every mode.
23
+ const scrubSecrets = createSecretScrubber({ secrets: getE2eSecrets() });
24
+
25
+ export default scrubSecrets;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/server-e2e",
3
- "version": "6.0.0",
3
+ "version": "6.1.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Lowdefy e2e testing server with cookie-based user injection",
6
6
  "homepage": "https://lowdefy.com",
@@ -42,35 +42,35 @@
42
42
  "dependencies": {
43
43
  "@ant-design/cssinjs": "2.1.2",
44
44
  "@ant-design/x": "2.7.0",
45
- "@hono/node-server": "2.0.4",
46
- "@lowdefy/actions-core": "6.0.0",
47
- "@lowdefy/api": "6.0.0",
48
- "@lowdefy/block-utils": "6.0.0",
49
- "@lowdefy/blocks-aggrid": "6.0.0",
50
- "@lowdefy/blocks-antd": "6.0.0",
51
- "@lowdefy/blocks-antd-x": "6.0.0",
52
- "@lowdefy/blocks-basic": "6.0.0",
53
- "@lowdefy/blocks-echarts": "6.0.0",
54
- "@lowdefy/blocks-loaders": "6.0.0",
55
- "@lowdefy/blocks-markdown": "6.0.0",
56
- "@lowdefy/blocks-tiptap": "6.0.0",
57
- "@lowdefy/client": "6.0.0",
58
- "@lowdefy/connection-axios-http": "6.0.0",
59
- "@lowdefy/connection-mongodb": "6.0.0",
60
- "@lowdefy/errors": "6.0.0",
61
- "@lowdefy/helpers": "6.0.0",
62
- "@lowdefy/layout": "6.0.0",
63
- "@lowdefy/logger": "6.0.0",
64
- "@lowdefy/node-utils": "6.0.0",
65
- "@lowdefy/operators-js": "6.0.0",
66
- "@lowdefy/operators-nunjucks": "6.0.0",
67
- "@lowdefy/operators-uuid": "6.0.0",
68
- "@lowdefy/websockets-core": "6.0.0",
45
+ "@hono/node-server": "2.0.10",
46
+ "@lowdefy/actions-core": "6.1.0",
47
+ "@lowdefy/api": "6.1.0",
48
+ "@lowdefy/block-utils": "6.1.0",
49
+ "@lowdefy/blocks-aggrid": "6.1.0",
50
+ "@lowdefy/blocks-antd": "6.1.0",
51
+ "@lowdefy/blocks-antd-x": "6.1.0",
52
+ "@lowdefy/blocks-basic": "6.1.0",
53
+ "@lowdefy/blocks-echarts": "6.1.0",
54
+ "@lowdefy/blocks-loaders": "6.1.0",
55
+ "@lowdefy/blocks-markdown": "6.1.0",
56
+ "@lowdefy/blocks-tiptap": "6.1.0",
57
+ "@lowdefy/client": "6.1.0",
58
+ "@lowdefy/connection-axios-http": "6.1.0",
59
+ "@lowdefy/connection-mongodb": "6.1.0",
60
+ "@lowdefy/errors": "6.1.0",
61
+ "@lowdefy/helpers": "6.1.0",
62
+ "@lowdefy/layout": "6.1.0",
63
+ "@lowdefy/logger": "6.1.0",
64
+ "@lowdefy/node-utils": "6.1.0",
65
+ "@lowdefy/operators-js": "6.1.0",
66
+ "@lowdefy/operators-nunjucks": "6.1.0",
67
+ "@lowdefy/operators-uuid": "6.1.0",
68
+ "@lowdefy/websockets-core": "6.1.0",
69
69
  "@tailwindcss/postcss": "4.3.1",
70
70
  "@vitejs/plugin-react": "6.0.2",
71
71
  "antd": "6.3.1",
72
72
  "dayjs": "1.11.20",
73
- "hono": "4.12.25",
73
+ "hono": "4.13.5",
74
74
  "pino": "10.3.1",
75
75
  "react": "18.2.0",
76
76
  "react-dom": "18.2.0",
@@ -78,16 +78,14 @@
78
78
  "tailwindcss": "4.3.1",
79
79
  "uuid": "14.0.0",
80
80
  "vite": "8.0.16",
81
- "ws": "8.18.0"
81
+ "ws": "8.21.0"
82
82
  },
83
83
  "devDependencies": {
84
84
  "@jest/globals": "28.1.3",
85
- "@lowdefy/build": "6.0.0",
86
- "@next/eslint-plugin-next": "16.1.6",
85
+ "@lowdefy/build": "6.1.0",
87
86
  "@tailwindcss/postcss": "4.3.1",
88
87
  "jest": "28.1.3",
89
88
  "tailwindcss": "4.3.1",
90
- "webpack": "5.94.0",
91
89
  "yaml": "2.9.0",
92
90
  "yargs": "18.0.0"
93
91
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/server-e2e",
3
- "version": "6.0.0",
3
+ "version": "6.1.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Lowdefy e2e testing server with cookie-based user injection",
6
6
  "homepage": "https://lowdefy.com",
@@ -50,35 +50,35 @@
50
50
  "dependencies": {
51
51
  "@ant-design/cssinjs": "2.1.2",
52
52
  "@ant-design/x": "2.7.0",
53
- "@hono/node-server": "2.0.4",
54
- "@lowdefy/actions-core": "6.0.0",
55
- "@lowdefy/api": "6.0.0",
56
- "@lowdefy/block-utils": "6.0.0",
57
- "@lowdefy/blocks-aggrid": "6.0.0",
58
- "@lowdefy/blocks-antd": "6.0.0",
59
- "@lowdefy/blocks-antd-x": "6.0.0",
60
- "@lowdefy/blocks-basic": "6.0.0",
61
- "@lowdefy/blocks-echarts": "6.0.0",
62
- "@lowdefy/blocks-loaders": "6.0.0",
63
- "@lowdefy/blocks-markdown": "6.0.0",
64
- "@lowdefy/blocks-tiptap": "6.0.0",
65
- "@lowdefy/client": "6.0.0",
66
- "@lowdefy/connection-axios-http": "6.0.0",
67
- "@lowdefy/connection-mongodb": "6.0.0",
68
- "@lowdefy/errors": "6.0.0",
69
- "@lowdefy/helpers": "6.0.0",
70
- "@lowdefy/layout": "6.0.0",
71
- "@lowdefy/logger": "6.0.0",
72
- "@lowdefy/node-utils": "6.0.0",
73
- "@lowdefy/operators-js": "6.0.0",
74
- "@lowdefy/operators-nunjucks": "6.0.0",
75
- "@lowdefy/operators-uuid": "6.0.0",
76
- "@lowdefy/websockets-core": "6.0.0",
53
+ "@hono/node-server": "2.0.10",
54
+ "@lowdefy/actions-core": "6.1.0",
55
+ "@lowdefy/api": "6.1.0",
56
+ "@lowdefy/block-utils": "6.1.0",
57
+ "@lowdefy/blocks-aggrid": "6.1.0",
58
+ "@lowdefy/blocks-antd": "6.1.0",
59
+ "@lowdefy/blocks-antd-x": "6.1.0",
60
+ "@lowdefy/blocks-basic": "6.1.0",
61
+ "@lowdefy/blocks-echarts": "6.1.0",
62
+ "@lowdefy/blocks-loaders": "6.1.0",
63
+ "@lowdefy/blocks-markdown": "6.1.0",
64
+ "@lowdefy/blocks-tiptap": "6.1.0",
65
+ "@lowdefy/client": "6.1.0",
66
+ "@lowdefy/connection-axios-http": "6.1.0",
67
+ "@lowdefy/connection-mongodb": "6.1.0",
68
+ "@lowdefy/errors": "6.1.0",
69
+ "@lowdefy/helpers": "6.1.0",
70
+ "@lowdefy/layout": "6.1.0",
71
+ "@lowdefy/logger": "6.1.0",
72
+ "@lowdefy/node-utils": "6.1.0",
73
+ "@lowdefy/operators-js": "6.1.0",
74
+ "@lowdefy/operators-nunjucks": "6.1.0",
75
+ "@lowdefy/operators-uuid": "6.1.0",
76
+ "@lowdefy/websockets-core": "6.1.0",
77
77
  "@tailwindcss/postcss": "4.3.1",
78
78
  "@vitejs/plugin-react": "6.0.2",
79
79
  "antd": "6.3.1",
80
80
  "dayjs": "1.11.20",
81
- "hono": "4.12.25",
81
+ "hono": "4.13.5",
82
82
  "pino": "10.3.1",
83
83
  "react": "18.2.0",
84
84
  "react-dom": "18.2.0",
@@ -86,16 +86,14 @@
86
86
  "tailwindcss": "4.3.1",
87
87
  "uuid": "14.0.0",
88
88
  "vite": "8.0.16",
89
- "ws": "8.18.0"
89
+ "ws": "8.21.0"
90
90
  },
91
91
  "devDependencies": {
92
92
  "@jest/globals": "28.1.3",
93
- "@lowdefy/build": "6.0.0",
94
- "@next/eslint-plugin-next": "16.1.6",
93
+ "@lowdefy/build": "6.1.0",
95
94
  "@tailwindcss/postcss": "4.3.1",
96
95
  "jest": "28.1.3",
97
96
  "tailwindcss": "4.3.1",
98
- "webpack": "5.94.0",
99
97
  "yaml": "2.9.0",
100
98
  "yargs": "18.0.0"
101
99
  },
@@ -31,6 +31,7 @@ import i18nConfig from '../../lib/build/i18n.js';
31
31
  import jsMap from '../../build/plugins/operators/serverJsMap.js';
32
32
  import logRequest from '../../lib/server/log/logRequest.js';
33
33
  import operators from '../../build/plugins/operators/server.js';
34
+ import scrubSecrets from '../../lib/server/scrubSecrets.js';
34
35
  import websockets from '../../build/plugins/websockets.js';
35
36
 
36
37
  const secrets = getE2eSecrets();
@@ -60,12 +61,14 @@ function apiContext() {
60
61
  i18n: i18nConfig,
61
62
  jsMap,
62
63
  logger: createLogger({ rid }),
64
+ mode: 'prod',
63
65
  operators,
64
66
  req: {
65
67
  url: c.req.path,
66
68
  method: c.req.method,
67
69
  hostname: c.req.header('host'),
68
70
  },
71
+ scrubSecrets,
69
72
  secrets,
70
73
  websockets,
71
74
  };
@@ -0,0 +1,109 @@
1
+ /*
2
+ Copyright 2020-2026 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import fs from 'fs';
18
+ import path from 'path';
19
+ import { fileURLToPath } from 'url';
20
+
21
+ import { Hono } from 'hono';
22
+ import { jest } from '@jest/globals';
23
+
24
+ const secret = 'planted-e2e-secret';
25
+ process.env.LOWDEFY_SECRET_TEST = secret;
26
+
27
+ jest.unstable_mockModule('@lowdefy/api', () => ({ createApiContext: jest.fn() }));
28
+ jest.unstable_mockModule('../../lib/build/appMeta.js', () => ({ default: {} }));
29
+ jest.unstable_mockModule('../../lib/build/config.js', () => ({ default: {} }));
30
+ jest.unstable_mockModule('../../lib/build/i18n.js', () => ({ default: {} }));
31
+ jest.unstable_mockModule('../../lib/server/log/createHandleError.js', () => ({
32
+ default: jest.fn(() => jest.fn()),
33
+ }));
34
+ jest.unstable_mockModule('../../lib/server/log/createLogger.js', () => ({
35
+ default: jest.fn(() => ({ debug: jest.fn(), info: jest.fn(), warn: jest.fn(), error: jest.fn() })),
36
+ }));
37
+ jest.unstable_mockModule('../../lib/server/fileCache.js', () => ({ default: {} }));
38
+ jest.unstable_mockModule('../../lib/server/getE2eSecrets.js', () => ({
39
+ default: jest.fn(() => ({ TEST: process.env.LOWDEFY_SECRET_TEST })),
40
+ }));
41
+ jest.unstable_mockModule('../../lib/server/auth/session.js', () => ({
42
+ default: jest.fn(() => undefined),
43
+ }));
44
+ jest.unstable_mockModule('../../lib/server/log/logRequest.js', () => ({ default: jest.fn() }));
45
+
46
+ // apiContext statically imports the app build's plugin artifacts, which only
47
+ // exist in a built app (build/** is gitignored). Materialize the minimal set
48
+ // it needs so the import resolves; clean up only what this test created.
49
+ const dirname = path.dirname(fileURLToPath(import.meta.url));
50
+ const pluginsDir = path.resolve(dirname, '../../build/plugins');
51
+ const fixtures = [
52
+ { file: 'agents.js', content: 'export default {};\n' },
53
+ { file: 'connections.js', content: 'export default {};\n' },
54
+ { file: path.join('operators', 'server.js'), content: 'export default {};\n' },
55
+ { file: path.join('operators', 'serverJsMap.js'), content: 'export default {};\n' },
56
+ { file: 'websockets.js', content: 'export default {};\n' },
57
+ ].map(({ file, content }) => ({ absolutePath: path.join(pluginsDir, file), content }));
58
+
59
+ const createdFixtures = [];
60
+ fixtures.forEach(({ absolutePath, content }) => {
61
+ if (!fs.existsSync(absolutePath)) {
62
+ fs.mkdirSync(path.dirname(absolutePath), { recursive: true });
63
+ fs.writeFileSync(absolutePath, content);
64
+ createdFixtures.push(absolutePath);
65
+ }
66
+ });
67
+
68
+ // A checkout that has built an app already holds real artifacts here, which import plugins this
69
+ // package does not depend on, so the stubs are also mocked over whatever is on disk.
70
+ fixtures.forEach(({ absolutePath }) => {
71
+ jest.unstable_mockModule(absolutePath, () => ({
72
+ default: {},
73
+ interpolateProperties: () => {},
74
+ renderEmail: () => {},
75
+ }));
76
+ });
77
+
78
+ afterAll(() => {
79
+ createdFixtures.forEach((absolutePath) => fs.rmSync(absolutePath, { force: true }));
80
+ });
81
+
82
+ const { default: apiContext } = await import('./apiContext.js');
83
+
84
+ function createApp() {
85
+ const app = new Hono();
86
+ app.use('*', apiContext());
87
+ app.get('/api/ping', (c) => {
88
+ const context = c.get('lowdefyContext');
89
+ return c.json({
90
+ mode: context.mode,
91
+ scrubbed: context.scrubSecrets(`token ${secret} end`),
92
+ });
93
+ });
94
+ return app;
95
+ }
96
+
97
+ test('apiContext sets mode to prod', async () => {
98
+ const res = await createApp().request('/api/ping');
99
+ expect(res.status).toEqual(200);
100
+ const body = await res.json();
101
+ expect(body.mode).toEqual('prod');
102
+ });
103
+
104
+ test('apiContext scrubSecrets redacts a planted secret', async () => {
105
+ const res = await createApp().request('/api/ping');
106
+ expect(res.status).toEqual(200);
107
+ const body = await res.json();
108
+ expect(body.scrubbed).toEqual('token [REDACTED] end');
109
+ });
@@ -1,73 +0,0 @@
1
- /*
2
- Copyright 2020-2026 Lowdefy, Inc
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */
16
-
17
- import path from 'path';
18
- import { createApiContext, redactErrorResponse } from '@lowdefy/api';
19
- import { v4 as uuid } from 'uuid';
20
-
21
- import appMeta from '../build/appMeta.js';
22
- import config from '../build/config.js';
23
- import connections from '../../build/plugins/connections.js';
24
- import createLogger from './log/createLogger.js';
25
- import fileCache from './fileCache.js';
26
- import getE2eSecrets from './getE2eSecrets.js';
27
- import getServerSession from './auth/getServerSession.js';
28
- import createHandleError from './log/createHandleError.js';
29
- import logRequest from './log/logRequest.js';
30
- import operators from '../../build/plugins/operators/server.js';
31
- import jsMap from '../../build/plugins/operators/serverJsMap.js';
32
-
33
- const secrets = getE2eSecrets();
34
-
35
- function apiWrapper(handler) {
36
- return async function wrappedHandler(req, res) {
37
- const context = {
38
- // Important to give absolute path so Next can trace build files
39
- rid: uuid(),
40
- appMeta,
41
- buildDirectory: path.join(process.cwd(), 'build'),
42
- configDirectory: process.env.LOWDEFY_DIRECTORY_CONFIG || process.cwd(),
43
- config,
44
- connections,
45
- fileCache,
46
- headers: req?.headers,
47
- jsMap,
48
- handleError: async (err) => {
49
- console.error(err);
50
- },
51
- logger: console,
52
- operators,
53
- req,
54
- res,
55
- secrets,
56
- };
57
- try {
58
- context.logger = createLogger({ rid: context.rid });
59
- context.handleError = createHandleError({ context });
60
- context.session = getServerSession(context);
61
- createApiContext(context);
62
- logRequest({ context });
63
- // Await here so that if handler throws it is caught.
64
- const response = await handler({ context, req, res });
65
- return response;
66
- } catch (error) {
67
- await context.handleError(error);
68
- res.status(500).json(redactErrorResponse(context, error));
69
- }
70
- };
71
- }
72
-
73
- export default apiWrapper;