Skip to content
This repository has been archived by the owner on Mar 3, 2022. It is now read-only.

Support changing the store in WebStorageStateStore by adding proper TypeScript declarations #165

Conversation

merijndejonge
Copy link
Contributor

Pull request for #159.

WebStorageStateStore can be configured to use a different storage than the default. UserManagerSettings is using this to make use of Global.sessionStorage. This default of UserManagerSettings can also be changed in using the UserManagerSettings class.

However, with TypeScript this cannot be done because of the following three reasons:

  • WebStorageStateStore is defined as an interface and can therefore not be instantiated. I.e., the following does not work: userStore: new Oidc.WebStorageStateStore()
  • The typescript definition of WebStorageStateStore doesn't have a constructor defined, so the compiler complains when trying to pass an argument in the constructor:
  • There is no TypeScript definition for the options that are accepted by WebStorageStateStore.

In this pull request I therefore 1) changed the interface definition into a class definition; 2) added a constructor; 3) added WebStorageStateStoreSettings . With these changes the store can be configured in UserManagerSettings as follows:

var settings: Oidc.UserManagerSettings = {
                // other settings
                userStore: new Oidc.WebStorageStateStore({ store: localStorage })
            }

@brockallen brockallen merged commit 0fc27ac into IdentityModel:dev Oct 22, 2016
@brockallen
Copy link
Member

thanks

@brockallen brockallen added this to the 1.2.1 milestone Oct 22, 2016
@merijndejonge merijndejonge deleted the Support_change_store_in_WebStorageStateStore branch October 22, 2016 20:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging this pull request may close these issues.

None yet

2 participants