UNPKG

@auth0/auth0-spa-js

Version:

Auth0 SDK for Single Page Applications using Authorization Code Grant Flow with PKCE

28 lines (24 loc) 597 B
import * as Cookies from 'es-cookie'; interface ClientStorageOptions { daysUntilExpire: number; } export const getAllKeys = () => Object.keys(Cookies.getAll() || {}); export const get = <T extends Object>(key: string) => { const value = Cookies.get(key); if (typeof value === 'undefined') { return; } return <T>JSON.parse(value); }; export const save = ( key: string, value: any, options: ClientStorageOptions ) => { Cookies.set(key, JSON.stringify(value), { expires: options.daysUntilExpire }); }; export const remove = (key: string) => { Cookies.remove(key); };