R21.3: delete the unreachable registered-app resolution path

The runtime app-registration writer (POST /v1/apps) was deleted in an
earlier pass because it minted a client_secret nobody verified. This
pass kept resolveAppProfile's registered-app fallback and
listAppProfiles on the theory that AppSlug is an open string and
dynamic registration was a live extension point. Soul falsified that:
every HTTP route enumerates the four built-in slugs in its own JSON
schema (app.ts's `enum: [...appSlugs]` at every appSlug param/body
field), so a registered row could never be resolved from a request.
With the writer already gone, this was unreachable code behind a dead
writer -- delete it rather than keep authenticating a door nobody can
open.

Deleted: src/app-registry.ts entirely (resolveAppProfile,
listAppProfiles, isBuiltInApp, registeredAppToProfile,
returnOriginsFromRedirectUris); StoredRegisteredApp and the
findRegisteredApp/listRegisteredApps HeimdallStore methods
(store/types.ts); their InMemoryStore and PostgresStore
implementations, including seedRegisteredApp and mapRegisteredApp; the
registered_apps table (store/schema.ts now drops it on any store built
before this schema); tests/app-registry.test.ts.

Every call site (app.ts x5, claims.ts, private-command-plane.ts) now
calls the existing built-in-only getAppProfile (app-profiles.ts)
directly -- sync, no store needed. If dynamic app registration is
wanted later it returns as a designed, authenticated feature, not by
resurrecting this vestige.

Net -305 lines against the prior commit.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-09-08 14:51:23 +02:00
commit e21659cd31
11 changed files with 33 additions and 338 deletions

View file

@ -9,12 +9,11 @@ import {
import { type FastifyInstance } from "fastify";
import { getHeimdallRuntimeContext, refreshAppSession, startOAuthFlow, verifyRefreshToken } from "./app.js";
import { callerFromOpenedEnvelope } from "./app-caller.js";
import { resolveAppProfile } from "./app-registry.js";
import { getAppProfile } from "./app-profiles.js";
import { executeHeimdallAccessPlugin, HEIMDALL_ACCESS_PLUGIN_ID, type EvePluginAbiRequest } from "./access-plugin.js";
import { isAppSlug, oauthModes, providers, type AppSlug, type OAuthEntitlementPolicy, type OAuthMode, type Provider } from "./contracts.js";
import { type HeimdallConfig } from "./config.js";
import { openPrivateEnvelope, sealPrivateEnvelope, type HeimdallPrivateEnvelope } from "./private-command-security.js";
import { type HeimdallStore } from "./store/types.js";
export const HEIMDALL_PRIVATE_COMMAND_SERVICE = "heimdall.private.commands";
export const HEIMDALL_PRIVATE_ENVELOPE_SCHEMA = "heimdall.private_command_envelope.v1";
@ -228,7 +227,7 @@ async function refreshAuth(
// handler function the HTTP route uses rather than forging the HTTP header
// back at itself.
const context = getHeimdallRuntimeContext(app);
await requireEntitlementPolicyIfProfileDemandsIt(context.store, appSlug, entitlementPolicy, "refresh");
await requireEntitlementPolicyIfProfileDemandsIt(appSlug, entitlementPolicy, "refresh");
const result = await refreshAppSession(context, appSlug, callerFromOpenedEnvelope(appSlug), {
refreshToken,
...(entitlementPolicy ? { entitlementPolicy } : {}),
@ -264,7 +263,7 @@ async function beginAuth(
if (!providers.includes(provider) || !oauthModes.includes(mode) || !returnTo) throw new Error("Auth begin payload is incomplete.");
const entitlementPolicy = parseEntitlementPolicy(payload.entitlementPolicy);
const store = getHeimdallRuntimeContext(app).store;
await requireEntitlementPolicyIfProfileDemandsIt(store, appSlug, entitlementPolicy, "authentication");
await requireEntitlementPolicyIfProfileDemandsIt(appSlug, entitlementPolicy, "authentication");
const now = new Date();
const attempt = await store.createAuthAttempt({
handle: randomUUID(),
@ -392,12 +391,11 @@ function parseEntitlementPolicy(value: unknown): OAuthEntitlementPolicy | undefi
* need declares it in its profile instead of adding another branch.
*/
async function requireEntitlementPolicyIfProfileDemandsIt(
store: HeimdallStore,
appSlug: AppSlug,
entitlementPolicy: OAuthEntitlementPolicy | undefined,
action: "authentication" | "refresh",
): Promise<void> {
const profile = await resolveAppProfile(store, appSlug);
const profile = getAppProfile(appSlug);
const requiredKind = profile?.requiredEntitlementPolicyKind;
if (requiredKind && entitlementPolicy?.kind !== requiredKind) {
throw new Error(`${appSlug} ${action} requires its caller-owned ${requiredKind} policy.`);