virgil-sdk
Version:
Virgil Security Services SDK
28 lines (27 loc) • 1.17 kB
TypeScript
import { GetJwtCallback } from '../Jwt';
import { IAccessToken, IAccessTokenProvider, ITokenContext } from './interfaces';
/**
* Implementation of {@link IAccessToken} that calls the user-provided
* callback function to get the JWT when requested by the clients.
*/
export declare class CallbackJwtProvider implements IAccessTokenProvider {
private readonly getJwt;
/**
* Creates a new instance of `CallbackJwtProvider`.
*
* @param {GetJwtCallback} getJwtFn - The function that will be called
* whenever the JWT is needed. If the `getJwtFn` returns the JWT as a
* string, it will be converted to {@link Jwt} instance automatically.
*/
constructor(getJwtFn: GetJwtCallback);
/**
* Returns a `Promise` resolved with the {@link Jwt} instance obtained
* by the call to the {@link CallbackJwtProvider.getJwt}. If the
* `getJwtFn` returns the JWT as a string, it is converted to
* {@link Jwt} instance before returning.
*
* @param {ITokenContext} context
* @returns {Promise<IAccessToken>}
*/
getToken(context: ITokenContext): Promise<IAccessToken>;
}