I want to use auth.js in my Qwik app. This is my [email protected] file:
import { serverAuth$ } from '@builder.io/qwik-auth';
import Keycloak from "@auth/core/providers/keycloak";
const {
onRequest,
useAuthSession,
useAuthSignin,
useAuthSignout,
} = serverAuth$(({ env }) => ({
secret: env.get("AUTH_SECRET"),
trustHost: true,
providers: [
Keycloak({
clientId: 'Site',
clientSecret: env.get('KEYCLOAK_CLIENT_SECRET'),
issuer: env.get('KEYCLOAK_ISSUER')
}),
],
}));
export { onRequest }
export { useAuthSession }
export { useAuthSignin }
export { useAuthSignout }
I have figured it out from combining docs of Qwick and auth.js.
It works great in the development mode. I have made a test page where I have a sign-in button, and when user logs in, I show him his email and the sign-out button.
However, when I run npm run build I get this error:
src/routes/[email protected](13,9): error TS2322: Type 'OAuthConfig<KeycloakProfile>' is not assignable to type 'Provider'.
Type 'OIDCConfig<KeycloakProfile>' is not assignable to type 'Provider'.
Type 'OIDCConfig<KeycloakProfile>' is not assignable to type 'OIDCConfig<Profile> & InternalProviderOptions'.
Type 'OIDCConfig<KeycloakProfile>' is not assignable to type 'OIDCConfig<Profile>'.
Type 'Profile' is missing the following properties from type 'KeycloakProfile': exp, iat, auth_time, jti, and 14 more.
src/routes/[email protected](15,13): error TS2322: Type 'string | undefined' is not assignable to type 'string'.
Type 'undefined' is not assignable to type 'string'.