From 068a148b088c67fe058a79b424427205d69ea681 Mon Sep 17 00:00:00 2001 From: pamapa Date: Thu, 18 Jul 2024 13:41:15 +0200 Subject: [PATCH 1/2] fix: compiler error "...is used before its initialization" --- src/ResponseValidator.ts | 9 ++++++--- src/utils/Event.ts | 6 ++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/ResponseValidator.ts b/src/ResponseValidator.ts index f0077b31c..ec8f1037e 100644 --- a/src/ResponseValidator.ts +++ b/src/ResponseValidator.ts @@ -21,14 +21,17 @@ import type { ClaimsService } from "./ClaimsService"; */ export class ResponseValidator { protected readonly _logger = new Logger("ResponseValidator"); - protected readonly _userInfoService = new UserInfoService(this._settings, this._metadataService); - protected readonly _tokenClient = new TokenClient(this._settings, this._metadataService); + protected readonly _userInfoService: UserInfoService; + protected readonly _tokenClient: TokenClient; public constructor( protected readonly _settings: OidcClientSettingsStore, protected readonly _metadataService: MetadataService, protected readonly _claimsService: ClaimsService, - ) {} + ) { + this._userInfoService = new UserInfoService(this._settings, this._metadataService); + this._tokenClient = new TokenClient(this._settings, this._metadataService); + } public async validateSigninResponse(response: SigninResponse, state: SigninState, extraHeaders?: Record): Promise { const logger = this._logger.create("validateSigninResponse"); diff --git a/src/utils/Event.ts b/src/utils/Event.ts index 1c3f019c4..cb8235cca 100644 --- a/src/utils/Event.ts +++ b/src/utils/Event.ts @@ -12,11 +12,13 @@ export type Callback = (...ev: EventType) => (Promi * @internal */ export class Event { - protected readonly _logger = new Logger(`Event('${this._name}')`); + protected readonly _logger: Logger; private _callbacks: Array> = []; - public constructor(protected readonly _name: string) {} + public constructor(protected readonly _name: string) { + this._logger = new Logger(`Event('${this._name}')`); + } public addHandler(cb: Callback): () => void { this._callbacks.push(cb); From edc9c5fb384fe8632286a4043dfba0058fd1e300 Mon Sep 17 00:00:00 2001 From: pamapa Date: Thu, 18 Jul 2024 13:41:53 +0200 Subject: [PATCH 2/2] fix: make _callbacks readonly --- src/utils/Event.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/Event.ts b/src/utils/Event.ts index cb8235cca..796d0c276 100644 --- a/src/utils/Event.ts +++ b/src/utils/Event.ts @@ -14,7 +14,7 @@ export type Callback = (...ev: EventType) => (Promi export class Event { protected readonly _logger: Logger; - private _callbacks: Array> = []; + private readonly _callbacks: Array> = []; public constructor(protected readonly _name: string) { this._logger = new Logger(`Event('${this._name}')`);