@rockcarver/frodo-lib
Version:
A library to manage ForgeRock Identity Cloud tenants, ForgeOps deployments, and classic deployments.
76 lines • 3.27 kB
TypeScript
import { State } from '../shared/State';
import { CallbackHandler } from './CallbackOps';
import { JwkRsa } from './JoseOps';
import { type AccessTokenMetaType } from './OAuth2OidcOps';
export type Authenticate = {
/**
* Get tokens and store them in State
* @param {boolean} forceLoginAsUser true to force login as user even if a service account is available (default: false)
* @param {boolean} autoRefresh true to automatically refresh tokens before they expire (default: true)
* @param {string[]} types Array of supported deployment types. The function will throw an error if an unsupported type is detected (default: ['classic', 'cloud', 'forgeops'])
* @param {CallbackHandler} callbackHandler function allowing the library to collect responses from the user through callbacks
* @returns {Promise<Tokens>} object containing the tokens
*/
getTokens(forceLoginAsUser?: boolean, autoRefresh?: boolean, types?: string[], callbackHandler?: CallbackHandler): Promise<Tokens>;
/**
* Get access token for service account
* @param {string} saId optional service account id
* @param {JwkRsa} saJwk optional service account JWK
* @returns {string | null} Access token or null
* @deprecated since v2.0.0 use {@link Authenticate.getTokens | getTokens} instead
* ```javascript
* getTokens(): Promise<boolean>
* ```
* @group Deprecated
*/
getAccessTokenForServiceAccount(saId?: string, saJwk?: JwkRsa): Promise<string | null>;
};
declare const _default: (state: State) => Authenticate;
export default _default;
export type UserSessionMetaType = {
tokenId: string;
successUrl: string;
realm: string;
expires: number;
from_cache?: boolean;
};
/**
* Get fresh access token for service account
* @param {State} state library state
* @returns {Promise<AccessTokenResponseType>} response object containg token, scope, type, and expiration in seconds
*/
export declare function getFreshSaBearerToken({ saId, saJwk, state, }: {
saId?: string;
saJwk?: JwkRsa;
state: State;
}): Promise<AccessTokenMetaType>;
/**
* Get cached or fresh access token for service account
* @param {State} state library state
* @returns {Promise<AccessTokenResponseType>} response object containg token, scope, type, and expiration in seconds
*/
export declare function getSaBearerToken({ state, }: {
state: State;
}): Promise<AccessTokenMetaType>;
export type Tokens = {
bearerToken?: AccessTokenMetaType;
userSessionToken?: UserSessionMetaType;
subject?: string;
host?: string;
realm?: string;
};
/**
* Get tokens
* @param {boolean} forceLoginAsUser true to force login as user even if a service account is available (default: false)
* @param {boolean} autoRefresh true to automatically refresh tokens before they expire (default: true)
* @param {State} state library state
* @returns {Promise<Tokens>} object containing the tokens
*/
export declare function getTokens({ forceLoginAsUser, autoRefresh, types, callbackHandler, state, }: {
forceLoginAsUser?: boolean;
autoRefresh?: boolean;
types?: string[];
callbackHandler?: CallbackHandler;
state: State;
}): Promise<Tokens>;
//# sourceMappingURL=AuthenticateOps.d.ts.map