mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-11 05:11:49 +01:00
fix(tool-gateway): record an activity entry when a person reveals a gateway token
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d760cc6fee
commit
39f38a7f6c
2 files changed
+3
-3
No files matched your search
@@ -1582,6 +1582,8 @@ describe("connection management with production default agents", () => {
|
||||
const value = await revealed.json() as { token: string; pendingReveal: boolean; id: string };
|
||||
expect(value).toMatchObject({ id: created.data.id, pendingReveal: false, token: expect.stringMatching(new RegExp(`^pcgw_${created.data.id}\\.`)) });
|
||||
expect(await reveal()).toMatchObject({ status: 409 });
|
||||
expect(await server.db.select().from(activityLog).where(and(eq(activityLog.companyId, f.companyId), eq(activityLog.action, "tool_gateway.token_revealed"))))
|
||||
.toEqual([expect.objectContaining({ actorType: "user", actorId: f.userId, entityId: gateway.body.id, details: { tokenId: created.data.id } })]);
|
||||
const use = () => f.request("POST", `/mcp/gateways/${gateway.body.gatewayPublicId}`, { jsonrpc: "2.0", id: 1, method: "tools/list" }, value.token);
|
||||
expect(await use()).toMatchObject({ status: 200 });
|
||||
|
||||
|
||||
@@ -9456,9 +9456,7 @@ export function createToolGatewayService(
|
||||
companyId: string;
|
||||
tokenId: string;
|
||||
userId: string;
|
||||
managementContext?: ConnectionManagementContext;
|
||||
}): Promise<ToolMcpGatewayTokenCreated> {
|
||||
await input.managementContext?.reauthorize();
|
||||
const [existing] = await db.select().from(toolMcpGatewayTokens).where(and(
|
||||
eq(toolMcpGatewayTokens.companyId, input.companyId),
|
||||
eq(toolMcpGatewayTokens.id, input.tokenId),
|
||||
@@ -9482,7 +9480,7 @@ export function createToolGatewayService(
|
||||
))
|
||||
.returning();
|
||||
if (!row) throw new ToolGatewayHttpError(409, "This token's value was already shown once. Issue a new token to get a new value.", "gateway_token_already_revealed");
|
||||
if (input.managementContext) await logActivity(db, { companyId: input.companyId, ...input.managementContext.audit,
|
||||
await logActivity(db, { companyId: input.companyId, actorType: "user", actorId: input.userId,
|
||||
action: "tool_gateway.token_revealed", entityType: "tool_mcp_gateway", entityId: row.gatewayId,
|
||||
details: { tokenId: row.id } });
|
||||
return { ...toGatewayToken(row), token };
|
||||
|
||||
Reference in new issue
Block a user