diff --git a/.changeset/clever-bees-happen.md b/.changeset/clever-bees-happen.md new file mode 100644 index 000000000..90e346e46 --- /dev/null +++ b/.changeset/clever-bees-happen.md @@ -0,0 +1,6 @@ +--- +'@verdaccio/types': patch +'@verdaccio/proxy': patch +--- + +chore: move agent_options to config diff --git a/packages/core/types/src/configuration.ts b/packages/core/types/src/configuration.ts index 3f303e521..8c2c48bd1 100644 --- a/packages/core/types/src/configuration.ts +++ b/packages/core/types/src/configuration.ts @@ -1,3 +1,6 @@ +import { AgentOptions as HttpAgentOptions } from 'node:http'; +import { AgentOptions as HttpsAgentOptions } from 'node:https'; + import { PackageAccess, PackageList } from '@verdaccio/types/src/manifest'; export type TypeToken = 'Bearer' | 'Basic'; @@ -47,6 +50,8 @@ export interface Headers { [key: string]: string; } +export type AgentOptionsConf = HttpAgentOptions | HttpsAgentOptions; + export interface UpLinkTokenConf { type: TypeToken; token?: string; @@ -64,6 +69,7 @@ export interface UpLinkConf { headers?: Headers; auth?: UpLinkTokenConf; strict_ssl?: boolean | void; + agent_options?: AgentOptionsConf; _autogenerated?: boolean; } diff --git a/packages/proxy/src/agent.ts b/packages/proxy/src/agent.ts index 0fa2a300d..225f12a7c 100644 --- a/packages/proxy/src/agent.ts +++ b/packages/proxy/src/agent.ts @@ -1,21 +1,17 @@ import { Agents } from 'got-cjs'; import { HttpProxyAgent, HttpsProxyAgent } from 'hpagent'; -import { Agent as HttpAgent, AgentOptions as HttpAgentOptions } from 'http'; -import { Agent as HttpsAgent, AgentOptions as HttpsAgentOptions } from 'https'; +import { Agent as HttpAgent } from 'http'; +import { Agent as HttpsAgent } from 'https'; import { URL } from 'url'; -export type AgentOptionsConf = HttpAgentOptions | HttpsAgentOptions; +import { AgentOptionsConf } from '@verdaccio/types'; class CustomAgents { private url: string; private proxy: string | undefined; - private agentOptions: HttpAgentOptions | HttpsAgentOptions; + private agentOptions: AgentOptionsConf; private agent: Agents; - public constructor( - url: string, - proxy: string | undefined, - agentOptions: HttpAgentOptions | HttpsAgentOptions - ) { + public constructor(url: string, proxy: string | undefined, agentOptions: AgentOptionsConf) { this.proxy = proxy; this.url = url; this.agentOptions = agentOptions; diff --git a/packages/proxy/src/proxy.ts b/packages/proxy/src/proxy.ts index 9da818131..1ab72767f 100644 --- a/packages/proxy/src/proxy.ts +++ b/packages/proxy/src/proxy.ts @@ -22,11 +22,10 @@ import { errorUtils, searchUtils, } from '@verdaccio/core'; -import { Manifest } from '@verdaccio/types'; -import { Config, Logger, UpLinkConf } from '@verdaccio/types'; +import { AgentOptionsConf, Config, Logger, Manifest, UpLinkConf } from '@verdaccio/types'; import { buildToken } from '@verdaccio/utils'; -import CustomAgents, { AgentOptionsConf } from './agent'; +import CustomAgents from './agent'; import { parseInterval } from './proxy-utils'; const debug = buildDebug('verdaccio:proxy');