Skip to content

Commit 0a0656d

Browse files
committed
fix(auth): attempt to fix CI ERR_REQUIRE_ESM
1 parent 4f71e77 commit 0a0656d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/service/passport/oidc.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
const openIdClient = require('openid-client');
2-
const { Strategy } = require('openid-client/passport');
31
const passport = require('passport');
42
const db = require('../../db');
53

64
const 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

Comments
 (0)