1- const openIdClient = require ( 'openid-client' ) ;
2- const { Strategy } = require ( 'openid-client/passport' ) ;
31const passport = require ( 'passport' ) ;
42const db = require ( '../../db' ) ;
53
64const configure = async ( ) => {
5+ // Temp fix for ERR_REQUIRE_ESM, will be changed when we refactor to ESM
6+ const { discovery, fetchUserInfo } = await import ( 'openid-client' ) ;
7+ const { Strategy } = await import ( 'openid-client/passport' ) ;
78 const config = require ( '../../config' ) . getAuthentication ( ) ;
89 const { oidcConfig } = config ;
910 const { issuer, clientID, clientSecret, callbackURL, scope } = oidcConfig ;
@@ -15,13 +16,13 @@ const configure = async () => {
1516 const server = new URL ( issuer ) ;
1617
1718 try {
18- const config = await openIdClient . discovery ( server , clientID , clientSecret ) ;
19+ const config = await discovery ( server , clientID , clientSecret ) ;
1920
2021 const strategy = new Strategy ( { callbackURL, config, scope } , async ( tokenSet , done ) => {
2122 // Validate token sub for added security
2223 const idTokenClaims = tokenSet . claims ( ) ;
2324 const expectedSub = idTokenClaims . sub ;
24- const userInfo = await openIdClient . fetchUserInfo ( config , tokenSet . access_token , expectedSub ) ;
25+ const userInfo = await fetchUserInfo ( config , tokenSet . access_token , expectedSub ) ;
2526 handleUserAuthentication ( userInfo , done ) ;
2627 } ) ;
2728
0 commit comments