@@ -5,7 +5,7 @@ import { getToken } from "@src/utils/auth/callbacks/get-token";
55import { getUpdatedSession } from "@src/utils/auth/callbacks/get-updated-session" ;
66import { isValidSignIn } from "@src/utils/auth/callbacks/is-valid-signin" ;
77import { MaxAgeInSeconds } from "@src/utils/auth/types" ;
8- import { AppConfig , configProvider } from "@src/utils/config" ;
8+ import lazyConfig from "@src/utils/lazy- config" ;
99import { logger } from "@src/utils/logger" ;
1010import { profilePerformanceEnd , profilePerformanceStart } from "@src/utils/performance" ;
1111import { RequestContext , asyncLocalStorage } from "@src/utils/requestContext" ;
@@ -21,16 +21,15 @@ const AuthJWTPerformanceMarker = "auth-jwt-callback";
2121const AuthSessionPerformanceMarker = "auth-session-callback" ;
2222
2323export const { handlers, signIn, signOut, auth } = NextAuth ( async ( ) => {
24- const config : AppConfig = await configProvider ( ) ;
25- const MAX_SESSION_AGE_SECONDS : number = config . MAX_SESSION_AGE_MINUTES * 60 ;
24+ const MAX_SESSION_AGE_SECONDS : number = ( ( await lazyConfig . MAX_SESSION_AGE_MINUTES ) as number ) * 60 ;
2625 const headerValues = await headers ( ) ;
2726
2827 const requestContext : RequestContext = extractRequestContextFromHeaders ( headerValues ) ;
2928
3029 return await asyncLocalStorage . run ( requestContext , async ( ) => {
3130 return {
3231 providers : [ await NHSLoginAuthProvider ( ) ] ,
33- secret : config . AUTH_SECRET ,
32+ secret : ( await lazyConfig . AUTH_SECRET ) as string ,
3433 pages : {
3534 signIn : SSO_FAILURE_ROUTE ,
3635 signOut : SESSION_LOGOUT_ROUTE ,
@@ -49,7 +48,7 @@ export const { handlers, signIn, signOut, auth } = NextAuth(async () => {
4948 let response : boolean ;
5049 try {
5150 profilePerformanceStart ( AuthSignInPerformanceMarker ) ;
52- response = isValidSignIn ( account , config ) ;
51+ response = await isValidSignIn ( account ) ;
5352 profilePerformanceEnd ( AuthSignInPerformanceMarker ) ;
5453 } catch ( error ) {
5554 log . error ( { error : error } , "signIn() callback error" ) ;
@@ -64,7 +63,7 @@ export const { handlers, signIn, signOut, auth } = NextAuth(async () => {
6463 let response ;
6564 try {
6665 profilePerformanceStart ( AuthJWTPerformanceMarker ) ;
67- response = getToken ( token , account , profile , config , MAX_SESSION_AGE_SECONDS as MaxAgeInSeconds ) ;
66+ response = getToken ( token , account , profile , MAX_SESSION_AGE_SECONDS as MaxAgeInSeconds ) ;
6867 profilePerformanceEnd ( AuthJWTPerformanceMarker ) ;
6968 } catch ( error ) {
7069 log . error ( { error : error } , "jwt() callback error" ) ;
0 commit comments