constructor()

in libs/@guardian/identity-auth/src/identityAuth.ts [48:86]


	constructor(options: IdentityAuthOptions) {
		this.#options = {
			autoRenew: true,
			renewGracePeriod: 60,
			maxClockSkew: 300,
			idCookieSessionRefresh: false,
			oauthTimeout: 30000,
			strictClockSkewCheck: false,
			...options,
		};
		this.#oauthUrls = {
			authorizeUrl: `${this.#options.issuer}/v1/authorize`,
			tokenUrl: `${this.#options.issuer}/v1/token`,
			keysUrl: `${this.#options.issuer}/v1/keys`,
		};

		// before doing anything else, we check if the user's session should be refreshed based on the idCookieSessionRefresh option
		cookieRefreshIfRequired(
			this.#options.idCookieSessionRefresh,
			this.#options.issuer,
		);

		this.#emitter = new Emitter();
		this.token = new Token<AC, IC>(this.#options, this.#oauthUrls);
		this.tokenManager = new TokenManager<AC, IC>(this.#emitter, this.token);
		this.authStateManager = new AuthStateManager<AC, IC>(
			this.#emitter,
			this.tokenManager,
		);
		this.#autoRenewService = new AutoRenewService(
			this.#options,
			this.#emitter,
			this.authStateManager,
		);

		this.#isSignedInWithAuthStateInProgress = undefined;

		this.#autoRenewService.start();
	}