github auth0/auth0-spa-js v1.16.0

latest releases: v2.1.3, v2.1.2, v2.1.1...
2 years ago

This release adds a new extensible cache API, that enables you to bring your own cache implementation instead of relying on our built-in in-memory storage and localStorage implementations.

It's a Promise-based API that opens up the possibility to provide a more secure and complex cache to the SDK.

Here's a simple example that shows how sessionStorage support can be added to the cache:

const sessionStorageCache = {
  get(key) {
    return Promise.resolve(JSON.parse(sessionStorage.getItem(key)));
  },

  set(key, value) {
    return Promise.resolve(sessionStorage.setItem(key, JSON.stringify(value)));
  },

  remove(key) {
    sessionStorage.removeItem(key);
    return Promise.resolve();
  },
};

await createAuth0Client({
  domain: '<AUTH0_DOMAIN>',
  client_id: '<AUTH0_CLIENT_ID>',
  redirect_uri: '<MY_CALLBACK_URL>',
  cache: sessionStorageCache
});

You can read more about the cache API in the readme doc.

Added

Don't miss a new auth0-spa-js release

NewReleases is sending notifications on new releases.