@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
@@ -33,7 +33,8 @@ const upgrade = upgradeWebSocket((c) => {
33
33
  return {
34
34
  onOpen(event, ws) {
35
35
  // The upgrade's headers stay with the connection: its caller is resolved
36
- // from them again while the socket is open.
36
+ // from them again while the socket is open - a browser's session cookie,
37
+ // or a phone shell's "Authorization: Bearer" session, read the same way.
37
38
  connection = createWebSocketConnection(context, {
38
39
  closeSocket: ({ code, reason }) => ws.close(code, reason),
39
40
  headers: c.req.raw.headers,
@@ -57,7 +58,8 @@ const upgrade = upgradeWebSocket((c) => {
57
58
  });
58
59
 
59
60
  // Upgrades are accepted from the app's own pages and from clients that send no
60
- // Origin; isWebSocketOriginAllowed holds the rule and logs a refusal.
61
+ // Origin (a phone shell sends the app's own); isWebSocketOriginAllowed holds the
62
+ // rule and logs a refusal.
61
63
  function websocketHandler(c, next) {
62
64
  const context = c.get('lowdefyContext');
63
65
  if (!isWebSocketOriginAllowed({ context, getHeader: (name) => c.req.header(name) })) {
@@ -15,11 +15,11 @@
15
15
  */
16
16
 
17
17
  import { Hono } from 'hono';
18
- import { jest } from '@jest/globals';
18
+ import { vi, afterAll, beforeAll, expect, test } from 'vitest';
19
19
  import { serve } from '@hono/node-server';
20
20
  import WebSocket, { WebSocketServer } from 'ws';
21
21
 
22
- jest.unstable_mockModule('../../lib/server/auth/getStrategies.js', () => ({
22
+ vi.doMock('../../lib/server/auth/getStrategies.js', () => ({
23
23
  default: () => [],
24
24
  }));
25
25
 
@@ -1,37 +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 { mapPlainValues } from '@lowdefy/helpers';
18
-
19
- // `received` is the one kept log field holding values fetched at runtime (a token
20
- // from an earlier step sent as a header), which the by-value secret scrub
21
- // cannot recognise, so credential-looking keys are masked by name instead.
22
- const credentialKeyParts = ['authorization', 'token', 'secret', 'password', 'apikey', 'cookie'];
23
-
24
- function isCredentialKey(key) {
25
- const normalized = key.toLowerCase().replace(/[-_]/g, '');
26
- return credentialKeyParts.some((part) => normalized.includes(part));
27
- }
28
-
29
- // Shared references and cycles are copied as such, so the serializer walk still
30
- // marks them '[Circular]'.
31
- function maskCredentialKeys(value) {
32
- return mapPlainValues(value, (item, key) =>
33
- key !== undefined && isCredentialKey(key) ? '[REDACTED]' : item
34
- );
35
- }
36
-
37
- export default maskCredentialKeys;