diff --git a/src/auth0-session/client/node-client.ts b/src/auth0-session/client/node-client.ts index 264b6a714..dad56ac13 100644 --- a/src/auth0-session/client/node-client.ts +++ b/src/auth0-session/client/node-client.ts @@ -61,7 +61,8 @@ export class NodeClient extends AbstractClient { } : undefined) }, - timeout: config.httpTimeout + timeout: config.httpTimeout, + agent: config.httpAgent }); const applyHttpOptionsCustom = (entity: Issuer | typeof Issuer | Client) => { entity[custom.http_options] = defaultHttpOptions; diff --git a/src/auth0-session/config.ts b/src/auth0-session/config.ts index 9334bad76..59f06d23a 100644 --- a/src/auth0-session/config.ts +++ b/src/auth0-session/config.ts @@ -2,6 +2,7 @@ import type { AuthorizationParameters as OidcAuthorizationParameters, ClientAuthMethod } from './client/abstract-client'; +import type { Agent } from 'https'; import { SessionStore } from './session/stateful-session'; /** @@ -100,6 +101,12 @@ export interface Config { */ httpTimeout: number; + /** + * Instance of an HTTP agent for authentication requests. + * (This is for the Node.js runtime only) + */ + httpAgent?: Agent; + /** * Boolean value to opt-out of sending the library and Node.js version to your authorization server * via the `Auth0-Client` header. Defaults to `true`. diff --git a/src/auth0-session/get-config.ts b/src/auth0-session/get-config.ts index 1adc9e79c..84c1cab6a 100644 --- a/src/auth0-session/get-config.ts +++ b/src/auth0-session/get-config.ts @@ -112,6 +112,7 @@ const paramsSchema = Joi.object({ ), clockTolerance: Joi.number().optional().default(60), httpTimeout: Joi.number().optional().default(5000), + httpAgent: Joi.object().optional(), enableTelemetry: Joi.boolean().optional().default(true), getLoginState: Joi.function() .optional() diff --git a/src/config.ts b/src/config.ts index 7d0eaf648..358af2548 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,3 +1,4 @@ +import type { Agent } from 'https'; import type { LoginOptions, AuthorizationParameters as OidcAuthorizationParameters } from './auth0-session/config'; import { SessionStore } from './auth0-session/session/stateful-session'; import Session from './session/session'; @@ -96,6 +97,12 @@ export interface BaseConfig { */ httpTimeout: number; + /** + * Instance of an HTTP agent for authentication requests. + * (This is for the Node.js runtime only) + */ + httpAgent?: Agent; + /** * Boolean value to opt-out of sending the library and node version to your authorization server * via the `Auth0-Client` header. Defaults to `true`.