export interface OAuthClient { client_id: string; client_secret?: string; redirect_uris: string[]; grant_types?: string[]; response_types?: string[]; scopes?: string[]; } export interface AccessToken { token: string; clientId: string; scopes: string[]; expiresAt?: Date; refreshToken?: string; } export interface OAuthEndpoints { authorizationUrl: string; tokenUrl: string; revocationUrl?: string; userInfoUrl?: string; registerUrl: string; } export interface OAuthError { error: string; error_description?: string; error_uri?: string; } export interface TokenResponse { access_token: string; token_type: string; expires_in?: number; refresh_token?: string; scope?: string; } export interface OAuthStorage { tokens: TokenStorage; } export interface TokenStorage { getToken(token: string): Promise; saveToken(token: AccessToken): Promise; deleteToken(token: string): Promise; deleteTokensByClient(clientId: string): Promise; } export interface ProxyOAuthProviderConfig { endpoints: OAuthEndpoints; storage?: OAuthStorage; verifyAccessToken?: (token: string) => Promise; issuerUrl?: string; defaultScopes?: string[]; } export interface OAuthRouterConfig { provider: ProxyOAuthServerProvider; issuerUrl: URL; baseUrl: URL; serviceDocumentationUrl?: URL; pathPrefix?: string; } export interface ProxyOAuthServerProvider { verifyAccessToken(token: string): Promise; authorize(params: AuthorizeParams): Promise; token(params: TokenParams): Promise; revoke(params: RevokeParams): Promise; readonly endpoints: OAuthEndpoints; } export interface AuthorizeParams { response_type: string; client_id: string; redirect_uri: string; scope?: string; state?: string; code_challenge: string; code_challenge_method: string; } export interface TokenParams { grant_type: string; client_id: string; client_secret?: string; code?: string; redirect_uri?: string; refresh_token?: string; code_verifier?: string; } export interface RevokeParams { token: string; token_type_hint?: string; client_id?: string; client_secret?: string; } export interface OAuthConfigOptions { endpoints: { authorizationUrl: string; tokenUrl: string; revocationUrl?: string; userInfoUrl?: string; registerUrl: string; }; issuerUrl: string; baseUrl: string; serviceDocumentationUrl?: string; pathPrefix?: string; defaultScopes?: string[]; } export interface OAuthProxyConfig { endpoints: OAuthEndpoints; issuerUrl: string; baseUrl: string; serviceDocumentationUrl?: string; pathPrefix?: string; storage?: OAuthStorage; verifyAccessToken?: (token: string) => Promise; defaultScopes?: string[]; }