1 | import { IdToken, User } from '../global';
|
2 | export declare const CACHE_KEY_PREFIX = "@@auth0spajs@@";
|
3 | export declare type CacheKeyData = {
|
4 | audience: string;
|
5 | scope: string;
|
6 | client_id: string;
|
7 | };
|
8 | export declare class CacheKey {
|
9 | prefix: string;
|
10 | client_id: string;
|
11 | scope: string;
|
12 | audience: string;
|
13 | constructor(data: CacheKeyData, prefix?: string);
|
14 | /**
|
15 | * Converts this `CacheKey` instance into a string for use in a cache
|
16 | * @returns A string representation of the key
|
17 | */
|
18 | toKey(): string;
|
19 | /**
|
20 | * Converts a cache key string into a `CacheKey` instance.
|
21 | * @param key The key to convert
|
22 | * @returns An instance of `CacheKey`
|
23 | */
|
24 | static fromKey(key: string): CacheKey;
|
25 | /**
|
26 | * Utility function to build a `CacheKey` instance from a cache entry
|
27 | * @param entry The entry
|
28 | * @returns An instance of `CacheKey`
|
29 | */
|
30 | static fromCacheEntry(entry: CacheEntry): CacheKey;
|
31 | }
|
32 | interface DecodedToken {
|
33 | claims: IdToken;
|
34 | user: User;
|
35 | }
|
36 | export declare type CacheEntry = {
|
37 | id_token: string;
|
38 | access_token: string;
|
39 | expires_in: number;
|
40 | decodedToken: DecodedToken;
|
41 | audience: string;
|
42 | scope: string;
|
43 | client_id: string;
|
44 | refresh_token?: string;
|
45 | oauthTokenScope?: string;
|
46 | };
|
47 | export declare type WrappedCacheEntry = {
|
48 | body: Partial<CacheEntry>;
|
49 | expiresAt: number;
|
50 | };
|
51 | export declare type KeyManifestEntry = {
|
52 | keys: string[];
|
53 | };
|
54 | export declare type Cacheable = WrappedCacheEntry | KeyManifestEntry;
|
55 | export declare type MaybePromise<T> = Promise<T> | T;
|
56 | export interface ICache {
|
57 | set<T = Cacheable>(key: string, entry: T): MaybePromise<void>;
|
58 | get<T = Cacheable>(key: string): MaybePromise<T | null>;
|
59 | remove(key: string): MaybePromise<void>;
|
60 | allKeys?(): MaybePromise<string[]>;
|
61 | }
|
62 | export {};
|