Files
cfw-autumn/server/src/internal/auth/oauth/handleGetOAuthClient.ts
imeepos a98f11c214 refactor: pass env explicitly across all remaining request-path modules
- Remove last runtimeEnv import from processMessage.ts
- Add env: Env param to all functions with 'Cannot find name env' errors
- Convert initRedisV2 to lazy initialization (ensureRedisV2 + Proxy)
- Add Bindings: Env to StripeWebhookHonoEnv
- Fix 12+ files across external/, internal/, queue/ modules
- Scanning test passes: 1/1 (runtime-env-imports.test.ts)
2026-06-17 07:08:41 -07:00

42 lines
1.2 KiB
TypeScript

import type { Context } from "hono";
import { db } from "@/db/initDrizzle.js";
import type { HonoEnv } from "@/honoUtils/HonoEnv.js";
import { oauthClientRepo } from "../repos/index.js";
import { isAtmnOAuthClientRecord } from "./atmnOAuthClients.js";
import {
getInternalMcpDisplayName,
isInternalMcpOAuthClientRecord,
} from "./internalMcpOAuthClients.js";
export const handleGetOAuthClient = async (c: Context<HonoEnv>) => {
const clientId = c.req.param("client_id");
const redirectUri = c.req.query("redirect_uri");
if (!clientId) {
return c.json({ error: "client_id is required" }, 400);
}
const client = await oauthClientRepo.getByClientId({ db, clientId });
if (!client) {
return c.json({ error: "Client not found" }, 404);
}
const isInternalMcp = isInternalMcpOAuthClientRecord({
env: c.env,
...client,
});
const internalMcpName = isInternalMcp
? getInternalMcpDisplayName({
metadata: client.metadata,
redirectUri,
})
: null;
return c.json({
client_id: client.clientId,
name: internalMcpName || client.name || "Unknown Application",
is_atmn: isAtmnOAuthClientRecord({ env: c.env, ...client }),
is_internal_mcp: isInternalMcp,
});
};