Skip to content

Commit f0baad0

Browse files
authored
fix(sdk): drop auth headers from public firewall API endpoint (#581)
1 parent 951ab0c commit f0baad0

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

src/socket-sdk-class.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,10 +957,27 @@ export class SocketSdk {
957957
const results = await Promise.allSettled(
958958
components.map(async ({ purl }) => {
959959
const urlPath = `/${encodeURIComponent(purl)}`
960+
// Public endpoint — copy all headers except Authorization
961+
// (case-insensitive per RFC 7230 §3.2), keep agent/signal/timeout.
962+
const publicHeaders: Record<string, string> = {
963+
__proto__: null,
964+
} as unknown as Record<string, string>
965+
const srcHeaders = this.#reqOptions.headers as
966+
| Record<string, string>
967+
| undefined
968+
if (srcHeaders) {
969+
const keys = Object.keys(srcHeaders)
970+
for (let i = 0, { length } = keys; i < length; i += 1) {
971+
const key = keys[i]!
972+
if (key.toLowerCase() !== 'authorization') {
973+
publicHeaders[key] = srcHeaders[key]!
974+
}
975+
}
976+
}
960977
const response = await createGetRequest(
961978
SOCKET_FIREWALL_API_URL,
962979
urlPath,
963-
this.#reqOptions,
980+
{ ...this.#reqOptions, headers: publicHeaders },
964981
)
965982
if (!isResponseOk(response)) return undefined
966983
const json = await getResponseJson(response)

0 commit comments

Comments
 (0)