Skip to content
This repository was archived by the owner on May 11, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/http-helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,18 @@ export const put = async (endpoint: string, options?: RequestOptions): Promise<a
}
};

export const sanitizeAxiosResponseConfig = (config: unknown) => {
if (!config || typeof config !== "object") {
return undefined;
}
const maybe = config as Record<string, unknown>;
return {
method: maybe.method,
url: maybe.url,
timeout: maybe.timeout,
};
};

const errorHandling = (err: unknown) => {
if (axios.isAxiosError(err)) {
if (err.response) {
Expand All @@ -142,7 +154,7 @@ const errorHandling = (err: unknown) => {
status: err.response?.status,
statusText: err.response?.statusText,
data: err.response?.data,
config: err.response?.config,
config: sanitizeAxiosResponseConfig(err.response?.config),
}),
);
if (err.response?.data) {
Expand Down
18 changes: 18 additions & 0 deletions tests/http-helpers/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
parseDropNotificationParams,
parseOrdersScoringParams,
sanitizeAxiosResponseConfig,
} from "../../src/http-helpers/index.ts";
import type { DropNotificationParams, OrdersScoringParams } from "../../src/types.ts";

Expand All @@ -27,4 +28,21 @@ describe("utilities", () => {
expect(params).deep.equal({ ids: "0,1,2" });
});
});

describe("sanitizeAxiosResponseConfig", () => {
it("removes sensitive headers and auth details", () => {
const sanitized = sanitizeAxiosResponseConfig({
method: "post",
url: "https://clob.polymarket.com/order",
timeout: 5000,
headers: { Authorization: "Bearer secret" },
auth: { username: "u", password: "p" },
});
expect(sanitized).deep.equal({
method: "post",
url: "https://clob.polymarket.com/order",
timeout: 5000,
});
});
});
});