@@ -92,18 +92,6 @@ export interface AuthConfig {
9292 }
9393}
9494
95- type ChangeAuthHandlerContextToMinimalContext <
96- TContext extends MinimalContext ,
97- THandlers extends Record < string , { handler : ApiRouteHandler < any , any > } > ,
98- > = {
99- [ K in keyof THandlers ] : THandlers [ K ] [ 'handler' ] extends ApiRouteHandler <
100- any ,
101- infer TApiRouteSchema
102- >
103- ? { schema : TApiRouteSchema ; handler : ApiRouteHandler < TContext , TApiRouteSchema > }
104- : never
105- }
106-
10795type AddObjectKeyPrefix < T extends Record < string , any > , TPrefix extends string > = Simplify < {
10896 [ K in keyof T as K extends string ? `${TPrefix } .${K } ` : never ] : T [ K ]
10997} >
@@ -115,15 +103,7 @@ export type Auth<
115103 config : TAuthConfig
116104 context : Context < TContext >
117105 authContext : AuthContext
118- handlers : Simplify <
119- AddObjectKeyPrefix <
120- ChangeAuthHandlerContextToMinimalContext <
121- TContext ,
122- ReturnType < typeof createAuthHandlers > [ 'handlers' ]
123- > ,
124- 'auth'
125- >
126- >
106+ handlers : Simplify < AddObjectKeyPrefix < ReturnType < typeof createAuthHandlers > [ 'handlers' ] , 'auth' > >
127107}
128108
129109export type AuthHandlers = Auth < any , any > [ 'handlers' ]
@@ -162,22 +142,13 @@ export function createAuth<TContext extends MinimalContext<any> = MinimalContext
162142 return h . handler ( { ...args , context : wrappedContext } as any ) as any
163143 }
164144 return { schema : h . schema , handler }
165- } ) as ChangeAuthHandlerContextToMinimalContext <
166- TContext ,
167- ReturnType < typeof createAuthHandlers > [ 'handlers' ]
168- >
145+ } ) as ReturnType < typeof createAuthHandlers > [ 'handlers' ]
169146
170147 const prefixedHandlers = Object . fromEntries (
171148 Object . entries ( handlers ) . map ( ( [ key , value ] ) => {
172149 return [ `auth.${ key } ` , value ]
173150 } )
174- ) as unknown as AddObjectKeyPrefix <
175- ChangeAuthHandlerContextToMinimalContext <
176- TContext ,
177- ReturnType < typeof createAuthHandlers > [ 'handlers' ]
178- > ,
179- 'auth'
180- >
151+ ) as unknown as AddObjectKeyPrefix < ReturnType < typeof createAuthHandlers > [ 'handlers' ] , 'auth' >
181152
182153 return {
183154 config,
0 commit comments