@betterportal/framework 11.0.13 → 11.0.16
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/lib/adapters/h3.d.ts +3 -1
- package/lib/adapters/h3.d.ts.map +1 -1
- package/lib/adapters/h3.js +53 -28
- package/lib/adapters/h3.js.map +1 -1
- package/lib/contracts/platformConfig.d.ts +134 -0
- package/lib/contracts/platformConfig.d.ts.map +1 -1
- package/lib/contracts/platformConfig.js +14 -0
- package/lib/contracts/platformConfig.js.map +1 -1
- package/lib/contracts/route.d.ts +2 -0
- package/lib/contracts/route.d.ts.map +1 -1
- package/lib/contracts/route.js +2 -0
- package/lib/contracts/route.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/runtime/auth/menu.d.ts +2 -2
- package/lib/runtime/auth/menu.d.ts.map +1 -1
- package/lib/runtime/auth/menu.js +6 -4
- package/lib/runtime/auth/menu.js.map +1 -1
- package/lib/runtime/auth/routePolicy.d.ts +35 -0
- package/lib/runtime/auth/routePolicy.d.ts.map +1 -0
- package/lib/runtime/auth/routePolicy.js +123 -0
- package/lib/runtime/auth/routePolicy.js.map +1 -0
- package/lib/runtime/llms.d.ts +8 -0
- package/lib/runtime/llms.d.ts.map +1 -1
- package/lib/runtime/llms.js +28 -20
- package/lib/runtime/llms.js.map +1 -1
- package/package.json +3 -3
package/lib/adapters/h3.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export interface H3RouterObservabilityOptions {
|
|
|
15
15
|
serviceId?: string;
|
|
16
16
|
/** Current installed instance used for URL resolution; evaluated after configuration/installation changes. */
|
|
17
17
|
resolveRouteServiceId?: () => string | undefined;
|
|
18
|
-
/** Resolve auth context for a request.
|
|
18
|
+
/** Resolve auth context for a request. Protected operations fail closed when no auth context is available. */
|
|
19
19
|
resolveAuth?: (event: BetterPortalEvent, route: RegisteredRoute) => Promise<H3AuthContext | undefined> | H3AuthContext | undefined;
|
|
20
20
|
/**
|
|
21
21
|
* Validate that the resolved (tenantId, appId) is allowed to use this service.
|
|
@@ -27,6 +27,8 @@ export interface H3RouterObservabilityOptions {
|
|
|
27
27
|
resolveContext?: (event: BetterPortalEvent, route: RegisteredRoute) => Promise<Partial<RuntimeRouteHandlerContext>> | Partial<RuntimeRouteHandlerContext>;
|
|
28
28
|
}
|
|
29
29
|
export interface H3AuthContext {
|
|
30
|
+
/** Concrete owning binding, resolved by the host from trusted scoped configuration. */
|
|
31
|
+
readonly permissionServiceId?: string | null;
|
|
30
32
|
readonly verifier?: JwtVerifier;
|
|
31
33
|
readonly serviceVerifier?: ServiceTokenVerifier;
|
|
32
34
|
readonly tenantId: string;
|
package/lib/adapters/h3.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"h3.d.ts","sourceRoot":"","sources":["../../src/adapters/h3.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"h3.d.ts","sourceRoot":"","sources":["../../src/adapters/h3.ts"],"names":[],"mappings":"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"}
|
package/lib/adapters/h3.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { effectiveRouteAuth, hasRoutePermissions, resolvePermissionServiceId } from "../runtime/auth/routePolicy.js";
|
|
1
2
|
import { createRouteResult, viewRouteResolver } from "../runtime/routeResult.js";
|
|
2
3
|
import { routeMountServicePath, safeServiceBaseUrl } from "../runtime/configProvider.js";
|
|
3
4
|
import { ElevationRequired, requireElevation, elevationResponse } from "../runtime/auth/elevation.js";
|
|
4
5
|
import { createEventStream, getRequestIP, getRequestURL } from "h3";
|
|
5
6
|
import { decodeFormBody } from "./formBody.js";
|
|
6
|
-
import { renderThemeLlmsDrop } from "../runtime/llms.js";
|
|
7
|
+
import { renderThemeLlmsDrop, ThemeLlmsDocumentPaths } from "../runtime/llms.js";
|
|
7
8
|
import { BetterPortalRouteChromeSchema } from "../contracts/chrome.js";
|
|
8
9
|
import { isStreamHandler } from "../contracts/streaming.js";
|
|
9
10
|
import { driveStream, driveStreamBuffered, ndjsonStreamResponse } from "../runtime/stream.js";
|
|
@@ -256,10 +257,24 @@ async function prepareSseContext(registryRoutes, dependencyAliases, route, event
|
|
|
256
257
|
return rejectUnallowedAppRoute(obs, route, "GET", extraContext, allowance.reason ?? "route_not_mounted_for_app");
|
|
257
258
|
}
|
|
258
259
|
const authResolved = await loadAuthContext(event, route, routerOptions, obs);
|
|
259
|
-
const
|
|
260
|
+
const owner = requestPermissionOwner(authResolved, routerOptions);
|
|
261
|
+
const apiAuth = effectiveRouteAuth(operation.auth, owner, route.viewId, "GET");
|
|
262
|
+
const authResult = await resolveRequestAuth(apiAuth, event, authResolved, route, "GET", owner, obs, operation.auth.permissions ?? []);
|
|
260
263
|
if (authResult.error) {
|
|
261
264
|
return coreJsonResponse({ error: authResult.error, status: authResult.status }, authResult.status, authResult.code ?? "auth.unclassified", authResult.error);
|
|
262
265
|
}
|
|
266
|
+
if (operation.auth.elevation) {
|
|
267
|
+
if (authResult.callerMode === "service")
|
|
268
|
+
return jsonResponse({ error: "Human authentication is required for elevation" }, 403);
|
|
269
|
+
try {
|
|
270
|
+
requireElevation(authResult.user, operation.auth.elevation);
|
|
271
|
+
}
|
|
272
|
+
catch (error) {
|
|
273
|
+
if (error instanceof ElevationRequired && authResolved)
|
|
274
|
+
return elevationResponse(error.requirement, { tenantId: authResolved.tenantId, appId: authResolved.appId, serviceId: routerOptions.serviceId, operationId: operation.operationId, method: "GET" });
|
|
275
|
+
throw error;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
263
278
|
const tenantApp = readTenantAppFromEvent(event);
|
|
264
279
|
if (tenantApp && routerOptions.validateTenantApp && !isBpManagementAuthRoute(route)) {
|
|
265
280
|
let validation;
|
|
@@ -818,7 +833,7 @@ function createRouteResolver(event, routes, extraContext, aliases, currentServic
|
|
|
818
833
|
absoluteApiPath: serviceBase ? renderUrl(path, { query, sse: input.sse }, serviceBase) : null,
|
|
819
834
|
absoluteViewPath: serviceBase ? renderUrl(path, options, serviceBase) : null,
|
|
820
835
|
absoluteUiPath: uiPath && appBase ? new URL(uiPath, appBase).toString() : null
|
|
821
|
-
}, resolve, input, "apiPath", { serviceId, method, access: target && access ? access(target.methodRoutes?.[method]?.auth ?? { required: false, permissions: [] }) : "unknown" });
|
|
836
|
+
}, resolve, input, "apiPath", { serviceId, method, access: target && access ? access(target.methodRoutes?.[method]?.auth ?? { required: false, permissions: [] }, serviceId, viewId, method) : "unknown" });
|
|
822
837
|
};
|
|
823
838
|
return resolve;
|
|
824
839
|
}
|
|
@@ -1004,7 +1019,7 @@ async function handleRouteRequest(registryRoutes, dependencyAliases, route, meth
|
|
|
1004
1019
|
return rejectUnallowedAppRoute(obs, route, method, extraContext, routeAllowance.reason ?? "route_not_mounted_for_app");
|
|
1005
1020
|
}
|
|
1006
1021
|
let presentationAccess = () => "unknown";
|
|
1007
|
-
const routeResolver = createRouteResolver(event, registryRoutes, extraContext, dependencyAliases, routerOptions.resolveRouteServiceId?.() ?? routerOptions.serviceId, { path: url.pathname, template: route.path, method, params, query: query },
|
|
1022
|
+
const routeResolver = createRouteResolver(event, registryRoutes, extraContext, dependencyAliases, routerOptions.resolveRouteServiceId?.() ?? routerOptions.serviceId, { path: url.pathname, template: route.path, method, params, query: query }, (...args) => presentationAccess(...args));
|
|
1008
1023
|
const earlyRenderContext = (status) => {
|
|
1009
1024
|
const renderer = rendererFromEvent(event);
|
|
1010
1025
|
return renderer ? createViewRenderContext(route, {
|
|
@@ -1018,10 +1033,11 @@ async function handleRouteRequest(registryRoutes, dependencyAliases, route, meth
|
|
|
1018
1033
|
}, dependencyAliases, renderer, "page", "page", undefined, status) : undefined;
|
|
1019
1034
|
};
|
|
1020
1035
|
// -- Auth resolution (per spec section 0.5) ----------------------
|
|
1021
|
-
const apiAuth = { ...methodRoute.auth, required: methodRoute.auth.required || !!methodRoute.auth.elevation };
|
|
1022
1036
|
const authResolved = await loadAuthContext(event, route, routerOptions, obs);
|
|
1023
|
-
const
|
|
1024
|
-
|
|
1037
|
+
const owner = requestPermissionOwner(authResolved, routerOptions);
|
|
1038
|
+
const apiAuth = effectiveRouteAuth(methodRoute.auth, owner, route.viewId, method);
|
|
1039
|
+
const authResult = await resolveRequestAuth(apiAuth, event, authResolved, route, method, owner, obs, methodRoute.auth.permissions ?? []);
|
|
1040
|
+
presentationAccess = (requirement, serviceId, viewId, method) => presentationRouteAccess(effectiveRouteAuth(requirement, serviceId, viewId, method), authResult.user, authResolved);
|
|
1025
1041
|
if (authResult.error) {
|
|
1026
1042
|
return renderAuthError(route, event, method, authResult.status, authResult.code ?? "auth.unclassified", authResult.error, authResult.requiredPermissions, earlyRenderContext(authResult.status));
|
|
1027
1043
|
}
|
|
@@ -1219,7 +1235,10 @@ async function handleRouteRequest(registryRoutes, dependencyAliases, route, meth
|
|
|
1219
1235
|
"bp.view.kind": requestedKind,
|
|
1220
1236
|
"bp.view.status": handlerStatus
|
|
1221
1237
|
}, () => statusRenderer.render(data, renderContext)));
|
|
1222
|
-
|
|
1238
|
+
// A declared service validation renderer can supply a local fragment.
|
|
1239
|
+
// Framework-owned/auth error pages use their separate status response path.
|
|
1240
|
+
const mode = representation.mode === "fragment" || requestedKind !== "page" ? "fragment" : "status";
|
|
1241
|
+
return htmlResponse(toHtmlString(html), handlerStatus, htmlContentType(mode, methodRoute.chrome));
|
|
1223
1242
|
}
|
|
1224
1243
|
// No specific renderer found.
|
|
1225
1244
|
if (!shouldFallThroughToDefaultRenderer(handlerStatus)) {
|
|
@@ -1400,6 +1419,12 @@ async function handleStreamSse(registryRoutes, dependencyAliases, route, handler
|
|
|
1400
1419
|
})();
|
|
1401
1420
|
return stream.send();
|
|
1402
1421
|
}
|
|
1422
|
+
function requestPermissionOwner(auth, options) {
|
|
1423
|
+
// null is an explicit rejection by the host; never replace it with a plugin alias.
|
|
1424
|
+
if (auth?.permissionServiceId !== undefined)
|
|
1425
|
+
return auth.permissionServiceId ?? "";
|
|
1426
|
+
return resolvePermissionServiceId(options.resolveRouteServiceId?.() ?? options.serviceId ?? "", auth?.serviceIdAliases) ?? "";
|
|
1427
|
+
}
|
|
1403
1428
|
async function loadAuthContext(event, route, routerOptions, obs) {
|
|
1404
1429
|
try {
|
|
1405
1430
|
return await routerOptions.resolveAuth?.(event, route);
|
|
@@ -1413,7 +1438,7 @@ async function loadAuthContext(event, route, routerOptions, obs) {
|
|
|
1413
1438
|
* Resolve authentication and authorization per spec section 0.5.
|
|
1414
1439
|
* Returns either a validated user (or undefined for anonymous) or an error.
|
|
1415
1440
|
*/
|
|
1416
|
-
async function resolveRequestAuth(apiAuth, event, authContext, route, method, obs) {
|
|
1441
|
+
async function resolveRequestAuth(apiAuth, event, authContext, route, method, permissionServiceId, obs, additionalPermissions = apiAuth.permissions) {
|
|
1417
1442
|
const required = apiAuth.required;
|
|
1418
1443
|
const primaryHeader = event.req.headers.get("authorization");
|
|
1419
1444
|
const secondaryHeader = event.req.headers.get("x-bp-service-authorization");
|
|
@@ -1426,6 +1451,10 @@ async function resolveRequestAuth(apiAuth, event, authContext, route, method, ob
|
|
|
1426
1451
|
: primary
|
|
1427
1452
|
? "user"
|
|
1428
1453
|
: undefined;
|
|
1454
|
+
const machineEnvelope = secondaryHeader !== null || Boolean(primary && isServiceToken(primary)) || event.req.headers.has("x-bp-service-id");
|
|
1455
|
+
if (machineEnvelope && (!primary || !callerMode || callerMode === "user")) {
|
|
1456
|
+
return { status: 401, error: "Incomplete service authentication envelope", code: "s2s.headers_missing" };
|
|
1457
|
+
}
|
|
1429
1458
|
if (!primary || !callerMode) {
|
|
1430
1459
|
if (required)
|
|
1431
1460
|
return { status: 401, error: "Authentication required", code: "auth.required" };
|
|
@@ -1433,12 +1462,12 @@ async function resolveRequestAuth(apiAuth, event, authContext, route, method, ob
|
|
|
1433
1462
|
}
|
|
1434
1463
|
const allowedCallers = apiAuth.callers ?? ["user"];
|
|
1435
1464
|
if (!allowedCallers.includes(callerMode)) {
|
|
1436
|
-
if (required)
|
|
1465
|
+
if (required || machineEnvelope)
|
|
1437
1466
|
return { status: 403, error: `${callerMode} callers are not allowed`, code: "auth.caller_not_allowed" };
|
|
1438
1467
|
return { status: 200 };
|
|
1439
1468
|
}
|
|
1440
1469
|
if (!authContext) {
|
|
1441
|
-
if (required)
|
|
1470
|
+
if (required || machineEnvelope)
|
|
1442
1471
|
return { status: 503, error: "Auth context unavailable", code: "auth.context_unavailable" };
|
|
1443
1472
|
return { status: 200 };
|
|
1444
1473
|
}
|
|
@@ -1455,21 +1484,24 @@ async function resolveRequestAuth(apiAuth, event, authContext, route, method, ob
|
|
|
1455
1484
|
return { status: 401, error: "S2S headers do not match the resolved tenant/app", code: "s2s.context_mismatch" };
|
|
1456
1485
|
}
|
|
1457
1486
|
if (!authContext.serviceVerifier) {
|
|
1458
|
-
|
|
1459
|
-
return { status: 503, error: "Service auth context unavailable", code: "s2s.verifier_unavailable" };
|
|
1460
|
-
return { status: 200 };
|
|
1487
|
+
return { status: 503, error: "Service auth context unavailable", code: "s2s.verifier_unavailable" };
|
|
1461
1488
|
}
|
|
1462
1489
|
const verifyService = async (token, mode) => {
|
|
1463
1490
|
try {
|
|
1464
|
-
|
|
1491
|
+
const claims = await authContext.serviceVerifier.verify(token, {
|
|
1465
1492
|
tenantId: authContext.tenantId,
|
|
1466
1493
|
appId: authContext.appId,
|
|
1467
1494
|
viewId: route.viewId,
|
|
1468
1495
|
method,
|
|
1469
1496
|
mode,
|
|
1470
1497
|
sourceServiceId,
|
|
1471
|
-
|
|
1498
|
+
// The exact approved binding/view/method is the machine baseline.
|
|
1499
|
+
requiredPermissions: additionalPermissions.flatMap((requirement) => requirement.permissions)
|
|
1472
1500
|
});
|
|
1501
|
+
if (!route.path.startsWith("/.well-known/") && claims.aud !== permissionServiceId) {
|
|
1502
|
+
return { status: 403, error: "Service access denied", code: "s2s.access_denied" };
|
|
1503
|
+
}
|
|
1504
|
+
return claims;
|
|
1473
1505
|
}
|
|
1474
1506
|
catch (err) {
|
|
1475
1507
|
obs?.logger.warn("Service token verification failed: {msg}", { msg: err.message });
|
|
@@ -1484,7 +1516,7 @@ async function resolveRequestAuth(apiAuth, event, authContext, route, method, ob
|
|
|
1484
1516
|
if (callerMode === "service") {
|
|
1485
1517
|
const serviceCaller = await verifyService(primary, "service");
|
|
1486
1518
|
if ("status" in serviceCaller)
|
|
1487
|
-
return
|
|
1519
|
+
return serviceCaller;
|
|
1488
1520
|
return { status: 200, serviceCaller, callerMode };
|
|
1489
1521
|
}
|
|
1490
1522
|
if (!secondary || isServiceToken(primary)) {
|
|
@@ -1501,7 +1533,7 @@ async function resolveRequestAuth(apiAuth, event, authContext, route, method, ob
|
|
|
1501
1533
|
: { status: 401, error: "Valid BP user token required", code: "s2s.delegated_token_invalid" };
|
|
1502
1534
|
const serviceCaller = await verifyService(secondary, "delegated");
|
|
1503
1535
|
if ("status" in serviceCaller)
|
|
1504
|
-
return
|
|
1536
|
+
return serviceCaller;
|
|
1505
1537
|
return { status: 200, user: userResult.user, serviceCaller, callerMode };
|
|
1506
1538
|
}
|
|
1507
1539
|
async function resolveUserRequestAuth(bearer, apiAuth, authContext, obs) {
|
|
@@ -1564,14 +1596,7 @@ async function resolveUserRequestAuth(bearer, apiAuth, authContext, obs) {
|
|
|
1564
1596
|
rootAppId: authContext.platformRoot?.appId ?? ""
|
|
1565
1597
|
});
|
|
1566
1598
|
}
|
|
1567
|
-
const
|
|
1568
|
-
const aliases = authContext.serviceIdAliases ?? {};
|
|
1569
|
-
const serviceIdsMatch = (grantServiceId, requiredServiceId) => grantServiceId === requiredServiceId
|
|
1570
|
-
|| aliases[grantServiceId] === requiredServiceId
|
|
1571
|
-
|| aliases[requiredServiceId] === grantServiceId;
|
|
1572
|
-
const ok = apiAuth.permissions.every((requirement) => requirement.permissions.every((action) => granted.some((grant) => serviceIdsMatch(grant.serviceId, requirement.serviceId)
|
|
1573
|
-
&& grant.viewId === requirement.viewId
|
|
1574
|
-
&& grant.permissions.includes(action))));
|
|
1599
|
+
const ok = hasRoutePermissions(claims, apiAuth, authContext.appAuthConfig, authContext.serviceIdAliases, authContext.platformRoot);
|
|
1575
1600
|
if (!ok) {
|
|
1576
1601
|
if (required) {
|
|
1577
1602
|
return {
|
|
@@ -1612,7 +1637,7 @@ function presentationRouteAccess(requirement, user, auth) {
|
|
|
1612
1637
|
return "unknown";
|
|
1613
1638
|
const grants = expandRolesToPermissions(user.roles, auth.appAuthConfig);
|
|
1614
1639
|
const aliases = auth.serviceIdAliases ?? {};
|
|
1615
|
-
if (!requirement.permissions.every(required => required.permissions.every(action => grants.some(grant => (grant.serviceId === required.serviceId || aliases[grant.serviceId] === required.serviceId
|
|
1640
|
+
if (!requirement.permissions.every(required => required.permissions.every(action => grants.some(grant => (grant.serviceId === required.serviceId || aliases[grant.serviceId] === required.serviceId)
|
|
1616
1641
|
&& grant.viewId === required.viewId && grant.permissions.includes(action)))))
|
|
1617
1642
|
return "noperm";
|
|
1618
1643
|
return "ok";
|
|
@@ -1782,7 +1807,7 @@ function applyBpHeadersToEvent(event, collector) {
|
|
|
1782
1807
|
export function registerBpWellKnownRoutes(app, manifest, bpSchema, options = {}) {
|
|
1783
1808
|
const resolveLlmsContext = options.llmsContext;
|
|
1784
1809
|
if (manifest.shell && resolveLlmsContext) {
|
|
1785
|
-
app.get(
|
|
1810
|
+
app.get(ThemeLlmsDocumentPaths.drop, (event) => {
|
|
1786
1811
|
const context = resolveLlmsContext(event);
|
|
1787
1812
|
return new Response(context ? renderThemeLlmsDrop(context, bpSchema) : "BetterPortal app context is not available yet.\n", {
|
|
1788
1813
|
status: context ? 200 : 404,
|