diff --git a/src/config/index.js b/src/config/index.js index bfd7e65..5ca04a2 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -1,3 +1,6 @@ +import {GrantType} from '@kinde-oss/kinde-typescript-sdk'; +import {version} from '../utils/version'; + const initialState = { user: null, isLoading: true, @@ -9,9 +12,10 @@ const SESSION_PREFIX = 'pkce-verifier'; const KINDE_SITE_URL = process.env.KINDE_SITE_URL; // We need to use NEXT_PUBLIC for frontend vars -const KINDE_AUTH_API_PATH = process.env.NEXT_PUBLIC_KINDE_AUTH_API_PATH - || process.env.KINDE_AUTH_API_PATH - || '/api/auth'; +const KINDE_AUTH_API_PATH = + process.env.NEXT_PUBLIC_KINDE_AUTH_API_PATH || + process.env.KINDE_AUTH_API_PATH || + '/api/auth'; const KINDE_POST_LOGIN_REDIRECT_URL = process.env.KINDE_POST_LOGIN_REDIRECT_URL || @@ -47,5 +51,16 @@ export const config = { register: '/oauth2/auth', token: '/oauth2/token', profile: '/oauth2/v2/user_profile' - } + }, + clientOptions: { + audience: KINDE_AUDIENCE, + authDomain: KINDE_ISSUER_URL, + clientId: KINDE_CLIENT_ID, + clientSecret: KINDE_CLIENT_SECRET, + logoutRedirectURL: KINDE_POST_LOGOUT_REDIRECT_URL, + redirectURL: `${KINDE_SITE_URL}/api/auth/kinde_callback`, + frameworkVersion: version, + framework: 'Next.js' + }, + grantType: GrantType.AUTHORIZATION_CODE }; diff --git a/src/handlers/appRouter/callback.js b/src/handlers/appRouter/callback.js deleted file mode 100644 index 8bde5a9..0000000 --- a/src/handlers/appRouter/callback.js +++ /dev/null @@ -1,71 +0,0 @@ -import jwt_decode from 'jwt-decode'; -import {config} from '../../config/index'; -import {version} from '../../utils/version'; -import {cookies} from 'next/headers'; -import {redirect} from 'next/navigation'; - -export const callback = async (request) => { - const code = request.nextUrl.searchParams.get('code'); - const state = request.nextUrl.searchParams.get('state'); - - const cookieStore = cookies(); - const code_verifier = cookieStore.get(`${config.SESSION_PREFIX}-${state}`); - if (code_verifier) { - try { - const response = await fetch( - config.issuerURL + config.issuerRoutes.token, - { - method: 'POST', - headers: new Headers({ - 'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8', - 'Kinde-SDK': `"NextJS"/${version}` - }), - body: new URLSearchParams({ - client_id: config.clientID, - client_secret: config.clientSecret, - code: code, - code_verifier: code_verifier.value, - grant_type: 'authorization_code', - redirect_uri: `${config.redirectURL}${config.redirectRoutes.callback}` - }) - } - ); - const data = await response.json(); - const tokenHeader = jwt_decode(data.access_token, {header: true}); - const payload = jwt_decode(data.access_token); - let isAudienceValid = true; - - if (config.audience) - isAudienceValid = payload.aud && payload.aud.includes(config.audience); - - if ( - payload.iss === config.issuerURL && - tokenHeader.alg === 'RS256' && - payload.exp > Math.floor(Date.now() / 1000) && - isAudienceValid - ) { - cookies().set({ - name: 'kinde_token', - value: JSON.stringify(data), - httpOnly: true, - expires: new Date(payload.exp * 1000), - sameSite: 'lax', - secure: config.redirectURL.substring(0, 6) == 'https:', - path: '/' - }); - } else { - console.error('One or more of the claims were not verified.'); - } - } catch (err) { - console.error({err}); - } - const redirectUrl = config.postLoginRedirectURL - ? config.postLoginRedirectURL - : config.redirectURL; - redirect(redirectUrl); - } else { - const logoutURL = new URL(config.issuerURL + config.issuerRoutes.logout); - logoutURL.searchParams.set('redirect', config.postLogoutRedirectURL); - redirect(logoutURL.href); - } -}; diff --git a/src/handlers/appRouter/createOrg.js b/src/handlers/appRouter/createOrg.js deleted file mode 100644 index 8bde922..0000000 --- a/src/handlers/appRouter/createOrg.js +++ /dev/null @@ -1,13 +0,0 @@ -import {prepareForRedirect} from '../../utils/appRouter/prepareForRedirect'; -import {redirect} from 'next/navigation'; - -export const createOrg = async (request) => { - const org_name = request.nextUrl.searchParams.get('org_name'); - const options = { - org_name, - is_create_org: true - }; - const authUrl = prepareForRedirect(options, 'register'); - - redirect(authUrl); -}; diff --git a/src/handlers/appRouter/handleAuth.js b/src/handlers/appRouter/handleAuth.js deleted file mode 100644 index 3a6d96f..0000000 --- a/src/handlers/appRouter/handleAuth.js +++ /dev/null @@ -1,26 +0,0 @@ -import {redirect} from 'next/navigation'; -import {login} from './login'; -import {logout} from './logout'; -import {register} from './register'; -import {callback} from './callback'; -import {createOrg} from './createOrg'; - -const routeMap = { - create_org: createOrg, - register, - login, - logout, - kinde_callback: callback -}; - -const getRoute = (endpoint) => { - return routeMap[endpoint]; -}; - -export async function handleAuth(request, endpoint) { - const route = getRoute(endpoint); - - return route - ? await route(request) - : new Response('This page could not be found.', {status: 404}); -} diff --git a/src/handlers/appRouter/index.js b/src/handlers/appRouter/index.js deleted file mode 100644 index 85aef87..0000000 --- a/src/handlers/appRouter/index.js +++ /dev/null @@ -1 +0,0 @@ -export {handleAuth} from './handleAuth'; diff --git a/src/handlers/appRouter/login.js b/src/handlers/appRouter/login.js deleted file mode 100644 index 5355a1a..0000000 --- a/src/handlers/appRouter/login.js +++ /dev/null @@ -1,11 +0,0 @@ -import {generateAuthUrl} from '../../utils/generateAuthUrl'; -import {redirect} from 'next/navigation'; -import {prepareForRedirect} from '../../utils/appRouter/prepareForRedirect'; - -export const login = async (request) => { - const org_code = request.nextUrl.searchParams.get('org_code'); - const options = {org_code}; - const authUrl = prepareForRedirect(options); - - redirect(authUrl); -}; diff --git a/src/handlers/appRouter/logout.js b/src/handlers/appRouter/logout.js deleted file mode 100644 index c87ad57..0000000 --- a/src/handlers/appRouter/logout.js +++ /dev/null @@ -1,20 +0,0 @@ -import {redirect} from 'next/navigation'; -import {cookies} from 'next/headers'; -import {config} from '../../config/index'; - -export const logout = async (request) => { - const cookieStore = cookies(); - cookies().set({ - name: 'kinde_token', - value: '', - httpOnly: true, - expires: new Date(0), - sameSite: 'lax', - secure: config.redirectURL.substring(0, 6) == 'https:', - path: '/' - }); - - const logoutURL = new URL(config.issuerURL + config.issuerRoutes.logout); - logoutURL.searchParams.set('redirect', config.postLogoutRedirectURL || ''); - redirect(logoutURL.href); -}; diff --git a/src/handlers/appRouter/register.js b/src/handlers/appRouter/register.js deleted file mode 100644 index 8ac0aeb..0000000 --- a/src/handlers/appRouter/register.js +++ /dev/null @@ -1,12 +0,0 @@ -import {prepareForRedirect} from '../../utils/appRouter/prepareForRedirect'; -import {redirect} from 'next/navigation'; - -export const register = async (request) => { - const org_code = request.nextUrl.searchParams.get('org_code'); - - const options = {org_code}; - - const authUrl = prepareForRedirect(options, 'register'); - - redirect(authUrl); -}; diff --git a/src/handlers/auth.js b/src/handlers/auth.js new file mode 100644 index 0000000..3796a52 --- /dev/null +++ b/src/handlers/auth.js @@ -0,0 +1,55 @@ +import {isAppRouter} from '../utils/isAppRouter'; +import {callback} from './callback'; +import {createOrg} from './createOrg'; +import {login} from './login'; +import {logout} from './logout'; +import {setup} from './setup'; +import {register} from './register'; +import AppRouterClient from '../routerClients/AppRouterClient'; +import PagesRouterClient from '../routerClients/PagesRouterClient'; + +const routeMap = { + create_org: createOrg, + register, + setup, + login, + logout, + kinde_callback: callback +}; + +const getRoute = (endpoint) => { + return routeMap[endpoint]; +}; + +/** + * @param {Request} [req] + * @param {Response} [res] + */ +export default () => + async function handler(req, res) { + return isAppRouter(req) + ? appRouterHandler(req, res) + : pagesRouterHandler(req, res); + }; + +const appRouterHandler = async (req, res) => { + const {params} = res; + let endpoint = params.kindeAuth; + endpoint = Array.isArray(endpoint) ? endpoint[0] : endpoint; + const route = getRoute(endpoint); + + return route + ? await route(new AppRouterClient(req, res)) + : new Response('This page could not be found.', {status: 404}); +}; + +const pagesRouterHandler = async (req, res) => { + let { + query: {kindeAuth: endpoint} + } = req; + endpoint = Array.isArray(endpoint) ? endpoint[0] : endpoint; + const route = getRoute(endpoint); + return route + ? await route(new PagesRouterClient(req, res)) + : res.status(404).end(); +}; diff --git a/src/handlers/callback.js b/src/handlers/callback.js new file mode 100644 index 0000000..ec419fb --- /dev/null +++ b/src/handlers/callback.js @@ -0,0 +1,22 @@ +import {config} from '../config/index'; + +export const callback = async (routerClient) => { + await routerClient.kindeClient.handleRedirectToApp( + routerClient.sessionManager, + routerClient.getUrl() + ); + + const kindeNextPage = + routerClient.sessionManager.getSessionItem('kinde_next_page'); + if (kindeNextPage) + routerClient.sessionManager.removeSessionItem('kinde_next_page'); + + console.log('KINDE NEXT PAGE', kindeNextPage); + + const postLoginRedirectURL = kindeNextPage + ? kindeNextPage + : config.postLoginRedirectURL; + // const postLoginRedirectURL = config.postLoginRedirectURL + + routerClient.redirect(postLoginRedirectURL); +}; diff --git a/src/handlers/createOrg.js b/src/handlers/createOrg.js new file mode 100644 index 0000000..919a947 --- /dev/null +++ b/src/handlers/createOrg.js @@ -0,0 +1,14 @@ +export const createOrg = async (routerClient) => { + const org_name = routerClient.getSearchParam('org_name'); + const options = { + org_name, + is_create_org: true + }; + + const authUrl = await routerClient.kindeClient.createOrg( + routerClient.sessionManager, + options + ); + + routerClient.redirect(authUrl); +}; diff --git a/src/handlers/login.js b/src/handlers/login.js new file mode 100644 index 0000000..26efafa --- /dev/null +++ b/src/handlers/login.js @@ -0,0 +1,7 @@ +export const login = async (routerClient) => { + const authUrl = await routerClient.kindeClient.login( + routerClient.sessionManager + ); + + routerClient.redirect(authUrl); +}; diff --git a/src/handlers/logout.js b/src/handlers/logout.js new file mode 100644 index 0000000..c36707f --- /dev/null +++ b/src/handlers/logout.js @@ -0,0 +1,7 @@ +export const logout = async (routerClient) => { + const authUrl = await routerClient.kindeClient.logout( + routerClient.sessionManager + ); + + routerClient.redirect(authUrl); +}; diff --git a/src/handlers/pageRouter/callback.js b/src/handlers/pageRouter/callback.js deleted file mode 100644 index afe2628..0000000 --- a/src/handlers/pageRouter/callback.js +++ /dev/null @@ -1,77 +0,0 @@ -import jwt_decode from 'jwt-decode'; - -import {config} from '../../config/index'; -import {isTokenValid} from '../../utils/pageRouter/isTokenValid'; -import {version} from '../../utils/version'; -import {sanitizeRedirect} from '../../utils/sanitizeRedirect'; - -var cookie = require('cookie'); - -export const callback = async (req, res) => { - const {code, state} = req.query; - const jsonCookieValue = cookie.parse(req.headers.cookie || '')[ - `${config.SESSION_PREFIX}-${state}` - ]; - - let redirectUrl = config.postLoginRedirectURL || config.redirectURL; - - if (jsonCookieValue) { - try { - const { - code_verifier, - options, - } = JSON.parse(jsonCookieValue); - - if (options?.post_login_redirect_url) { - redirectUrl = sanitizeRedirect({ - baseUrl: new URL(config.redirectURL).origin, - url: options.post_login_redirect_url - }); - } - - const response = await fetch( - config.issuerURL + config.issuerRoutes.token, - { - method: 'POST', - headers: new Headers({ - 'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8', - 'Kinde-SDK': `"NextJS"/${version}` - }), - body: new URLSearchParams({ - client_id: config.clientID, - client_secret: config.clientSecret, - code, - code_verifier, - grant_type: 'authorization_code', - redirect_uri: config.redirectURL + config.redirectRoutes.callback - }) - } - ); - const data = await response.json(); - - const accessToken = jwt_decode(data.access_token); - if (isTokenValid(data)) { - res.setHeader( - 'Set-Cookie', - cookie.serialize(`kinde_token`, JSON.stringify(data), { - httpOnly: true, - expires: new Date(accessToken.exp * 1000), - sameSite: 'lax', - secure: config.redirectURL.substring(0, 6) == 'https:', - path: '/' - }) - ); - } else { - console.error('One or more of the claims were not verified.'); - } - } catch (err) { - console.error(err); - } - - res.redirect(redirectUrl); - } else { - const logoutURL = new URL(config.issuerURL + config.issuerRoutes.logout); - logoutURL.searchParams.set('redirect', config.postLogoutRedirectURL); - res.redirect(logoutURL.href); - } -}; diff --git a/src/handlers/pageRouter/createOrg.js b/src/handlers/pageRouter/createOrg.js deleted file mode 100644 index adfb5df..0000000 --- a/src/handlers/pageRouter/createOrg.js +++ /dev/null @@ -1,12 +0,0 @@ -import {prepareForRedirect} from '../../utils/pageRouter/prepareForRedirect'; - -export const createOrg = async (req, res) => { - const {org_name = ''} = req.query.options; - const options = { - org_name, - is_create_org: true - }; - const authUrl = prepareForRedirect(options, 'register', res); - - res.redirect(authUrl); -}; diff --git a/src/handlers/pageRouter/getToken.js b/src/handlers/pageRouter/getToken.js deleted file mode 100644 index 46cd5c5..0000000 --- a/src/handlers/pageRouter/getToken.js +++ /dev/null @@ -1,10 +0,0 @@ -export const getToken = async (req, res) => { - if (req.cookies.kinde_token) { - res.status(200).json(JSON.parse(req.cookies.kinde_token)); - } else { - res.status(500).json({ - message: - 'There is no kinde_token, you are not authenticated. Try logging in.' - }); - } -}; diff --git a/src/handlers/pageRouter/handleAuth.js b/src/handlers/pageRouter/handleAuth.js deleted file mode 100644 index 562129c..0000000 --- a/src/handlers/pageRouter/handleAuth.js +++ /dev/null @@ -1,35 +0,0 @@ -import {login} from './login'; -import {logout} from './logout'; -import {me} from './me'; -import {register} from './register'; -import {callback} from './callback'; -import {createOrg} from './createOrg'; -import {getToken} from './getToken'; -import {setup} from './setup'; - -const getRoute = (endpoint) => { - const routeMap = { - create_org: createOrg, - get_token: getToken, - kinde_callback: callback, - login, - logout, - me, - register, - setup - }; - return routeMap[endpoint]; -}; - -export default () => - async function handler(req, res) { - let { - query: {kindeAuth: endpoint} - } = req; - - endpoint = Array.isArray(endpoint) ? endpoint[0] : endpoint; - - const route = getRoute(endpoint); - - return route ? await route(req, res) : res.status(404).end(); - }; diff --git a/src/handlers/pageRouter/index.js b/src/handlers/pageRouter/index.js deleted file mode 100644 index af15469..0000000 --- a/src/handlers/pageRouter/index.js +++ /dev/null @@ -1 +0,0 @@ -export {default as handleAuth} from './handleAuth'; diff --git a/src/handlers/pageRouter/login.js b/src/handlers/pageRouter/login.js deleted file mode 100644 index 5dcfe7f..0000000 --- a/src/handlers/pageRouter/login.js +++ /dev/null @@ -1,10 +0,0 @@ -import {prepareForRedirect} from '../../utils/pageRouter/prepareForRedirect'; - -export const login = async (req, res) => { - const options = req.query; - const {org_code, is_create_org, org_name = ''} = options; - - const authUrl = prepareForRedirect(options, 'login', res); - - res.redirect(authUrl); -}; diff --git a/src/handlers/pageRouter/logout.js b/src/handlers/pageRouter/logout.js deleted file mode 100644 index 6481c52..0000000 --- a/src/handlers/pageRouter/logout.js +++ /dev/null @@ -1,22 +0,0 @@ -import {config} from '../../config/index'; - -var cookie = require('cookie'); - -export const logout = async (req, res) => { - res.setHeader( - 'Set-Cookie', - cookie.serialize('kinde_token', null, { - httpOnly: true, - expires: new Date(0), - sameSite: 'lax', - secure: config.redirectURL.substring(0, 6) == 'https:', - path: '/' - }) - ); - - const logoutURL = new URL(config.issuerURL + config.issuerRoutes.logout); - - logoutURL.searchParams.set('redirect', config.postLogoutRedirectURL); - - res.redirect(logoutURL.href); -}; diff --git a/src/handlers/pageRouter/me.js b/src/handlers/pageRouter/me.js deleted file mode 100644 index d7352d3..0000000 --- a/src/handlers/pageRouter/me.js +++ /dev/null @@ -1,28 +0,0 @@ -import {config} from '../../config/index'; - -var cookie = require('cookie'); - -export const me = async (req, res) => { - const kinde_token = cookie.parse(req.headers.cookie || '')['kinde_token']; - if (kinde_token) { - const token = JSON.parse(kinde_token); - try { - const response = await fetch( - config.issuerURL + config.issuerRoutes.profile, - { - headers: new Headers({ - Authorization: 'Bearer ' + token.access_token - }) - } - ); - const data = await response.json(); - res.send(data); - } catch (err) { - console.error(err); - } - } else { - res.status(401).send({ - message: 'Unauthorized' - }); - } -}; diff --git a/src/handlers/pageRouter/register.js b/src/handlers/pageRouter/register.js deleted file mode 100644 index 73eb280..0000000 --- a/src/handlers/pageRouter/register.js +++ /dev/null @@ -1,10 +0,0 @@ -import {prepareForRedirect} from '../../utils/pageRouter/prepareForRedirect'; - -export const register = async (req, res) => { - const options = req.query; - const {org_code, is_create_org, org_name = ''} = options; - - const authUrl = prepareForRedirect(options, 'register', res); - - res.redirect(authUrl); -}; diff --git a/src/handlers/pageRouter/setup.js b/src/handlers/pageRouter/setup.js deleted file mode 100644 index af49ec5..0000000 --- a/src/handlers/pageRouter/setup.js +++ /dev/null @@ -1,22 +0,0 @@ -const cookie = require('cookie'); -import jwt_decode from 'jwt-decode'; - -export const setup = async (req, res) => { - res.setHeader('Cache-Control', 'no-cache'); - const kinde_token = cookie.parse(req.headers.cookie || '')['kinde_token']; - - if (kinde_token) { - const token = JSON.parse(kinde_token); - const accessTokenPayload = jwt_decode(token.access_token); - const idTokenPayload = jwt_decode(token.id_token); - res.send({ - access_token_encoded: token.access_token, - id_token: idTokenPayload, - access_token: accessTokenPayload - }); - } else { - res.status(401).send({ - message: 'Unauthorized' - }); - } -}; diff --git a/src/handlers/register.js b/src/handlers/register.js new file mode 100644 index 0000000..0322133 --- /dev/null +++ b/src/handlers/register.js @@ -0,0 +1,7 @@ +export const register = async (routerClient) => { + const authUrl = await routerClient.kindeClient.register( + routerClient.sessionManager + ); + + routerClient.redirect(authUrl); +}; diff --git a/src/handlers/setup.js b/src/handlers/setup.js new file mode 100644 index 0000000..741c2ad --- /dev/null +++ b/src/handlers/setup.js @@ -0,0 +1,44 @@ +export const setup = async (routerClient) => { + const user = routerClient.sessionManager.getSessionItem('user'); + if (user) { + const accessToken = routerClient.sessionManager.getSessionItem( + 'access_token_payload' + ); + + const idToken = + routerClient.sessionManager.getSessionItem('id_token_payload'); + + const permissions = await routerClient.kindeClient.getClaimValue( + routerClient.sessionManager, + 'permissions' + ); + + const organization = await routerClient.kindeClient.getClaimValue( + routerClient.sessionManager, + 'org_code' + ); + + const featureFlags = await routerClient.kindeClient.getClaimValue( + routerClient.sessionManager, + 'feature_flags' + ); + + const userOrganizations = await routerClient.kindeClient.getClaimValue( + routerClient.sessionManager, + 'org_codes', + 'id_token' + ); + + return routerClient.json({ + accessToken, + idToken, + user, + permissions, + organization, + featureFlags, + userOrganizations + }); + } else { + return routerClient.json({error: 'Log in with Kinde'}); + } +}; diff --git a/src/index.js b/src/index.js index abbc17e..35419d0 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,3 @@ export {KindeProvider, useKindeAuth} from './frontend/index'; -export {handleAuth} from './handlers/pageRouter/index'; export {isTokenValid} from './utils/pageRouter/isTokenValid'; export * from './session/pagesRouter/index'; diff --git a/src/routerClients/AppRouterClient.js b/src/routerClients/AppRouterClient.js new file mode 100644 index 0000000..a19ff37 --- /dev/null +++ b/src/routerClients/AppRouterClient.js @@ -0,0 +1,34 @@ +import {createKindeServerClient} from '@kinde-oss/kinde-typescript-sdk'; +import {cookies} from 'next/headers'; +import {redirect} from 'next/navigation'; +import {NextResponse} from 'next/server'; +import {config} from '../config/index'; +import {appRouterSessionManager} from '../session/sessionManager'; + +export default class AppRouterClient { + constructor(req, res) { + this.kindeClient = createKindeServerClient( + config.grantType, + config.clientOptions + ); + this.url = new URL(req.url); + this.sessionManager = appRouterSessionManager(cookies()); + this.req = req; + } + + redirect(url) { + return redirect(url); + } + + getUrl() { + return this.url; + } + + json(data) { + return NextResponse.json(data); + } + + getSearchParam(key) { + return this.req.nextUrl.searchParams.get(key); + } +} diff --git a/src/routerClients/PagesRouterClient.js b/src/routerClients/PagesRouterClient.js new file mode 100644 index 0000000..d4422bc --- /dev/null +++ b/src/routerClients/PagesRouterClient.js @@ -0,0 +1,32 @@ +import {createKindeServerClient} from '@kinde-oss/kinde-typescript-sdk'; +import {config} from '../config/index'; +import {sessionManager} from '../session/sessionManager'; + +export default class PagesRouterClient { + constructor(req, res) { + this.kindeClient = createKindeServerClient( + config.grantType, + config.clientOptions + ); + this.url = new URL(config.redirectURL + req.url); + this.res = res; + this.req = req; + this.sessionManager = sessionManager(req, res); + } + + redirect(url) { + return this.res.redirect(url.href ? url.href : url); + } + + getUrl() { + return this.url; + } + + json(data) { + return this.res.send(data); + } + + getSearchParam(key) { + return this.url.searchParams.get(key); + } +} diff --git a/src/routerClients/RouterClient.js b/src/routerClients/RouterClient.js new file mode 100644 index 0000000..8fd1ca4 --- /dev/null +++ b/src/routerClients/RouterClient.js @@ -0,0 +1,19 @@ +export default class AppRouterClient { + constructor() { + if (this.constructor == AppRouterClient) { + throw new Error("Abstract classes can't be instantiated."); + } + } + + redirect() { + throw new Error("Method 'redirect()' must be implemented."); + } + + json() { + throw new Error("Method 'json()' must be implemented."); + } + + getSearchParam() { + throw new Error("Method 'getSearchParam()' must be implemented."); + } +} diff --git a/src/server/index.js b/src/server/index.js index 29257bf..ef928c9 100644 --- a/src/server/index.js +++ b/src/server/index.js @@ -1,4 +1,4 @@ -export {handleAuth} from '../handlers/appRouter/index'; +// export {handleAuth} from '../handlers/appRouter/index'; import * as serverSession from '../session/appRouter/index'; export const getKindeServerSession = () => { @@ -12,3 +12,4 @@ export {LoginLink} from '../components/LoginLink'; export {LogoutLink} from '../components/LogoutLink'; export {CreateOrgLink} from '../components/CreateOrgLink'; export {createKindeManagementAPIClient} from '../api-client'; +export {default as handleAuth} from '../handlers/auth';