diff --git a/types/openid-client/index.d.ts b/types/openid-client/index.d.ts
index 5f159b21b5..4ab686ab42 100644
--- a/types/openid-client/index.d.ts
+++ b/types/openid-client/index.d.ts
@@ -8,6 +8,18 @@
///
import { IncomingMessage } from 'http';
+import { GotOptions } from 'got';
+
+export { }; // Disable automatic export of all module members (make it explicit)
+
+//
+
+type HttpRequestOptions = GotOptions;
+type CustomHttpOptionsProvider = (options: HttpRequestOptions) => HttpRequestOptions;
+
+export const custom: {
+ readonly http_options: unique symbol,
+};
// https://github.com/panva/node-openid-client/tree/master/docs#issuer
@@ -36,9 +48,14 @@ export interface IssuerMetadata {
}
export class Issuer {
+ static [custom.http_options]: CustomHttpOptionsProvider;
+
constructor(metadata?: IssuerMetadata);
+
static discover(issuer: string): Promise;
+ [custom.http_options]: CustomHttpOptionsProvider;
+
readonly metadata: IssuerMetadata;
readonly Client: typeof Client;
@@ -73,8 +90,12 @@ export interface EndSessionUrlParameters {
}
export class Client {
+ static [custom.http_options]: CustomHttpOptionsProvider;
+
constructor(metadata?: ClientMetadata);
+ [custom.http_options]: CustomHttpOptionsProvider;
+
readonly metadata: ClientMetadata;
authorizationUrl(parameters?: AuthorizationUrlParameters): string;
diff --git a/types/openid-client/openid-client-tests.ts b/types/openid-client/openid-client-tests.ts
index a3610b821e..9ee8784a4a 100644
--- a/types/openid-client/openid-client-tests.ts
+++ b/types/openid-client/openid-client-tests.ts
@@ -1,7 +1,18 @@
import { IncomingMessage } from 'http';
-import { Issuer, generators } from 'openid-client';
+import { Issuer, generators, custom } from 'openid-client';
async (req: IncomingMessage) => {
+ // Custom HTTP options on the `Issuer` _c'tor_ (e.g. used for `Issuer.discover()`):
+ Issuer[custom.http_options] = options => {
+ console.log(options.followRedirect, options.timeout, options.retry);
+ return {
+ ...options,
+ followRedirect: true,
+ timeout: 10_000,
+ retry: 3,
+ };
+ };
+
let issuer = await Issuer.discover('https://accounts.google.com');
console.log('Discovered issuer %O', issuer.metadata.issuer);
@@ -19,8 +30,12 @@ async (req: IncomingMessage) => {
token_endpoint_auth_methods_supported: ['client_secret_post', 'client_secret_basic'],
});
+ issuer[custom.http_options] = options => ({ ...options, retry: 3 });
+
//
+ issuer.Client[custom.http_options] = options => ({ ...options, retry: 3 });
+
const client = new issuer.Client({
client_id: 'c',
client_secret: 's',
@@ -29,6 +44,9 @@ async (req: IncomingMessage) => {
});
console.log(client.metadata.client_id);
+ // Custom HTTP options on the `Client` _instance_
+ client[custom.http_options] = options => ({ ...options, retry: 3 });
+
//
const code_verifier = generators.codeVerifier();