From 0e885d965ec7a711a1b9bef328e6444858d91657 Mon Sep 17 00:00:00 2001 From: Thomas Howlett <1786243+howlettt@users.noreply.github.com> Date: Tue, 4 Jul 2023 17:26:25 -0600 Subject: [PATCH] Add OidcClient constructor overload --- docs/oidc-client-ts.api.md | 1 + src/OidcClient.ts | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/oidc-client-ts.api.md b/docs/oidc-client-ts.api.md index ebbb47a02..ff727000a 100644 --- a/docs/oidc-client-ts.api.md +++ b/docs/oidc-client-ts.api.md @@ -256,6 +256,7 @@ export interface OidcAddressClaim { // @public export class OidcClient { constructor(settings: OidcClientSettings); + constructor(settings: OidcClientSettingsStore, metadataService: MetadataService); // Warning: (ae-forgotten-export) The symbol "ClaimsService" needs to be exported by the entry point index.d.ts // // (undocumented) diff --git a/src/OidcClient.ts b/src/OidcClient.ts index 777a8b923..5185c03b0 100644 --- a/src/OidcClient.ts +++ b/src/OidcClient.ts @@ -72,10 +72,12 @@ export class OidcClient { protected readonly _validator: ResponseValidator; protected readonly _tokenClient: TokenClient; - public constructor(settings: OidcClientSettings) { - this.settings = new OidcClientSettingsStore(settings); + public constructor(settings: OidcClientSettings); + public constructor(settings: OidcClientSettingsStore, metadataService: MetadataService); + public constructor(settings: OidcClientSettings | OidcClientSettingsStore, metadataService?: MetadataService) { + this.settings = settings instanceof OidcClientSettingsStore ? settings : new OidcClientSettingsStore(settings); - this.metadataService = new MetadataService(this.settings); + this.metadataService = metadataService ?? new MetadataService(this.settings); this._claimsService = new ClaimsService(this.settings); this._validator = new ResponseValidator(this.settings, this.metadataService, this._claimsService); this._tokenClient = new TokenClient(this.settings, this.metadataService);