@lowdefy/server 7.1.0 → 7.3.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.
Files changed (74) hide show
  1. package/client/clientBuildImports.test.mjs +1 -0
  2. package/client/getShownPage.test.mjs +1 -0
  3. package/client/shouldReloadForTypes.test.mjs +1 -0
  4. package/lib/build/mobileConfig.js +26 -0
  5. package/lib/client/auth/AuthConfigured.jsx +75 -48
  6. package/lib/client/auth/createFetchCheckingBuild.test.mjs +3 -3
  7. package/lib/client/auth/sessionCaller.js +56 -0
  8. package/lib/client/createLogUsage.test.mjs +2 -2
  9. package/lib/server/getClientAddress.test.mjs +6 -7
  10. package/lib/server/log/createHandleError.test.mjs +5 -5
  11. package/lib/server/log/createLogger.test.mjs +3 -3
  12. package/lib/server/log/projectErrorForLog.js +6 -4
  13. package/lib/server/log/redactUrlQuery.test.mjs +1 -0
  14. package/lib/server/log/serializeErrorForLog.test.mjs +50 -113
  15. package/lib/server/sentry/captureSentryError.test.mjs +4 -7
  16. package/lib/server/sentry/initSentry.serverless.test.mjs +6 -6
  17. package/lib/server/sentry/initSentry.test.mjs +3 -3
  18. package/lib/server/sentry/scrubEvent.test.mjs +2 -0
  19. package/lowdefy/build.mjs +4 -1
  20. package/lowdefy/build.test.mjs +11 -13
  21. package/lowdefy/createCustomPluginMessagesMap.mjs +2 -4
  22. package/lowdefy/createCustomPluginTypesMap.mjs +39 -11
  23. package/lowdefy/createCustomPluginTypesMap.test.mjs +249 -0
  24. package/package.json +32 -33
  25. package/package.original.json +32 -33
  26. package/src/app.js +19 -2
  27. package/src/app.mobile.test.mjs +351 -0
  28. package/src/app.test.mjs +31 -27
  29. package/src/app.timeout.test.mjs +141 -0
  30. package/src/html/collectPageTypesAssets.test.mjs +1 -0
  31. package/src/html/getPageAssets.test.mjs +1 -0
  32. package/src/html/renderPage.contentSecurityPolicy.test.mjs +13 -10
  33. package/src/html/renderPage.test.mjs +16 -13
  34. package/src/html/template.test.mjs +1 -0
  35. package/src/initServer.test.mjs +12 -12
  36. package/src/lib/getPathSegments.js +16 -1
  37. package/src/lib/getRequestSurface.js +25 -0
  38. package/src/middleware/apiContext.js +7 -4
  39. package/src/middleware/apiContext.test.mjs +48 -30
  40. package/src/middleware/createSameOriginGuard.test.mjs +1 -0
  41. package/src/middleware/errorHandler.js +33 -45
  42. package/src/middleware/errorHandler.test.mjs +11 -11
  43. package/src/middleware/refuseOtherBuild.test.mjs +3 -3
  44. package/src/middleware/requestTimeout.js +7 -1
  45. package/src/middleware/stampBuildId.test.mjs +1 -0
  46. package/src/middleware/stampCaller.test.mjs +1 -0
  47. package/src/routes/agentBearer.test.mjs +175 -0
  48. package/src/routes/apiPage.js +12 -1
  49. package/src/routes/apiPage.test.mjs +5 -5
  50. package/src/routes/auth.test.mjs +6 -6
  51. package/src/routes/clientError.js +14 -2
  52. package/src/routes/clientError.test.mjs +106 -0
  53. package/src/routes/endpoints.js +24 -0
  54. package/src/routes/endpointsLink.test.mjs +112 -0
  55. package/src/routes/endpointsTextAnswer.test.mjs +8 -8
  56. package/src/routes/mcp.js +6 -0
  57. package/src/routes/mcp.test.mjs +23 -8
  58. package/src/routes/mcpMemberToken.test.mjs +8 -8
  59. package/src/routes/mcpProtectedResourceMetadata.test.mjs +2 -2
  60. package/src/routes/mobileRoot.js +30 -0
  61. package/src/routes/mobileSignIn.js +46 -0
  62. package/src/routes/mobileSignIn.test.mjs +58 -0
  63. package/src/routes/mobileSignInCallback.js +34 -0
  64. package/src/routes/mobileSignInCallback.test.mjs +51 -0
  65. package/src/routes/mountMobileWellKnown.js +35 -0
  66. package/src/routes/mountMobileWellKnown.test.mjs +79 -0
  67. package/src/routes/mountOauthDiscovery.test.mjs +5 -5
  68. package/src/routes/mountPageRoutes.js +9 -2
  69. package/src/routes/mountPageRoutes.test.mjs +33 -3
  70. package/src/routes/normalizeMcpProtocolVersionHeader.test.mjs +1 -0
  71. package/src/routes/requestBody.test.mjs +12 -12
  72. package/src/routes/websocket.js +4 -2
  73. package/src/routes/websocket.test.mjs +2 -2
  74. package/lib/server/log/maskCredentialKeys.js +0 -37
