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
- [SDK-2555] Extensible cache #743 (stevehobbsdev)