Skip to content

Commit

Permalink
fix: allow configuring http timeout (#3188)
Browse files Browse the repository at this point in the history
  • Loading branch information
balazsorban44 committed Nov 12, 2021
1 parent 043b252 commit b871b47
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/core/lib/oauth/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,12 @@ export async function openidClient(
// and https://github.com/nextauthjs/next-auth/issues/3067
client[custom.clock_tolerance] = 10

// https://github.com/nextauthjs/next-auth/discussions/3186
if (typeof provider.httpOptions?.timeout === "number") {
custom.setHttpOptionsDefaults({
timeout: provider.httpOptions.timeout,
})
}

return client
}
6 changes: 5 additions & 1 deletion src/providers/oauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import type {
IssuerMetadata,
OAuthCallbackChecks,
OpenIDCallbackChecks,
HttpOptions,
} from "openid-client"
import type { JWK } from "jose"

type Client = InstanceType<Issuer['Client']>;
type Client = InstanceType<Issuer["Client"]>

export type { OAuthProviderType } from "./oauth-types"

Expand Down Expand Up @@ -132,6 +133,9 @@ export interface OAuthConfig<P> extends CommonProviderOptions, PartialIssuer {
region?: string
// TODO: only allow for some
issuer?: string
/** Read more at: https://github.com/panva/node-openid-client/tree/main/docs#customizing-http-requests */
httpOptions?: Pick<HttpOptions, "timeout">

/**
* The options provided by the user.
* We will perform a deep-merge of these values
Expand Down

0 comments on commit b871b47

Please sign in to comment.