@juspay/neurolink
Version:
Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applicatio
37 lines (36 loc) • 1.92 kB
TypeScript
/**
* Shared OAuth fetch wrapper for Anthropic API requests.
*
* Extracted from `providers/anthropic.ts` so that any provider or proxy layer
* that needs OAuth-authenticated Anthropic requests can reuse the same logic.
*
* Applies full "cloaking" to make requests indistinguishable from the
* official Claude CLI / CLIProxyAPI, which is required for OAuth + tools
* to work correctly.
*
* @module proxy/oauthFetch
*/
import { CLAUDE_CLI_USER_AGENT, MCP_TOOL_PREFIX } from "../auth/anthropicOAuth.js";
export { CLAUDE_CLI_USER_AGENT, MCP_TOOL_PREFIX };
/**
* Creates a custom fetch function for OAuth-authenticated requests.
* This wrapper applies all required transformations for OAuth mode:
* - Uses Authorization: Bearer header (NOT x-api-key)
* - Adds OAuth-required beta headers
* - Sets User-Agent to Claude CLI
* - Adds ?beta=true query parameter to /v1/messages
* - Injects billing header & agent block into system prompt
* - Injects Claude-Code-shaped user ID into metadata
* - Adds Stainless SDK headers for fingerprint matching
* - Disables thinking when tool_choice is forced
*
* Accepts a getter function instead of a static token so that refreshed
* tokens are picked up automatically on each request.
*
* @param getToken - Function returning the current OAuth access token
* @param includeOptionalBetas - Whether to include optional beta headers (default true)
* @param enableMcpPrefix - Whether to apply mcp_ prefix/strip logic to tool names (default false)
* @param skipBodyTransform - When true, skip ALL body modifications (billing header, user ID, tool prefix).
* Used for proxy passthrough where the request body must be forwarded as-is.
*/
export declare function createOAuthFetch(getToken: () => string, includeOptionalBetas?: boolean, enableMcpPrefix?: boolean, skipBodyTransform?: boolean): typeof fetch;