oauth-v2-client
Version:
Oauth V2 client based on axios
34 lines (33 loc) • 1.54 kB
TypeScript
import { OauthClientConfig } from "../interfaces";
import AuthorizationCodePKCEGrantOptions from "../interfaces/AuthorizationCodePKCEGrantOptions";
import GetAuthorizationTokenFuncConfig from "../interfaces/GetAuthorizationTokenFuncConfig";
import GetAuthorizationUrlFuncConfig from "../interfaces/GetAuthorizationUrlFuncConfig";
import RefreshTokenFuncConfig from "../interfaces/RefreshTokenFuncConfig";
import TokenRefreshable from "../interfaces/TokenRefreshable";
import GrantControl from "./GrantControl";
export default class AuthorizationCodePKCEGrantControl extends GrantControl implements TokenRefreshable {
private options;
private redirectUri;
constructor(config: OauthClientConfig, options: AuthorizationCodePKCEGrantOptions);
/**
* Get authentication url
* @param {GetAuthorizationUrlFuncConfig} options redirect uri, response type
*/
getAuthUri(options?: GetAuthorizationUrlFuncConfig & {
codeVerifier?: string;
codeChallengeMethod?: "S256" | "plain";
}): string;
/**
* Get token with the authorization code extracted in the callback uri
* @param params {GetAuthorizationTokenFuncConfig} parameters
*/
getToken<T = any>(params: GetAuthorizationTokenFuncConfig<T> & {
codeVerifier?: string;
codeChallengeMethod?: "S256" | "plain";
}): Promise<void>;
/**
* Refresh the token
* @param params parameters
*/
refresh<T = any>(params: RefreshTokenFuncConfig<T>): Promise<void>;
}