@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.
- package/client/clientBuildImports.test.mjs +1 -0
- package/client/getShownPage.test.mjs +1 -0
- package/client/shouldReloadForTypes.test.mjs +1 -0
- package/lib/build/mobileConfig.js +26 -0
- package/lib/client/auth/AuthConfigured.jsx +75 -48
- package/lib/client/auth/createFetchCheckingBuild.test.mjs +3 -3
- package/lib/client/auth/sessionCaller.js +56 -0
- package/lib/client/createLogUsage.test.mjs +2 -2
- package/lib/server/getClientAddress.test.mjs +6 -7
- package/lib/server/log/createHandleError.test.mjs +5 -5
- package/lib/server/log/createLogger.test.mjs +3 -3
- package/lib/server/log/projectErrorForLog.js +6 -4
- package/lib/server/log/redactUrlQuery.test.mjs +1 -0
- package/lib/server/log/serializeErrorForLog.test.mjs +50 -113
- package/lib/server/sentry/captureSentryError.test.mjs +4 -7
- package/lib/server/sentry/initSentry.serverless.test.mjs +6 -6
- package/lib/server/sentry/initSentry.test.mjs +3 -3
- package/lib/server/sentry/scrubEvent.test.mjs +2 -0
- package/lowdefy/build.mjs +4 -1
- package/lowdefy/build.test.mjs +11 -13
- package/lowdefy/createCustomPluginMessagesMap.mjs +2 -4
- package/lowdefy/createCustomPluginTypesMap.mjs +39 -11
- package/lowdefy/createCustomPluginTypesMap.test.mjs +249 -0
- package/package.json +32 -33
- package/package.original.json +32 -33
- package/src/app.js +19 -2
- package/src/app.mobile.test.mjs +351 -0
- package/src/app.test.mjs +31 -27
- package/src/app.timeout.test.mjs +141 -0
- package/src/html/collectPageTypesAssets.test.mjs +1 -0
- package/src/html/getPageAssets.test.mjs +1 -0
- package/src/html/renderPage.contentSecurityPolicy.test.mjs +13 -10
- package/src/html/renderPage.test.mjs +16 -13
- package/src/html/template.test.mjs +1 -0
- package/src/initServer.test.mjs +12 -12
- package/src/lib/getPathSegments.js +16 -1
- package/src/lib/getRequestSurface.js +25 -0
- package/src/middleware/apiContext.js +7 -4
- package/src/middleware/apiContext.test.mjs +48 -30
- package/src/middleware/createSameOriginGuard.test.mjs +1 -0
- package/src/middleware/errorHandler.js +33 -45
- package/src/middleware/errorHandler.test.mjs +11 -11
- package/src/middleware/refuseOtherBuild.test.mjs +3 -3
- package/src/middleware/requestTimeout.js +7 -1
- package/src/middleware/stampBuildId.test.mjs +1 -0
- package/src/middleware/stampCaller.test.mjs +1 -0
- package/src/routes/agentBearer.test.mjs +175 -0
- package/src/routes/apiPage.js +12 -1
- package/src/routes/apiPage.test.mjs +5 -5
- package/src/routes/auth.test.mjs +6 -6
- package/src/routes/clientError.js +14 -2
- package/src/routes/clientError.test.mjs +106 -0
- package/src/routes/endpoints.js +24 -0
- package/src/routes/endpointsLink.test.mjs +112 -0
- package/src/routes/endpointsTextAnswer.test.mjs +8 -8
- package/src/routes/mcp.js +6 -0
- package/src/routes/mcp.test.mjs +23 -8
- package/src/routes/mcpMemberToken.test.mjs +8 -8
- package/src/routes/mcpProtectedResourceMetadata.test.mjs +2 -2
- package/src/routes/mobileRoot.js +30 -0
- package/src/routes/mobileSignIn.js +46 -0
- package/src/routes/mobileSignIn.test.mjs +58 -0
- package/src/routes/mobileSignInCallback.js +34 -0
- package/src/routes/mobileSignInCallback.test.mjs +51 -0
- package/src/routes/mountMobileWellKnown.js +35 -0
- package/src/routes/mountMobileWellKnown.test.mjs +79 -0
- package/src/routes/mountOauthDiscovery.test.mjs +5 -5
- package/src/routes/mountPageRoutes.js +9 -2
- package/src/routes/mountPageRoutes.test.mjs +33 -3
- package/src/routes/normalizeMcpProtocolVersionHeader.test.mjs +1 -0
- package/src/routes/requestBody.test.mjs +12 -12
- package/src/routes/websocket.js +4 -2
- package/src/routes/websocket.test.mjs +2 -2
- package/lib/server/log/maskCredentialKeys.js +0 -37
package/src/routes/websocket.js
CHANGED
|
@@ -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
|
|
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 {
|
|
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
|
-
|
|
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;
|