utils/proxy/proxy_utils library

Classes

AuthHeaders
Authentication headers result.
MTLSConfig
Mutual TLS configuration.
ParsedProxyUrl
Parse a proxy URL into its components.
ProxyConfiguration
Comprehensive proxy configuration holder.
ProxyFetchOptions
Proxy fetch options (Dart equivalent of the TS getProxyFetchOptions).
TLSConfig
TLS configuration (mTLS + CA certs).

Properties

appliedExtraCACertsPath String?
Get the applied extra CA certs path (set by applyExtraCACertsFromConfig).
no setter
isKeepAliveDisabled bool
Whether keep-alive is currently disabled.
no setter

Functions

applyExtraCACertsFromConfig({required Map<String, String>? getGlobalConfigEnv(), required Map<String, String>? getUserSettingsEnv()}) → void
Apply NODE_EXTRA_CA_CERTS from settings to the environment early in init.
clearCACertsCache() → void
Clear the CA certificates cache.
clearMTLSCache() → void
Clear the mTLS configuration cache.
clearProxyCache() → void
Clear proxy agent cache.
configureGlobalAgents() → void
Configure global HTTP agents for proxy and mTLS.
configureGlobalMTLS() → void
Configure global TLS settings.
createProxiedHttpClient({String? proxyUrl, SecurityContext? securityContext}) HttpClient
Create an HttpClient with proxy configuration.
disableKeepAlive() → void
Disable keep-alive globally (sticky for process lifetime).
getAddressFamily(dynamic family) int
Convert DNS lookup options family to a numeric address family value.
getAuthHeaders({required bool isSubscriber, String? getOAuthAccessToken()?, String? getApiKey()?, String oauthBetaHeader = ''}) AuthHeaders
Get authentication headers for API requests.
getAWSClientProxyConfig() Future<Map<String, dynamic>>
Get AWS SDK client configuration with proxy support.
getCACertificates() List<String>?
Load CA certificates for TLS connections.
getMCPUserAgent({required String version, String? entrypoint, String? agentSdkVersion, String? clientApp}) String
Get the MCP user agent string.
getMTLSConfig() MTLSConfig?
Get mTLS configuration from environment variables.
getMTLSHttpClient() HttpClient?
Create an HttpClient with mTLS configuration.
getNoProxy([EnvLike? env]) String?
Get the NO_PROXY environment variable value.
getProxyFetchOptions({bool forAnthropicAPI = false}) ProxyFetchOptions
Get fetch options with proxy and mTLS configuration.
getProxyUrl([EnvLike? env]) String?
Get the active proxy URL if one is configured. Prefers lowercase variants over uppercase.
getTLSConfig() TLSConfig?
Get TLS configuration for fetch-like operations.
getUserAgent({required String version, String? userType, String? entrypoint, String? agentSdkVersion, String? clientApp, String? workload}) String
Get the user agent string for API requests.
getWebFetchUserAgent({required String neomageUserAgent}) String
Get the WebFetch user agent string.
getWebSocketProxyClient(String url) HttpClient?
Get an HTTP client for WebSocket proxy support. Returns null if no proxy is configured or URL should bypass proxy.
getWebSocketProxyUrl(String url) String?
Get the proxy URL for WebSocket connections. Returns null if no proxy or URL should bypass proxy.
getWebSocketTLSContext() SecurityContext?
Get TLS options for WebSocket connections.
isLocalhostUrl(String url) bool
Check if a URL points to localhost.
isValidPemCertificate(String pem) bool
Validate that a string is a valid PEM certificate.
isValidPemPrivateKey(String pem) bool
Validate that a string is a valid PEM private key.
isValidProxyUrl(String url) bool
Validates that the proxy URL is well-formed.
matchesNoProxyPattern(String hostname, String pattern) bool
Check if a hostname matches a NO_PROXY pattern.
mergeNoProxy(List<String?> values) String
Merge multiple NO_PROXY values (from different config sources).
parseNoProxy(String? noProxy) List<String>
Parse NO_PROXY string into a list of patterns.
parsePemCertificates(String pemBundle) List<String>
Certificate PEM parser: extract individual certificates from a PEM bundle.
parseProxyUrl(String url) ParsedProxyUrl?
Parse a proxy URL into structured components.
resetKeepAliveForTesting() → void
Reset keep-alive for testing.
shouldBypassProxy(String urlString, [String? noProxy]) bool
Check if a URL should bypass the proxy based on NO_PROXY.
withOAuth401Retry<T>({required Future<T> request(), required Future<void> handleOAuth401Error(String failedAccessToken), required String? getAccessToken(), bool also403Revoked = false}) Future<T>
Wrapper that handles OAuth 401 errors by retrying once.

Typedefs

EnvLike = Map<String, String?>
Environment-like map type for dependency injection in tests.