@oa2/core
Version:
A comprehensive, RFC-compliant OAuth 2.0 authorization server implementation in TypeScript
51 lines (48 loc) • 2.46 kB
TypeScript
import { Grant } from './types.js';
interface AuthorizationCodeOptions {
/** The lifetime of the authorization code in seconds. Defaults to 600 (10 minutes). */
authorizationCodeLifetime?: number;
/** The minimum length of the code verifier. Defaults to 43 characters. */
codeVerifierMinLength?: number;
}
/**
* Handles the OAuth 2.0 Authorization Endpoint request.
* This function validates the authorization request and redirects the user-agent
* back to the client with an authorization code.
* @param context The context object containing the request, storage, and authenticated client.
* @returns A Promise that resolves to an OAuth2Response, typically a 302 redirect.
* @throws {UnauthorizedClientError} If the client is not authenticated.
* @throws {InvalidRequestError} If required parameters are missing or invalid.
* @throws {AccessDeniedError} If the resource owner denies the request or authentication fails.
*/
/**
* Implements the Authorization Code Grant flow with PKCE support.
* This grant type is used by confidential and public clients to exchange an authorization code
* for an access token and optionally a refresh token.
* @returns A Grant object for the authorization_code type.
*/
declare function authorizationCodeGrant(options?: AuthorizationCodeOptions): Grant;
/**
* Implements the Client Credentials Grant flow.
* This grant type is used by confidential clients to obtain an access token
* directly, without involving a resource owner.
* @returns A Grant object for the client_credentials type.
*/
declare function clientCredentialsGrant(): Grant;
/**
* Implements the Refresh Token Grant flow.
* This grant type is used to obtain new access tokens (and optionally new refresh tokens)
* using a refresh token, without requiring the user to re-authenticate.
* @returns A Grant object for the refresh_token type.
*/
declare function refreshTokenGrant(): Grant;
/**
* Implements the Password Grant flow.
* This grant type is used by resource owners to obtain an access token by providing their username and password.
* Note: This grant type is not recommended for public clients and should only be used by trusted clients.
* @returns A Grant object for the password type.
*/
declare function passwordGrant(): Grant;
export { authorizationCodeGrant, clientCredentialsGrant, passwordGrant, refreshTokenGrant };
export type { AuthorizationCodeOptions };
//# sourceMappingURL=grants.d.ts.map