@rockcarver/frodo-lib
Version:
A library to manage ForgeRock Identity Cloud tenants, ForgeOps deployments, and classic deployments.
166 lines • 5.73 kB
TypeScript
import { State } from '../shared/State';
import { UserSessionMetaType } from './AuthenticateOps';
import { type AccessTokenMetaType } from './OAuth2OidcOps';
export type TokenCache = {
/**
* Get connection profiles file name
* @returns {string} connection profiles file name
*/
getTokenCachePath(): string;
/**
* Initialize token cache
*
* This method is called from app.ts and runs before any of the message handlers are registered.
* Therefore none of the Console message functions will produce any output.
*/
initTokenCache(): void;
/**
* Check if there are suitable tokens in the cache
* @param {tokenType} tokenType type of token
* @returns {Promise<boolean>} true if tokens found in cache, false otherwise
*/
hasToken(tokenType: tokenType): Promise<boolean>;
/**
* Check if there are suitable user session tokens in the cache
* @returns {Promise<boolean>} true if tokens found in cache, false otherwise
*/
hasUserSessionToken(): Promise<boolean>;
/**
* Check if there are suitable user bearer tokens in the cache
* @returns {Promise<boolean>} true if tokens found in cache, false otherwise
*/
hasUserBearerToken(): Promise<boolean>;
/**
* Check if there are suitable service account bearer tokens in the cache
* @returns {Promise<boolean>} true if tokens found in cache, false otherwise
*/
hasSaBearerToken(): Promise<boolean>;
/**
* Read token
* @param {tokenType} tokenType type of token
* @returns {Promise<string>} token or null
*/
readToken(tokenType: tokenType): Promise<AccessTokenMetaType | UserSessionMetaType>;
/**
* Read user session token
* @returns {Promise<string>} token or null
*/
readUserSessionToken(): Promise<UserSessionMetaType>;
/**
* Read user bearer token
* @returns {Promise<string>} token or null
*/
readUserBearerToken(): Promise<AccessTokenMetaType>;
/**
* Read service account bearer token
* @returns {Promise<string>} token or null
*/
readSaBearerToken(): Promise<AccessTokenMetaType>;
/**
* Save user session token for current connection
* @returns {Promise<boolean>} true if the operation succeeded, false otherwise
*/
saveUserSessionToken(token: UserSessionMetaType): Promise<boolean>;
/**
* Save user bearer token for current connection
* @returns {Promise<boolean>} true if the operation succeeded, false otherwise
*/
saveUserBearerToken(token: AccessTokenMetaType): Promise<boolean>;
/**
* Save service account bearer token for current connection
* @returns {Promise<boolean>} true if the operation succeeded, false otherwise
*/
saveSaBearerToken(token: AccessTokenMetaType): Promise<boolean>;
/**
* Purge all expired tokens from cache
* @returns {TokenCacheInterface} purged cache
*/
purge(): TokenCacheInterface;
/**
* Flush cache
* @returns {boolean} true if the operation succeeded, false otherwise
*/
flush(): boolean;
};
declare const _default: (state: State) => TokenCache;
export default _default;
export interface tokenTypeInterface {
userSession: string;
userBearer: string;
saBearer: string;
}
export type tokenType = 'userSession' | 'userBearer' | 'saBearer';
export interface TokenCacheInterface {
[hostKey: string]: {
[realmKey: string]: {
[typeKey in keyof typeKey]: {
[subjectKey: string]: {
[expKey: string]: string;
};
};
};
};
}
/**
* Get token cache file name
* @param {State} state library state
* @returns {String} connection profiles file name
*/
export declare function getTokenCachePath({ state }: {
state: State;
}): string;
/**
* Initialize connection profiles
*
* This method is called from app.ts and runs before any of the message handlers are registered.
* Therefore none of the Console message functions will produce any output.
* @param {State} state library state
*/
export declare function initTokenCache({ state }: {
state: State;
}): void;
export declare function hasToken({ tokenType, state, }: {
tokenType: tokenType;
state: State;
}): Promise<boolean>;
export declare function hasUserSessionToken({ state, }: {
state: State;
}): Promise<boolean>;
export declare function hasUserBearerToken({ state, }: {
state: State;
}): Promise<boolean>;
export declare function hasSaBearerToken({ state, }: {
state: State;
}): Promise<boolean>;
export declare function readToken({ tokenType, state, }: {
tokenType: tokenType;
state: State;
}): Promise<AccessTokenMetaType | UserSessionMetaType>;
export declare function readUserSessionToken({ state, }: {
state: State;
}): Promise<UserSessionMetaType>;
export declare function readUserBearerToken({ state, }: {
state: State;
}): Promise<AccessTokenMetaType>;
export declare function readSaBearerToken({ state, }: {
state: State;
}): Promise<AccessTokenMetaType>;
export declare function saveUserSessionToken({ token, state, }: {
token: UserSessionMetaType;
state: State;
}): Promise<boolean>;
export declare function saveUserBearerToken({ token, state, }: {
token: AccessTokenMetaType;
state: State;
}): Promise<boolean>;
export declare function saveSaBearerToken({ token, state, }: {
token: AccessTokenMetaType;
state: State;
}): Promise<boolean>;
export declare function purge({ state }: {
state: State;
}): TokenCacheInterface;
export declare function flush({ state }: {
state: State;
}): boolean;
//# sourceMappingURL=TokenCacheOps.d.ts.map