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