Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

refactor(open-knowledge): remove dead GET /api/local-op/auth/identity endpoint (#1739)

Andrew Mikofalvye59dc71be086
diff --git a/packages/app/tests/integration/api-error-envelope/local-op-auth-identity.test.ts b/packages/app/tests/integration/api-error-envelope/local-op-auth-identity.test.ts
deleted file mode 100644
index eae538e98..000000000
--- a/packages/app/tests/integration/api-error-envelope/local-op-auth-identity.test.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
-import {
- LocalOpAuthIdentitySuccessSchema,
- ProblemDetailsSchema,
-} from '@inkeep/open-knowledge-core';
-import { createTestServer, type TestServer } from '../test-harness';
-
-let server: TestServer;
-
-beforeAll(async () => {
- server = await createTestServer();
-});
-
-afterAll(async () => {
- await server.cleanup();
-});
-
-describe('local-op-auth-identity envelope (RFC 9457, US-012)', () => {
- test('happy path returns flat { identity } with application/json', async () => {
- const res = await fetch(`http://127.0.0.1:${server.port}/api/local-op/auth/identity`, {
- method: 'GET',
- });
- expect(res.status).toBe(200);
- expect(res.headers.get('content-type')).toBe('application/json');
- const body = await res.json();
- const parsed = LocalOpAuthIdentitySuccessSchema.safeParse(body);
- expect(parsed.success).toBe(true);
- expect((body as Record<string, unknown>).ok).toBeUndefined();
- });
-
- test('method-not-allowed on POST emits problem+json with Allow: GET', async () => {
- const res = await fetch(`http://127.0.0.1:${server.port}/api/local-op/auth/identity`, {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({}),
- });
- expect(res.status).toBe(405);
- expect(res.headers.get('allow')).toBe('GET');
- const body = await res.json();
- const parsed = ProblemDetailsSchema.safeParse(body);
- expect(parsed.success).toBe(true);
- if (parsed.success) {
- expect(parsed.data.type).toBe('urn:ok:error:method-not-allowed');
- }
- });
-});
diff --git a/packages/app/tests/integration/attribution-sweep-coverage.test.ts b/packages/app/tests/integration/attribution-sweep-coverage.test.ts
index 56b07c63a..2693d351c 100644
--- a/packages/app/tests/integration/attribution-sweep-coverage.test.ts
+++ b/packages/app/tests/integration/attribution-sweep-coverage.test.ts
@@ -80,7 +80,6 @@ const EXEMPT_HANDLERS = new Set([
'handleLocalOpAuthStatus',
'handleLocalOpAuthRepos',
'handleLocalOpAuthSignout',
- 'handleLocalOpAuthIdentity',
'handleLocalOpAuthSetIdentity',
'handleLocalOpEmbeddingsSetKey',
'handleLocalOpEmbeddingsClearKey',
diff --git a/packages/app/tests/integration/conflict-gate-coverage.test.ts b/packages/app/tests/integration/conflict-gate-coverage.test.ts
index 331790dd4..96558e786 100644
--- a/packages/app/tests/integration/conflict-gate-coverage.test.ts
+++ b/packages/app/tests/integration/conflict-gate-coverage.test.ts
@@ -70,7 +70,6 @@ const EXEMPT_HANDLERS = new Set([
'handleLocalOpAuthStatus',
'handleLocalOpAuthRepos',
'handleLocalOpAuthSignout',
- 'handleLocalOpAuthIdentity',
'handleLocalOpAuthSetIdentity',
'handleLocalOpEmbeddingsSetKey',
'handleLocalOpEmbeddingsClearKey',
diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts
index 4696a7392..91c86756f 100644
--- a/packages/core/src/index.ts
+++ b/packages/core/src/index.ts
@@ -583,10 +583,6 @@ export {
LocalOpAuthEmptySuccessSchema,
type LocalOpAuthHostRequest,
LocalOpAuthHostRequestSchema,
- type LocalOpAuthIdentity,
- LocalOpAuthIdentitySchema,
- type LocalOpAuthIdentitySuccess,
- LocalOpAuthIdentitySuccessSchema,
type LocalOpAuthSetIdentityRequest,
LocalOpAuthSetIdentityRequestSchema,
type LocalOpAuthStatusSuccess,
diff --git a/packages/core/src/schemas/api/local-op.test.ts b/packages/core/src/schemas/api/local-op.test.ts
index 34dfabfff..d6047bed7 100644
--- a/packages/core/src/schemas/api/local-op.test.ts
+++ b/packages/core/src/schemas/api/local-op.test.ts
@@ -2,8 +2,6 @@ import { describe, expect, test } from 'bun:test';
import {
LocalOpAuthEmptySuccessSchema,
LocalOpAuthHostRequestSchema,
- LocalOpAuthIdentitySchema,
- LocalOpAuthIdentitySuccessSchema,
LocalOpAuthSetIdentityRequestSchema,
LocalOpAuthStatusSuccessSchema,
LocalOpOpenRequestSchema,
@@ -106,36 +104,6 @@ describe('LocalOpAuthSetIdentityRequestSchema', () => {
});
});
-describe('LocalOpAuthIdentitySchema', () => {
- test('parses a populated identity', () => {
- expect(
- LocalOpAuthIdentitySchema.safeParse({ name: 'Alice', email: '[email protected]' }).success,
- ).toBe(true);
- });
- test('parses null', () => {
- expect(LocalOpAuthIdentitySchema.safeParse(null).success).toBe(true);
- });
- test('rejects empty name', () => {
- expect(LocalOpAuthIdentitySchema.safeParse({ name: '', email: '[email protected]' }).success).toBe(false);
- });
-});
-
-describe('LocalOpAuthIdentitySuccessSchema', () => {
- test('parses a populated identity', () => {
- expect(
- LocalOpAuthIdentitySuccessSchema.safeParse({
- identity: { name: 'Alice', email: '[email protected]' },
- }).success,
- ).toBe(true);
- });
- test('parses null identity', () => {
- expect(LocalOpAuthIdentitySuccessSchema.safeParse({ identity: null }).success).toBe(true);
- });
- test('rejects missing identity field', () => {
- expect(LocalOpAuthIdentitySuccessSchema.safeParse({}).success).toBe(false);
- });
-});
-
describe('LocalOpAuthStatusSuccessSchema', () => {
test('parses authenticated:true', () => {
expect(LocalOpAuthStatusSuccessSchema.safeParse({ authenticated: true }).success).toBe(true);
diff --git a/packages/core/src/schemas/api/local-op.ts b/packages/core/src/schemas/api/local-op.ts
index 841792b08..8d3c82573 100644
--- a/packages/core/src/schemas/api/local-op.ts
+++ b/packages/core/src/schemas/api/local-op.ts
@@ -77,22 +77,6 @@ export const LocalOpAuthSetIdentityRequestSchema = z
.loose() satisfies StandardSchemaV1;
export type LocalOpAuthSetIdentityRequest = z.infer<typeof LocalOpAuthSetIdentityRequestSchema>;
-export const LocalOpAuthIdentitySchema = z
- .object({
- name: z.string().min(1),
- email: z.string().min(1),
- })
- .loose()
- .nullable() satisfies StandardSchemaV1;
-export type LocalOpAuthIdentity = z.infer<typeof LocalOpAuthIdentitySchema>;
-
-export const LocalOpAuthIdentitySuccessSchema = z
- .object({
- identity: LocalOpAuthIdentitySchema,
- })
- .loose() satisfies StandardSchemaV1;
-export type LocalOpAuthIdentitySuccess = z.infer<typeof LocalOpAuthIdentitySuccessSchema>;
-
export const LocalOpAuthStatusSuccessSchema = z
.object({
authenticated: z.boolean(),
diff --git a/packages/server/src/api-extension.ts b/packages/server/src/api-extension.ts
index 437ddf03a..d07c7fe99 100644
--- a/packages/server/src/api-extension.ts
+++ b/packages/server/src/api-extension.ts
@@ -94,7 +94,6 @@ import {
LocalOpAuthEmptySuccessSchema,
type LocalOpAuthHostRequest,
LocalOpAuthHostRequestSchema,
- LocalOpAuthIdentitySuccessSchema,
LocalOpAuthSetIdentityRequestSchema,
LocalOpAuthStatusSuccessSchema,
type LocalOpCloneRequest,
@@ -379,7 +378,7 @@ import {
} from './git-branch-info.ts';
import { CHECKOUT_HANDLER_TAG, runCheckoutFlow } from './git-checkout.ts';
import { withParentLock } from './git-handle.ts';
-import { resolveGitIdentity, writeGitIdentity } from './git-identity.ts';
+import { writeGitIdentity } from './git-identity.ts';
import {
createStreamingErrorWriter,
errorResponse,
@@ -8657,44 +8656,6 @@ export function createApiExtension(options: ApiExtensionOptions): Extension {
},
);
- const HANDLE_LOCAL_OP_AUTH_IDENTITY = 'local-op-auth-identity';
- async function handleLocalOpAuthIdentity(
- req: IncomingMessage,
- res: ServerResponse,
- ): Promise<void> {
- if (!checkLocalOpSecurity(req, res, { handler: HANDLE_LOCAL_OP_AUTH_IDENTITY })) return;
- if (req.method !== 'GET') {
- errorResponse(res, 405, 'urn:ok:error:method-not-allowed', 'Method not allowed.', {
- handler: HANDLE_LOCAL_OP_AUTH_IDENTITY,
- extraHeaders: { Allow: 'GET' },
- });
- return;
- }
- if (!projectDir) {
- errorResponse(res, 503, 'urn:ok:error:no-project-dir', 'No project directory configured.', {
- handler: HANDLE_LOCAL_OP_AUTH_IDENTITY,
- });
- return;
- }
- try {
- const identity = await resolveGitIdentity(projectDir);
- successResponse(
- res,
- 200,
- LocalOpAuthIdentitySuccessSchema,
- { identity },
- {
- handler: HANDLE_LOCAL_OP_AUTH_IDENTITY,
- },
- );
- } catch (err) {
- errorResponse(res, 500, 'urn:ok:error:internal-server-error', 'Identity resolution failed.', {
- handler: HANDLE_LOCAL_OP_AUTH_IDENTITY,
- cause: err,
- });
- }
- }
-
const LOCAL_OP_AUTH_SET_IDENTITY_KEY = '/api/local-op/auth/set-identity';
const HANDLE_LOCAL_OP_AUTH_SET_IDENTITY = 'local-op-auth-set-identity';
@@ -11211,7 +11172,6 @@ export function createApiExtension(options: ApiExtensionOptions): Extension {
'/api/local-op/auth/status': handleLocalOpAuthStatus,
'/api/local-op/auth/repos': handleLocalOpAuthRepos,
'/api/local-op/auth/signout': handleLocalOpAuthSignout,
- '/api/local-op/auth/identity': handleLocalOpAuthIdentity,
'/api/local-op/auth/set-identity': handleLocalOpAuthSetIdentity,
'/api/local-op/embeddings/set-key': handleLocalOpEmbeddingsSetKey,
'/api/local-op/embeddings/clear-key': handleLocalOpEmbeddingsClearKey,