UNPKG

oauth-v2-client

Version:
28 lines (27 loc) 1.33 kB
import { OauthClientConfig } from "../interfaces"; import AuthorizationCodeGrantOptions from "../interfaces/AuthorizationCodeGrantOptions"; import GetAuthorizationTokenFuncConfig from "../interfaces/GetAuthorizationTokenFuncConfig"; import GetAuthorizationUriFuncType from "../interfaces/GetAuthorizationUrlFuncConfig"; import RefreshTokenFuncConfig from "../interfaces/RefreshTokenFuncConfig"; import TokenRefreshable from "../interfaces/TokenRefreshable"; import GrantControl from "./GrantControl"; export default class AuthorizationCodeGrantControl extends GrantControl implements TokenRefreshable { private options; private redirectUri; constructor(config: OauthClientConfig, options: AuthorizationCodeGrantOptions); /** * Get authentication url * @param {GetAuthorizationUriFuncType} options redirect uri, response type */ getAuthUri(options?: GetAuthorizationUriFuncType): string; /** * Get token with the authorization code extracted in the callback uri * @param params {GetAuthorizationTokenFuncConfig} parameters */ getToken<T = any>(params: GetAuthorizationTokenFuncConfig<T>): Promise<void>; /** * Refresh the token * @param params parameters */ refresh<T = any>(params: RefreshTokenFuncConfig<T>): Promise<void>; }