From ef61f40885beed085781480196a9aa38eabf9d27 Mon Sep 17 00:00:00 2001 From: sacOO7 Date: Thu, 16 Apr 2026 19:33:53 +0530 Subject: [PATCH] Fix keys revoke API endpoint to use POST /revoke instead of DELETE --- src/services/control-api.ts | 9 +++++++-- test/unit/commands/auth/keys/revoke.test.ts | 6 +++--- test/unit/services/control-api.test.ts | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/services/control-api.ts b/src/services/control-api.ts index 9b04e5e34..5565dc1d8 100644 --- a/src/services/control-api.ts +++ b/src/services/control-api.ts @@ -423,7 +423,7 @@ export class ControlApi { // Revoke a key async revokeKey(appId: string, keyId: string): Promise { - return this.request(`/apps/${appId}/keys/${keyId}`, "DELETE"); + return this.request(`/apps/${appId}/keys/${keyId}/revoke`, "POST"); } // Update an app @@ -588,6 +588,11 @@ export class ControlApi { return {} as T; } - return (await response.json()) as T; + const text = await response.text(); + if (!text) { + return {} as T; + } + + return JSON.parse(text) as T; } } diff --git a/test/unit/commands/auth/keys/revoke.test.ts b/test/unit/commands/auth/keys/revoke.test.ts index 8cf3766b4..94c26dfa4 100644 --- a/test/unit/commands/auth/keys/revoke.test.ts +++ b/test/unit/commands/auth/keys/revoke.test.ts @@ -37,7 +37,7 @@ describe("auth:keys:revoke command", () => { // Mock revoke key nockControl() - .delete(`/v1/apps/${appId}/keys/${mockKeyId}`) + .post(`/v1/apps/${appId}/keys/${mockKeyId}/revoke`) .reply(200, {}); const { stdout } = await runCommand( @@ -59,7 +59,7 @@ describe("auth:keys:revoke command", () => { ]); nockControl() - .delete(`/v1/apps/${appId}/keys/${mockKeyId}`) + .post(`/v1/apps/${appId}/keys/${mockKeyId}/revoke`) .reply(200, {}); const { stdout } = await runCommand( @@ -76,7 +76,7 @@ describe("auth:keys:revoke command", () => { mockKeysList(appId, [buildMockKey(appId, mockKeyId)]); nockControl() - .delete(`/v1/apps/${appId}/keys/${mockKeyId}`) + .post(`/v1/apps/${appId}/keys/${mockKeyId}/revoke`) .reply(200, {}); const { stdout } = await runCommand( diff --git a/test/unit/services/control-api.test.ts b/test/unit/services/control-api.test.ts index 6f5c98103..d4985543e 100644 --- a/test/unit/services/control-api.test.ts +++ b/test/unit/services/control-api.test.ts @@ -362,7 +362,7 @@ describe("ControlApi", function () { // Set up nock to intercept request nock(`https://${controlHost}`) - .delete(`/v1/apps/${appId}/keys/${keyId}`) + .post(`/v1/apps/${appId}/keys/${keyId}/revoke`) .reply(500, { message: "Failed to revoke key" }); // Intercept any calls to /me