Files
openchamber/packages/web/server/lib/opencode/bootstrap-runtime.js
T
Dave OteroandBohdan Triapitsyn 75a10ea66c Add passkey login for protected UI (#845)
* feat(auth): add passkey login for protected UI

* fix: polish passkey setup and correct WebAuthn user IDs

* feat: improve passkey login management

* build: align passkey deps with upstream main

* refactor: move ui auth out of opencode module

---------

Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
2026-04-11 22:36:02 +03:00

129 lines
3.2 KiB
JavaScript

export const createBootstrapRuntime = (dependencies) => {
const {
createUiAuth,
registerServerStatusRoutes,
registerCommonRequestMiddleware,
registerAuthAndAccessRoutes,
registerTtsRoutes,
registerNotificationRoutes,
registerOpenChamberRoutes,
express,
} = dependencies;
const setupBaseRoutes = (app, options) => {
const {
process,
openchamberVersion,
runtimeName,
serverStartedAt,
gracefulShutdown,
getHealthSnapshot,
uiPassword,
tunnelAuthController,
readSettingsFromDiskMigrated,
normalizeTunnelSessionTtlMs,
resolveZenModel,
sayTTSCapability,
ensurePushInitialized,
ensureGlobalWatcherStarted,
getOrCreateVapidKeys,
getUiSessionTokenFromRequest,
writeSettingsToDisk,
addOrUpdatePushSubscription,
removePushSubscription,
updateUiVisibility,
isUiVisible,
getUiNotificationClients,
writeSseEvent,
sessionRuntime,
setPushInitialized,
fs,
os,
path,
server,
__dirname,
openchamberDataDir,
modelsDevApiUrl,
modelsMetadataCacheTtl,
fetchFreeZenModels,
getCachedZenModels,
} = options;
registerServerStatusRoutes(app, {
process,
openchamberVersion,
runtimeName,
serverStartedAt,
gracefulShutdown,
getHealthSnapshot,
});
registerCommonRequestMiddleware(app, { express });
const uiAuthController = createUiAuth({
password: uiPassword,
readSettingsFromDiskMigrated,
});
if (uiAuthController.enabled) {
console.log('UI password protection enabled for browser sessions');
}
registerAuthAndAccessRoutes(app, {
tunnelAuthController,
uiAuthController,
readSettingsFromDiskMigrated,
normalizeTunnelSessionTtlMs,
});
registerTtsRoutes(app, { resolveZenModel, sayTTSCapability });
registerNotificationRoutes(app, {
uiAuthController,
ensurePushInitialized,
ensureGlobalWatcherStarted,
getOrCreateVapidKeys,
getUiSessionTokenFromRequest,
readSettingsFromDiskMigrated,
writeSettingsToDisk,
addOrUpdatePushSubscription,
removePushSubscription,
updateUiVisibility,
isUiVisible,
getUiNotificationClients,
writeSseEvent,
getSessionActivitySnapshot: sessionRuntime.getSessionActivitySnapshot,
getSessionStateSnapshot: sessionRuntime.getSessionStateSnapshot,
getSessionAttentionSnapshot: sessionRuntime.getSessionAttentionSnapshot,
getSessionState: sessionRuntime.getSessionState,
getSessionAttentionState: sessionRuntime.getSessionAttentionState,
markSessionViewed: sessionRuntime.markSessionViewed,
markSessionUnviewed: sessionRuntime.markSessionUnviewed,
markUserMessageSent: sessionRuntime.markUserMessageSent,
setPushInitialized,
});
registerOpenChamberRoutes(app, {
fs,
os,
path,
process,
server,
__dirname,
openchamberDataDir,
modelsDevApiUrl,
modelsMetadataCacheTtl,
readSettingsFromDiskMigrated,
fetchFreeZenModels,
getCachedZenModels,
});
return {
uiAuthController,
};
};
return {
setupBaseRoutes,
};
};