@@ -0,0 +1,249 @@
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 { vi, beforeEach, expect, test } from 'vitest';
18
+
19
+ const pluginYaml = `
20
+ plugins:
21
+ - name: fake-plugin
22
+ version: 1.0.0
23
+ `;
24
+
25
+ const shellPluginYaml = `
26
+ plugins:
27
+ - name: fake-plugin
28
+ version: 1.0.0
29
+ mobile:
30
+ shells:
31
+ - id: field
32
+ plugins:
33
+ - name: '@example/lowdefy-printer'
34
+ version: 2.1.0
35
+ typePrefix: Printer
36
+ - id: staging
37
+ plugins:
38
+ - name: '@example/lowdefy-printer'
39
+ version: 2.1.0
40
+ typePrefix: Printer
41
+ `;
42
+
43
+ const nativeOnlyYaml = `
44
+ mobile:
45
+ shells:
46
+ - id: field
47
+ plugins:
48
+ - name: '@example/lowdefy-printer'
49
+ version: 2.1.0
50
+ typePrefix: Printer
51
+ - name: '@example/lowdefy-mdm'
52
+ version: 1.0.3
53
+ options: { tenant: field-team }
54
+ `;
55
+
56
+ const rootNativeOnlyYaml = `
57
+ plugins:
58
+ - name: '@example/lowdefy-mdm'
59
+ version: 1.0.3
60
+ `;
61
+
62
+ const printerTypes = {
63
+ blocks: ['WebLabel'],
64
+ native: {
65
+ actions: ['Print'],
66
+ blockMetas: { Label: { category: 'display' } },
67
+ blocks: ['Label'],
68
+ icons: { Label: ['printer'] },
69
+ },
70
+ };
71
+
72
+ const pluginTypesEsm = {
73
+ __esModule: true,
74
+ default: {
75
+ actions: ['FakeAction'],
76
+ blocks: ['FakeBlock'],
77
+ blockMetas: {
78
+ FakeBlock: { category: 'display' },
79
+ },
80
+ operators: {
81
+ client: ['_fakeClientOp'],
82
+ server: ['_fakeServerOp'],
83
+ },
84
+ requests: ['FakeRequest'],
85
+ icons: {
86
+ FakeBlock: 'icon-name',
87
+ },
88
+ },
89
+ };
90
+
91
+ // The module under test imports @lowdefy/build, which links against every
92
+ // export it uses, so the real module passes through and only file access is
93
+ // replaced.
94
+ const realNodeUtils = await import('@lowdefy/node-utils');
95
+ vi.doMock('@lowdefy/node-utils', () => ({
96
+ ...realNodeUtils,
97
+ cleanDirectory: vi.fn(),
98
+ copyFileOrDirectory: vi.fn(),
99
+ getFileExtension: vi.fn(),
100
+ getFileSubExtension: vi.fn(),
101
+ getSecretsFromEnv: vi.fn(),
102
+ spawnProcess: vi.fn(),
103
+ readFile: vi.fn(async () => pluginYaml),
104
+ writeFile: vi.fn(),
105
+ writeFileIfChanged: vi.fn(),
106
+ installIfPackageJsonChanged: vi.fn(),
107
+ // @example/lowdefy-mdm exports ./shell alone, a native-only shell plugin.
108
+ hasTypesExport: vi.fn(({ name }) => name !== '@example/lowdefy-mdm'),
109
+ }));
110
+
111
+ // Modules the test does not fake (those @lowdefy/build loads, such as twrnc) load as usual.
112
+ const realModule = await import('node:module');
113
+ vi.doMock('node:module', () => ({
114
+ ...realModule,
115
+ createRequire: (from) => (moduleName) => {
116
+ if (moduleName === 'fake-plugin/types') {
117
+ return pluginTypesEsm;
118
+ }
119
+ if (moduleName === '@example/lowdefy-printer/types') {
120
+ return printerTypes;
121
+ }
122
+ if (moduleName === '@example/lowdefy-mdm/types') {
123
+ const error = new Error(
124
+ 'Package subpath \'./types\' is not defined by "exports" in @example/lowdefy-mdm/package.json'
125
+ );
126
+ error.code = 'ERR_PACKAGE_PATH_NOT_EXPORTED';
127
+ throw error;
128
+ }
129
+ return realModule.createRequire(from)(moduleName);
130
+ },
131
+ }));
132
+
133
+ // Imported once, after the mocks: it loads @lowdefy/build, which takes seconds.
134
+ const { default: createCustomPluginTypesMap } = await import('./createCustomPluginTypesMap.mjs');
135
+
136
+ beforeEach(() => {
137
+ vi.clearAllMocks();
138
+ });
139
+
140
+ test('unwraps ESM default export when loading plugin types', async () => {
141
+ const { customTypesMap: result } = await createCustomPluginTypesMap({
142
+ directories: { config: '/config' },
143
+ });
144
+ expect(result.actions).toEqual({
145
+ FakeAction: { package: 'fake-plugin', originalTypeName: 'FakeAction', version: '1.0.0' },
146
+ });
147
+ expect(result.blocks).toEqual({
148
+ FakeBlock: { package: 'fake-plugin', originalTypeName: 'FakeBlock', version: '1.0.0' },
149
+ });
150
+ expect(result.operators.client).toEqual({
151
+ _fakeClientOp: { package: 'fake-plugin', originalTypeName: '_fakeClientOp', version: '1.0.0' },
152
+ });
153
+ expect(result.operators.server).toEqual({
154
+ _fakeServerOp: { package: 'fake-plugin', originalTypeName: '_fakeServerOp', version: '1.0.0' },
155
+ });
156
+ expect(result.requests).toEqual({
157
+ FakeRequest: { package: 'fake-plugin', originalTypeName: 'FakeRequest', version: '1.0.0' },
158
+ });
159
+ });
160
+
161
+ test('populates blockMetas from plugin types', async () => {
162
+ const { customTypesMap: result } = await createCustomPluginTypesMap({
163
+ directories: { config: '/config' },
164
+ });
165
+ expect(result.blockMetas).toEqual({
166
+ FakeBlock: { category: 'display' },
167
+ });
168
+ });
169
+
170
+ test('populates icons from plugin types', async () => {
171
+ const { customTypesMap: result } = await createCustomPluginTypesMap({
172
+ directories: { config: '/config' },
173
+ });
174
+ expect(result.icons).toEqual({
175
+ FakeBlock: 'icon-name',
176
+ });
177
+ });
178
+
179
+ test('returns empty typesMap when neither lowdefy.yaml nor lowdefy.yml exists', async () => {
180
+ const { readFile } = await import('@lowdefy/node-utils');
181
+ readFile.mockResolvedValue(undefined);
182
+ const { customTypesMap: result } = await createCustomPluginTypesMap({
183
+ directories: { config: '/config' },
184
+ });
185
+ expect(result.actions).toEqual({});
186
+ expect(result.blocks).toEqual({});
187
+ expect(result.blockMetas).toEqual({});
188
+ expect(result.icons).toEqual({});
189
+ expect(result.requests).toEqual({});
190
+ expect(result.operators).toEqual({ client: {}, server: {} });
191
+ });
192
+
193
+ test('registers shell plugin native types in the mobile map and web types in the web map', async () => {
194
+ const { readFile } = await import('@lowdefy/node-utils');
195
+ readFile.mockResolvedValue(shellPluginYaml);
196
+ const { customTypesMap, customTypesMapMobile } = await createCustomPluginTypesMap({
197
+ directories: { config: '/config' },
198
+ });
199
+ expect(customTypesMapMobile).toEqual({
200
+ actions: {
201
+ PrinterPrint: {
202
+ package: '@example/lowdefy-printer',
203
+ originalTypeName: 'Print',
204
+ version: '2.1.0',
205
+ },
206
+ },
207
+ blockMetas: { PrinterLabel: { category: 'display' } },
208
+ blocks: {
209
+ PrinterLabel: {
210
+ package: '@example/lowdefy-printer',
211
+ originalTypeName: 'Label',
212
+ version: '2.1.0',
213
+ },
214
+ },
215
+ icons: { PrinterLabel: ['printer'] },
216
+ operators: { client: {} },
217
+ plugins: ['@example/lowdefy-printer'],
218
+ });
219
+ expect(customTypesMap.blocks.PrinterWebLabel).toEqual({
220
+ package: '@example/lowdefy-printer',
221
+ originalTypeName: 'WebLabel',
222
+ version: '2.1.0',
223
+ });
224
+ expect(customTypesMap.blocks.PrinterLabel).toBeUndefined();
225
+ expect(customTypesMap.actions.PrinterPrint).toBeUndefined();
226
+ });
227
+
228
+ test('a shell-only plugin without ./types adds no types and stays listed in the mobile map', async () => {
229
+ const { readFile } = await import('@lowdefy/node-utils');
230
+ readFile.mockResolvedValue(nativeOnlyYaml);
231
+ const { customTypesMap, customTypesMapMobile } = await createCustomPluginTypesMap({
232
+ directories: { config: '/config' },
233
+ });
234
+ expect(customTypesMapMobile.plugins).toEqual([
235
+ '@example/lowdefy-printer',
236
+ '@example/lowdefy-mdm',
237
+ ]);
238
+ expect(Object.keys(customTypesMapMobile.blocks)).toEqual(['PrinterLabel']);
239
+ expect(Object.keys(customTypesMapMobile.actions)).toEqual(['PrinterPrint']);
240
+ expect(Object.keys(customTypesMap.blocks)).toEqual(['PrinterWebLabel']);
241
+ });
242
+
243
+ test('a root plugin without ./types still fails', async () => {
244
+ const { readFile } = await import('@lowdefy/node-utils');
245
+ readFile.mockResolvedValue(rootNativeOnlyYaml);
246
+ await expect(createCustomPluginTypesMap({ directories: { config: '/config' } })).rejects.toThrow(
247
+ 'Package subpath \'./types\' is not defined by "exports"'
248
+ );
249
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/server",
3
- "version": "7.1.0",
3
+ "version": "7.3.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -43,32 +43,32 @@
43
43
  "@better-auth/oauth-provider": "1.7.7",
44
44
  "@better-auth/passkey": "1.7.7",
45
45
  "@hono/mcp": "0.3.2",
46
- "@hono/node-server": "2.0.10",
47
- "@lowdefy/actions-core": "7.1.0",
48
- "@lowdefy/api": "7.1.0",
49
- "@lowdefy/block-utils": "7.1.0",
50
- "@lowdefy/blocks-aggrid": "7.1.0",
51
- "@lowdefy/blocks-antd": "7.1.0",
52
- "@lowdefy/blocks-antd-x": "7.1.0",
53
- "@lowdefy/blocks-basic": "7.1.0",
54
- "@lowdefy/blocks-captcha": "7.1.0",
55
- "@lowdefy/blocks-echarts": "7.1.0",
56
- "@lowdefy/blocks-files": "7.1.0",
57
- "@lowdefy/blocks-loaders": "7.1.0",
58
- "@lowdefy/blocks-markdown": "7.1.0",
59
- "@lowdefy/blocks-table": "7.1.0",
60
- "@lowdefy/blocks-tiptap": "7.1.0",
61
- "@lowdefy/client": "7.1.0",
62
- "@lowdefy/connection-anthropic": "7.1.0",
63
- "@lowdefy/errors": "7.1.0",
64
- "@lowdefy/helpers": "7.1.0",
65
- "@lowdefy/layout": "7.1.0",
66
- "@lowdefy/logger": "7.1.0",
67
- "@lowdefy/node-utils": "7.1.0",
68
- "@lowdefy/operators-js": "7.1.0",
69
- "@lowdefy/operators-nunjucks": "7.1.0",
70
- "@lowdefy/plugin-better-auth": "7.1.0",
71
- "@lowdefy/websockets-core": "7.1.0",
46
+ "@hono/node-server": "2.1.3",
47
+ "@lowdefy/actions-core": "7.3.0",
48
+ "@lowdefy/api": "7.3.0",
49
+ "@lowdefy/block-utils": "7.3.0",
50
+ "@lowdefy/blocks-aggrid": "7.3.0",
51
+ "@lowdefy/blocks-antd": "7.3.0",
52
+ "@lowdefy/blocks-antd-x": "7.3.0",
53
+ "@lowdefy/blocks-basic": "7.3.0",
54
+ "@lowdefy/blocks-captcha": "7.3.0",
55
+ "@lowdefy/blocks-echarts": "7.3.0",
56
+ "@lowdefy/blocks-files": "7.3.0",
57
+ "@lowdefy/blocks-loaders": "7.3.0",
58
+ "@lowdefy/blocks-markdown": "7.3.0",
59
+ "@lowdefy/blocks-table": "7.3.0",
60
+ "@lowdefy/blocks-tiptap": "7.3.0",
61
+ "@lowdefy/client": "7.3.0",
62
+ "@lowdefy/connection-anthropic": "7.3.0",
63
+ "@lowdefy/errors": "7.3.0",
64
+ "@lowdefy/helpers": "7.3.0",
65
+ "@lowdefy/layout": "7.3.0",
66
+ "@lowdefy/logger": "7.3.0",
67
+ "@lowdefy/node-utils": "7.3.0",
68
+ "@lowdefy/operators-js": "7.3.0",
69
+ "@lowdefy/operators-nunjucks": "7.3.0",
70
+ "@lowdefy/plugin-better-auth": "7.3.0",
71
+ "@lowdefy/websockets-core": "7.3.0",
72
72
  "@sentry/browser": "10.57.0",
73
73
  "@sentry/node": "10.57.0",
74
74
  "@sentry/node-core": "10.57.0",
@@ -78,21 +78,20 @@
78
78
  "antd": "6.6.5",
79
79
  "better-auth": "1.7.7",
80
80
  "dayjs": "1.11.20",
81
- "hono": "4.13.7",
81
+ "hono": "4.13.14",
82
82
  "lightningcss": "1.32.0",
83
83
  "react": "18.2.0",
84
84
  "react-dom": "18.2.0",
85
85
  "tailwindcss": "4.3.3",
86
86
  "uuid": "14.0.0",
87
- "vite": "8.0.16",
87
+ "vite": "8.1.6",
88
88
  "ws": "8.21.0"
89
89
  },
90
90
  "devDependencies": {
91
- "@jest/globals": "28.1.3",
92
- "@lowdefy/build": "7.1.0",
91
+ "@lowdefy/build": "7.3.0",
93
92
  "@tailwindcss/postcss": "4.3.3",
94
- "jest": "28.1.3",
95
93
  "tailwindcss": "4.3.3",
94
+ "vitest": "4.1.12",
96
95
  "yaml": "2.9.0",
97
96
  "yargs": "18.0.0"
98
97
  },
@@ -108,6 +107,6 @@
108
107
  "build:client": "vite build",
109
108
  "build:lowdefy": "node lowdefy/build.mjs",
110
109
  "start": "node src/index.js",
111
- "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
110
+ "test": "vitest run"
112
111
  }
