Currently working on a library that has an AuthModule
with an AuthService
for managing OAuth2 authentication using oidc-client-js
. I want the application using this library to be able to set up the configuration for the OAuth client. One way to do this is by providing the configuration in the forRoot
method of the AuthModule
:
AuthModule.forRoot({
applicationNamespace: 'ConsumingApp',
clientId: 'consuming.app'
});
In the forRoot
method, I would like to initialize the service with the provided config.
I found a workaround by setting the properties on the window
object and then accessing them in the AuthService
as window.clientId
and window.applicationNamespace
.
(window as any).applicationNamespace = authConfig.applicationNamespace;
(window as any).clientId = authConfig.clientId;
Is there a more efficient or proper way to achieve this?