66 */
77
88import { initializeProviders , expandEnvVar } from './lib/config.ts' ;
9- import { createOAuthResource } from './lib/resource.ts' ;
9+ import { OAuthResource } from './lib/resource.ts' ;
1010import { validateAndRefreshSession } from './lib/sessionValidator.ts' ;
1111import { clearOAuthSession } from './lib/handlers.ts' ;
1212import { HookManager } from './lib/hookManager.ts' ;
1313import type { Scope , OAuthPluginConfig , ProviderRegistry , OAuthHooks } from './types.ts' ;
1414
15- // Export HookManager class and types
15+ // Export HookManager class, OAuthResource class, and types
1616export { HookManager } from './lib/hookManager.ts' ;
17+ export { OAuthResource } from './lib/resource.ts' ;
1718export type { OAuthHooks , OAuthUser , TokenResponse } from './types.ts' ;
1819
1920// Store hooks registered at module load time and active hookManager
@@ -106,7 +107,7 @@ export async function handleApplication(scope: Scope): Promise<void> {
106107
107108 // Update the resource with new providers
108109 if ( Object . keys ( providers ) . length === 0 ) {
109- // No valid providers configured
110+ // No valid providers configured - register a simple error resource
110111 scope . resources . set ( 'oauth' , {
111112 async get ( ) {
112113 return {
@@ -130,8 +131,11 @@ export async function handleApplication(scope: Scope): Promise<void> {
130131 } ,
131132 } ) ;
132133 } else {
133- // Register the OAuth resource with configured providers
134- scope . resources . set ( 'oauth' , createOAuthResource ( providers , debugMode , hookManager , logger ) ) ;
134+ // Configure the OAuth resource with providers and settings
135+ OAuthResource . configure ( providers , debugMode , hookManager , logger ) ;
136+
137+ // Register the OAuth resource class
138+ scope . resources . set ( 'oauth' , OAuthResource ) ;
135139
136140 // Log all configured providers
137141 logger ?. info ?.( 'OAuth plugin ready:' , {
0 commit comments