@shane32/msoauth
Version:
A React library for Azure AD authentication with PKCE (Proof Key for Code Exchange) flow support. This library provides a secure and easy-to-use solution for implementing Azure AD authentication in React applications, with support for both API and Microso
51 lines (50 loc) • 2.65 kB
TypeScript
import AuthManager, { AuthManagerConfiguration } from "./AuthManager";
import { TokenResponse } from "./AuthManager.helpers";
/**
* Configuration object for GoogleAuthManager
* Extends AuthManagerConfiguration with Google-specific options
*/
export interface GoogleAuthManagerConfiguration<TPolicyNames extends string = string> extends AuthManagerConfiguration<TPolicyNames> {
/** URL for the proxy endpoint that will handle token requests with client secret */
proxyUrl: string;
}
/**
* Google-specific implementation of AuthManager
* Handles Google OAuth flows and token management with proxy support for client_secret
* @template TPolicyNames - Enum type for policy keys
*/
declare class GoogleAuthManager<TPolicyNames extends string = string> extends AuthManager<TPolicyNames> {
/** URL for the proxy endpoint that will handle token requests with client secret */
private readonly proxyUrl;
/**
* Creates a new instance of GoogleAuthManager
* @param {GoogleAuthManagerConfiguration} config - Configuration object for the GoogleAuthManager
*/
constructor(config: string extends TPolicyNames ? Omit<GoogleAuthManagerConfiguration<TPolicyNames>, "policies"> | GoogleAuthManagerConfiguration<TPolicyNames> : GoogleAuthManagerConfiguration<TPolicyNames>);
/**
* Override getTokenEndpointUrl to use the proxy URL instead of the token endpoint
* @param {string} grantType - The OAuth grant type (e.g., "authorization_code", "refresh_token")
* @returns {Promise<string>} The URL to use for token requests
* @protected
*/
protected getTokenEndpointUrl(grantType: string): Promise<string>;
/**
* Override generateLoginParams to include access_type=offline and prompt=consent
* This ensures Google OAuth will always return a refresh token
* @param {string} codeChallenge - The PKCE code challenge
* @param {string} state - The state parameter for CSRF protection
* @returns {URLSearchParams} The parameters for the login request
* @protected
*/
protected generateLoginParams(codeChallenge: string, state: string): URLSearchParams;
/**
* Override parseTokenResponse to set access_token to equal id_token
* This is useful for Google OAuth where the id_token contains user information
* that may be needed for authentication purposes
* @param {TokenResponse} response - The raw token response from the OAuth provider
* @returns {TokenResponse} The modified token response
* @protected
*/
protected parseTokenResponse(response: TokenResponse): TokenResponse;
}
export default GoogleAuthManager;