113
112
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/server",
3
- "version": "7.1.0",
3
+ "version": "7.3.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -43,7 +43,7 @@
43
43
  "build:lowdefy": "node lowdefy/build.mjs",
44
44
  "prepublishOnly": "pnpm build",
45
45
  "start": "node src/index.js",
46
- "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
46
+ "test": "vitest run"
47
47
  },
48
48
  "dependencies": {
49
49
  "@ant-design/cssinjs": "2.1.2",
@@ -51,32 +51,32 @@
51
51
  "@better-auth/oauth-provider": "1.7.7",
52
52
  "@better-auth/passkey": "1.7.7",
53
53
  "@hono/mcp": "0.3.2",
54
- "@hono/node-server": "2.0.10",
55
- "@lowdefy/actions-core": "7.1.0",
56
- "@lowdefy/api": "7.1.0",
57
- "@lowdefy/block-utils": "7.1.0",
58
- "@lowdefy/blocks-aggrid": "7.1.0",
59
- "@lowdefy/blocks-antd": "7.1.0",
60
- "@lowdefy/blocks-antd-x": "7.1.0",
61
- "@lowdefy/blocks-basic": "7.1.0",
62
- "@lowdefy/blocks-captcha": "7.1.0",
63
- "@lowdefy/blocks-echarts": "7.1.0",
64
- "@lowdefy/blocks-files": "7.1.0",
65
- "@lowdefy/blocks-loaders": "7.1.0",
66
- "@lowdefy/blocks-markdown": "7.1.0",
67
- "@lowdefy/blocks-table": "7.1.0",
68
- "@lowdefy/blocks-tiptap": "7.1.0",
69
- "@lowdefy/client": "7.1.0",
70
- "@lowdefy/connection-anthropic": "7.1.0",
71
- "@lowdefy/errors": "7.1.0",
72
- "@lowdefy/helpers": "7.1.0",
73
- "@lowdefy/layout": "7.1.0",
74
- "@lowdefy/logger": "7.1.0",
75
- "@lowdefy/node-utils": "7.1.0",
76
- "@lowdefy/operators-js": "7.1.0",
77
- "@lowdefy/operators-nunjucks": "7.1.0",
78
- "@lowdefy/plugin-better-auth": "7.1.0",
79
- "@lowdefy/websockets-core": "7.1.0",
54
+ "@hono/node-server": "2.1.3",
55
+ "@lowdefy/actions-core": "7.3.0",
56
+ "@lowdefy/api": "7.3.0",
57
+ "@lowdefy/block-utils": "7.3.0",
58
+ "@lowdefy/blocks-aggrid": "7.3.0",
59
+ "@lowdefy/blocks-antd": "7.3.0",
60
+ "@lowdefy/blocks-antd-x": "7.3.0",
61
+ "@lowdefy/blocks-basic": "7.3.0",
62
+ "@lowdefy/blocks-captcha": "7.3.0",
63
+ "@lowdefy/blocks-echarts": "7.3.0",
64
+ "@lowdefy/blocks-files": "7.3.0",
65
+ "@lowdefy/blocks-loaders": "7.3.0",
66
+ "@lowdefy/blocks-markdown": "7.3.0",
67
+ "@lowdefy/blocks-table": "7.3.0",
68
+ "@lowdefy/blocks-tiptap": "7.3.0",
69
+ "@lowdefy/client": "7.3.0",
70
+ "@lowdefy/connection-anthropic": "7.3.0",
71
+ "@lowdefy/errors": "7.3.0",
72
+ "@lowdefy/helpers": "7.3.0",
73
+ "@lowdefy/layout": "7.3.0",
74
+ "@lowdefy/logger": "7.3.0",
75
+ "@lowdefy/node-utils": "7.3.0",
76
+ "@lowdefy/operators-js": "7.3.0",
77
+ "@lowdefy/operators-nunjucks": "7.3.0",
78
+ "@lowdefy/plugin-better-auth": "7.3.0",
79
+ "@lowdefy/websockets-core": "7.3.0",
80
80
  "@sentry/browser": "10.57.0",
81
81
  "@sentry/node": "10.57.0",
82
82
  "@sentry/node-core": "10.57.0",
@@ -86,21 +86,20 @@
86
86
  "antd": "6.6.5",
87
87
  "better-auth": "1.7.7",
88
88
  "dayjs": "1.11.20",
89
- "hono": "4.13.7",
89
+ "hono": "4.13.14",
90
90
  "lightningcss": "1.32.0",
91
91
  "react": "18.2.0",
92
92
  "react-dom": "18.2.0",
93
93
  "tailwindcss": "4.3.3",
94
94
  "uuid": "14.0.0",
95
- "vite": "8.0.16",
95
+ "vite": "8.1.6",
96
96
  "ws": "8.21.0"
97
97
  },
98
98
  "devDependencies": {
99
- "@jest/globals": "28.1.3",
100
- "@lowdefy/build": "7.1.0",
99
+ "@lowdefy/build": "7.3.0",
101
100
  "@tailwindcss/postcss": "4.3.3",
102
- "jest": "28.1.3",
103
101
  "tailwindcss": "4.3.3",
102
+ "vitest": "4.1.12",
104
103
  "yaml": "2.9.0",
105
104
  "yargs": "18.0.0"
106
105
  },
package/src/app.js CHANGED
@@ -16,6 +16,7 @@
16
16
 
17
17
  import { Hono } from 'hono';
18
18
  import { bodyLimit } from 'hono/body-limit';
19
+ import { etag } from 'hono/etag';
19
20
  import { compress } from 'hono/compress';
20
21
  import { serveStatic } from '@hono/node-server/serve-static';
21
22
  import { runInCredentialScope } from '@lowdefy/node-utils';
@@ -34,9 +35,13 @@ import cronHandler from './routes/cron.js';
34
35
  import detachedHandler from './routes/detached.js';
35
36
  import endpointsHandler from './routes/endpoints.js';
36
37
  import getAuth from '../lib/server/auth/getAuth.js';
38
+ import getRequestSurface from './lib/getRequestSurface.js';
37
39
  import getStrategies from '../lib/server/auth/getStrategies.js';
38
40
  import lowdefyConfig from '../lib/build/config.js';
39
41
  import mcpHandler from './routes/mcp.js';
42
+ import mobileConfig from '../lib/build/mobileConfig.js';
43
+ import mobileRootHandler from './routes/mobileRoot.js';
44
+ import mountMobileWellKnown from './routes/mountMobileWellKnown.js';
40
45
  import mountOauthDiscovery from './routes/mountOauthDiscovery.js';
41
46
  import mountPageRoutes from './routes/mountPageRoutes.js';
42
47
  import noStore from './middleware/noStore.js';
@@ -123,14 +128,15 @@ function createApp({ serveStaticAssets = true, clientAddressHeader } = {}) {
123
128
  app,
124
129
  auth: authJson.configured === true ? getAuth({ logger }) : null,
125
130
  });
131
+ mountMobileWellKnown({ app, basePath, mobileConfig });
126
132
  app.all('/.well-known/*', wellKnownFallbackHandler);
127
133
 
128
134
  app.use('/api/*', apiContext({ clientAddressHeader }));
129
135
  // Responses that carry the caller's data are never stored by a browser or proxy cache.
130
136
  // Static assets keep their own caching below; the page routes use the same middleware.
131
137
  const noStoreMiddleware = noStore();
132
- ['/api/page/*', '/api/user', '/api/request/*', '/api/endpoints/*'].forEach((route) =>
133
- app.use(route, noStoreMiddleware)
138
+ ['/api/page/*', '/api/mobile/root', '/api/user', '/api/request/*', '/api/endpoints/*'].forEach(
139
+ (route) => app.use(route, noStoreMiddleware)
134
140
  );
135
141
  // A tab left open across a deploy (or restored from the browser cache) runs
136
142
  // the old bundle against this build: see refuseOtherBuild and stampBuildId.
@@ -142,6 +148,16 @@ function createApp({ serveStaticAssets = true, clientAddressHeader } = {}) {
142
148
  app.use('/api/request/*', stampCaller());
143
149
  app.use('/api/endpoints/*', stampCaller());
144
150
  app.use('/api/page/*', stampCaller());
151
+ app.use('/api/mobile/root', stampCaller());
152
+ // A shell revalidates the pages and root config it keeps with If-None-Match.
153
+ // Registered inside noStore and stampCaller, so a 304 still carries both.
154
+ // Browsers never revalidate a no-store page, so their page responses are
155
+ // left as they were, with no ETag.
156
+ const etagMiddleware = etag();
157
+ app.use('/api/page/*', (c, next) =>
158
+ getRequestSurface(c) === 'mobile' ? etagMiddleware(c, next) : next()
159
+ );
160
+ app.use('/api/mobile/root', etagMiddleware);
145
161
  app.all('/api/request/*', refuseOtherBuild({ buildId: appMeta.buildId }), requestHandler);
146
162
  // Endpoint payloads may carry base64 file content (emitFileContent + CallAPI);
147
163
  // cap bodies at 10 MiB to match the agent route.
@@ -160,6 +176,7 @@ function createApp({ serveStaticAssets = true, clientAddressHeader } = {}) {
160
176
  app.all('/api/mcp', bodyLimit({ maxSize: 10 * 1024 * 1024 }), mcpHandler);
161
177
  app.get('/api/websocket', websocketHandler);
162
178
  app.get('/api/page/*', apiPageHandler);
179
+ app.get('/api/mobile/root', mobileRootHandler);
163
180
  app.get('/api/user', userHandler);
164
181
 
165
182
  // Vite build output (includes public/ via Vite's publicDir copy). Falls