next-auth-heksso 1.1.11 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of next-auth-heksso might be problematic. Click here for more details.

package/.eslintrc.json CHANGED
@@ -1,3 +1,3 @@
1
- {
2
- "extends": "next/core-web-vitals"
3
- }
1
+ {
2
+ "extends": "next/core-web-vitals"
3
+ }
package/README.md CHANGED
@@ -1,11 +1,11 @@
1
- # Next-Auth config for use with HEKsso (Keycloak)
2
-
3
- The rollowing environment variables are required:
4
-
5
- NEXTAUTH_SECRET
6
- NEXTAUTH_URL
7
- KEYCLOAK_ISSUER
8
- KEYCLOAK_CLIENT_ID
9
- KEYCLOAK_CLIENT_SECRET
10
-
1
+ # Next-Auth config for use with HEKsso (Keycloak)
2
+
3
+ The following environment variables are required:
4
+
5
+ NEXTAUTH_SECRET
6
+ NEXTAUTH_URL
7
+ KEYCLOAK_ISSUER
8
+ KEYCLOAK_CLIENT_ID
9
+ KEYCLOAK_CLIENT_SECRET
10
+
11
11
  See `.env.example`
@@ -1,8 +1,7 @@
1
1
  import { NextApiRequest, NextApiResponse } from "next";
2
2
  /**
3
3
  * Provides a next api route for performing a federated logout of the user (logs ouf of keycloak)
4
- * @param req NextApiRequest
5
- * @param res NextApiRequest
4
+ * @param logoutPath Post redirect URI
6
5
  * @returns
7
6
  */
8
7
  export declare function federatedLogout(logoutPath: string): (req: NextApiRequest, res: NextApiResponse) => Promise<NextApiResponse<any> | undefined>;
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
36
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
37
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -36,8 +46,7 @@ exports.federatedLogout = federatedLogout;
36
46
  const jwt = __importStar(require("next-auth/jwt"));
37
47
  /**
38
48
  * Provides a next api route for performing a federated logout of the user (logs ouf of keycloak)
39
- * @param req NextApiRequest
40
- * @param res NextApiRequest
49
+ * @param logoutPath Post redirect URI
41
50
  * @returns
42
51
  */
43
52
  function federatedLogout(logoutPath) {
package/package.json CHANGED
@@ -1,35 +1,39 @@
1
- {
2
- "name": "next-auth-heksso",
3
- "author": {
4
- "name": "Voakie",
5
- "email": "contact@voakie.com"
6
- },
7
- "license": "MIT",
8
- "version": "1.1.11",
9
- "scripts": {
10
- "prepublish": "run-script-os",
11
- "prepublish:default": "rm api/ -r && rm react/ -r && tsc",
12
- "prepublish:windows": "del /s /q api && del /s /q react",
13
- "build": "tsc",
14
- "clean": "run-script-os",
15
- "clean:default": "rm api/ -r && rm react/ -r -r",
16
- "clean:windows": "del /s /q api && del /s /q react"
17
- },
18
- "main": "api/index.js",
19
- "types": "api/index.d.ts",
20
- "dependencies": {
21
- "@types/node": "^18.11.18",
22
- "@types/react": "^18.3.3",
23
- "@types/react-dom": "^18.3.0",
24
- "eslint": "^8.0.0",
25
- "eslint-config-next": "^14.2.5",
26
- "next": "^14.2.5",
27
- "next-auth": "^4.24.7",
28
- "react": "^18.3.1",
29
- "react-dom": "^18.3.1",
30
- "typescript": "^5.5.4"
31
- },
32
- "devDependencies": {
33
- "run-script-os": "^1.1.6"
34
- }
35
- }
1
+ {
2
+ "name": "next-auth-heksso",
3
+ "author": {
4
+ "name": "Voakie",
5
+ "email": "contact@voakie.com"
6
+ },
7
+ "license": "MIT",
8
+ "version": "1.2.0",
9
+ "type": "module",
10
+ "scripts": {
11
+ "prepublish": "run-script-os",
12
+ "prepublish:default": "rm -rf api/ && rm -rf react/ && tsc",
13
+ "prepublish:windows": "del /s /q api && del /s /q react",
14
+ "build": "tsc",
15
+ "clean": "run-script-os",
16
+ "clean:default": "rm api/ -r && rm react/ -r -r",
17
+ "clean:windows": "del /s /q api && del /s /q react"
18
+ },
19
+ "main": "api/index.js",
20
+ "types": "api/index.d.ts",
21
+ "dependencies": {
22
+
23
+ },
24
+ "devDependencies": {
25
+ "run-script-os": "^1.1.6",
26
+ "@types/node": "^24",
27
+ "@types/react": "^19",
28
+ "@types/react-dom": "^19",
29
+ "eslint": "^9.13.0",
30
+ "eslint-config-next": "^16",
31
+ "typescript": "^5.6.3"
32
+ },
33
+ "peerDependencies": {
34
+ "next": "^15 || ^16",
35
+ "next-auth": "^4",
36
+ "react": "^18 || ^19",
37
+ "react-dom": "^18 || ^19"
38
+ }
39
+ }
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
36
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
37
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -1,40 +1,39 @@
1
- // /api/auth/federated-logout
2
- import { NextApiRequest, NextApiResponse } from "next"
3
- import * as jwt from "next-auth/jwt"
4
-
5
- /**
6
- * Provides a next api route for performing a federated logout of the user (logs ouf of keycloak)
7
- * @param req NextApiRequest
8
- * @param res NextApiRequest
9
- * @returns
10
- */
11
- export function federatedLogout(logoutPath: string) {
12
- return async function (req: NextApiRequest, res: NextApiResponse) {
13
- try {
14
- const token = await jwt.getToken({ req, secret: process.env.NEXTAUTH_SECRET })
15
- if (!token) {
16
- console.warn("No JWT token found when calling /federated-logout endpoint")
17
- return res.redirect(process.env.NEXTAUTH_URL || "")
18
- }
19
-
20
- const endsessionURL = `${process.env.KEYCLOAK_ISSUER}/protocol/openid-connect/logout`
21
-
22
- if (token.idToken) {
23
- console.warn(
24
- "Without an id_token the user won't be redirected back from the IdP after logout."
25
- )
26
-
27
- const endsessionParams = new URLSearchParams({
28
- id_token_hint: token.idToken as string,
29
- post_logout_redirect_uri: process.env.NEXTAUTH_URL + logoutPath || ""
30
- })
31
- return res.redirect(`${endsessionURL}?${endsessionParams}`)
32
- } else {
33
- return res.redirect(`${endsessionURL}`)
34
- }
35
- } catch (error) {
36
- console.error(error)
37
- res.redirect(process.env.NEXTAUTH_URL || "")
38
- }
39
- }
40
- }
1
+ // /api/auth/federated-logout
2
+ import { NextApiRequest, NextApiResponse } from "next"
3
+ import * as jwt from "next-auth/jwt"
4
+
5
+ /**
6
+ * Provides a next api route for performing a federated logout of the user (logs ouf of keycloak)
7
+ * @param logoutPath Post redirect URI
8
+ * @returns
9
+ */
10
+ export function federatedLogout(logoutPath: string) {
11
+ return async function (req: NextApiRequest, res: NextApiResponse) {
12
+ try {
13
+ const token = await jwt.getToken({ req, secret: process.env.NEXTAUTH_SECRET })
14
+ if (!token) {
15
+ console.warn("No JWT token found when calling /federated-logout endpoint")
16
+ return res.redirect(process.env.NEXTAUTH_URL || "")
17
+ }
18
+
19
+ const endsessionURL = `${process.env.KEYCLOAK_ISSUER}/protocol/openid-connect/logout`
20
+
21
+ if (token.idToken) {
22
+ console.warn(
23
+ "Without an id_token the user won't be redirected back from the IdP after logout."
24
+ )
25
+
26
+ const endsessionParams = new URLSearchParams({
27
+ id_token_hint: token.idToken as string,
28
+ post_logout_redirect_uri: process.env.NEXTAUTH_URL + logoutPath || ""
29
+ })
30
+ return res.redirect(`${endsessionURL}?${endsessionParams}`)
31
+ } else {
32
+ return res.redirect(`${endsessionURL}`)
33
+ }
34
+ } catch (error) {
35
+ console.error(error)
36
+ res.redirect(process.env.NEXTAUTH_URL || "")
37
+ }
38
+ }
39
+ }
package/src/api/index.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from "./federatedLogout"
2
- export * from "./nextAuthConfig"
1
+ export * from "./federatedLogout"
2
+ export * from "./nextAuthConfig"
@@ -1,67 +1,67 @@
1
- import { NextAuthOptions } from "next-auth"
2
- import KeycloakProvider from "next-auth/providers/keycloak"
3
- import { refreshAccessToken } from "./refreshAccessToken"
4
-
5
- /**
6
- * Provides authOptions for next-auth that configures it for use with the typical HEKsso setup
7
- */
8
- export function configureAuthOptions(options?: Partial<NextAuthOptions>): NextAuthOptions {
9
- let callbacks: NextAuthOptions["callbacks"] | undefined = undefined
10
-
11
- if (options && "callbacks" in options) {
12
- callbacks = options.callbacks
13
- }
14
-
15
- return {
16
- ...options,
17
- secret: process.env.NEXTAUTH_SECRET,
18
- providers: [
19
- KeycloakProvider({
20
- clientId: process.env.KEYCLOAK_CLIENT_ID || "",
21
- clientSecret: process.env.KEYCLOAK_CLIENT_SECRET || "",
22
- issuer: process.env.KEYCLOAK_ISSUER, // something like "http://localhost:8080/realms/master"
23
- authorization: { params: { scope: "openid email profile roles" } }
24
- })
25
- ],
26
- callbacks: {
27
- async jwt(data) {
28
- const hekGroups = (data.profile as any)?.hekGroups
29
-
30
- // Persist the OAuth access_token to the token right after signin
31
- if (data.account && data.user) {
32
- data.token.idToken = data.account?.id_token
33
- data.token.accessToken = data.account.access_token
34
- data.token.hekGroups = hekGroups
35
- data.token.username = (
36
- data.profile as { [key: string]: string }
37
- ).preferred_username
38
-
39
- if (data.account.expires_at)
40
- data.token.accessTokenExpires = data.account.expires_at * 1000
41
-
42
- data.token.refreshToken = data.account.refresh_token
43
- return data.token
44
- }
45
-
46
- // Return previous token if the access token has not expired yet
47
- if (Date.now() < (data.token.accessTokenExpires as number)) {
48
- return data.token
49
- }
50
-
51
- // Access token has expired, try to update it
52
- return refreshAccessToken(data.token)
53
- },
54
- async session({ session, token }) {
55
- // Send properties to the client, like an access_token from a provider.
56
- const _session = session as any
57
- _session.accessToken = token.accessToken
58
- _session.accessTokenExpires = token.accessTokenExpires
59
- _session.hekGroups = token.hekGroups || []
60
- _session.username = token.username
61
- if (token.error) _session.error = token.error
62
- return _session
63
- },
64
- ...callbacks
65
- }
66
- }
67
- }
1
+ import { NextAuthOptions } from "next-auth"
2
+ import KeycloakProvider from "next-auth/providers/keycloak"
3
+ import { refreshAccessToken } from "./refreshAccessToken"
4
+
5
+ /**
6
+ * Provides authOptions for next-auth that configures it for use with the typical HEKsso setup
7
+ */
8
+ export function configureAuthOptions(options?: Partial<NextAuthOptions>): NextAuthOptions {
9
+ let callbacks: NextAuthOptions["callbacks"] | undefined = undefined
10
+
11
+ if (options && "callbacks" in options) {
12
+ callbacks = options.callbacks
13
+ }
14
+
15
+ return {
16
+ ...options,
17
+ secret: process.env.NEXTAUTH_SECRET,
18
+ providers: [
19
+ KeycloakProvider({
20
+ clientId: process.env.KEYCLOAK_CLIENT_ID || "",
21
+ clientSecret: process.env.KEYCLOAK_CLIENT_SECRET || "",
22
+ issuer: process.env.KEYCLOAK_ISSUER, // something like "http://localhost:8080/realms/master"
23
+ authorization: { params: { scope: "openid email profile roles" } }
24
+ })
25
+ ],
26
+ callbacks: {
27
+ async jwt(data) {
28
+ const hekGroups = (data.profile as any)?.hekGroups
29
+
30
+ // Persist the OAuth access_token to the token right after signin
31
+ if (data.account && data.user) {
32
+ data.token.idToken = data.account?.id_token
33
+ data.token.accessToken = data.account.access_token
34
+ data.token.hekGroups = hekGroups
35
+ data.token.username = (
36
+ data.profile as { [key: string]: string }
37
+ ).preferred_username
38
+
39
+ if (data.account.expires_at)
40
+ data.token.accessTokenExpires = data.account.expires_at * 1000
41
+
42
+ data.token.refreshToken = data.account.refresh_token
43
+ return data.token
44
+ }
45
+
46
+ // Return previous token if the access token has not expired yet
47
+ if (Date.now() < (data.token.accessTokenExpires as number)) {
48
+ return data.token
49
+ }
50
+
51
+ // Access token has expired, try to update it
52
+ return refreshAccessToken(data.token)
53
+ },
54
+ async session({ session, token }) {
55
+ // Send properties to the client, like an access_token from a provider.
56
+ const _session = session as any
57
+ _session.accessToken = token.accessToken
58
+ _session.accessTokenExpires = token.accessTokenExpires
59
+ _session.hekGroups = token.hekGroups || []
60
+ _session.username = token.username
61
+ if (token.error) _session.error = token.error
62
+ return _session
63
+ },
64
+ ...callbacks
65
+ }
66
+ }
67
+ }
@@ -1,47 +1,47 @@
1
- import { JWT } from "next-auth/jwt"
2
-
3
- /**
4
- * Takes a token, and returns a new token with updated
5
- * `accessToken` and `accessTokenExpires`. If an error occurs,
6
- * returns the old token and an error property
7
- *
8
- * This is a utility function and not an API route
9
- */
10
- export async function refreshAccessToken(token: JWT) {
11
- try {
12
- const url = process.env.KEYCLOAK_ISSUER + "/protocol/openid-connect/token?"
13
-
14
- const response = await fetch(url, {
15
- headers: {
16
- "Content-Type": "application/x-www-form-urlencoded"
17
- },
18
- method: "POST",
19
- body: new URLSearchParams({
20
- client_id: process.env.KEYCLOAK_CLIENT_ID || "",
21
- client_secret: process.env.KEYCLOAK_CLIENT_SECRET || "",
22
- grant_type: "refresh_token",
23
- refresh_token: token.refreshToken as string
24
- })
25
- })
26
-
27
- const refreshedTokens = await response.json()
28
-
29
- if (!response.ok) {
30
- throw refreshedTokens
31
- }
32
-
33
- return {
34
- ...token,
35
- accessToken: refreshedTokens.access_token,
36
- accessTokenExpires: Date.now() + refreshedTokens.expires_in * 1000,
37
- refreshToken: refreshedTokens.refresh_token ?? token.refreshToken // Fall back to old refresh token
38
- }
39
- } catch (error) {
40
- console.log(error)
41
-
42
- return {
43
- ...token,
44
- error: "RefreshAccessTokenError"
45
- }
46
- }
1
+ import { JWT } from "next-auth/jwt"
2
+
3
+ /**
4
+ * Takes a token, and returns a new token with updated
5
+ * `accessToken` and `accessTokenExpires`. If an error occurs,
6
+ * returns the old token and an error property
7
+ *
8
+ * This is a utility function and not an API route
9
+ */
10
+ export async function refreshAccessToken(token: JWT) {
11
+ try {
12
+ const url = process.env.KEYCLOAK_ISSUER + "/protocol/openid-connect/token?"
13
+
14
+ const response = await fetch(url, {
15
+ headers: {
16
+ "Content-Type": "application/x-www-form-urlencoded"
17
+ },
18
+ method: "POST",
19
+ body: new URLSearchParams({
20
+ client_id: process.env.KEYCLOAK_CLIENT_ID || "",
21
+ client_secret: process.env.KEYCLOAK_CLIENT_SECRET || "",
22
+ grant_type: "refresh_token",
23
+ refresh_token: token.refreshToken as string
24
+ })
25
+ })
26
+
27
+ const refreshedTokens = await response.json()
28
+
29
+ if (!response.ok) {
30
+ throw refreshedTokens
31
+ }
32
+
33
+ return {
34
+ ...token,
35
+ accessToken: refreshedTokens.access_token,
36
+ accessTokenExpires: Date.now() + refreshedTokens.expires_in * 1000,
37
+ refreshToken: refreshedTokens.refresh_token ?? token.refreshToken // Fall back to old refresh token
38
+ }
39
+ } catch (error) {
40
+ console.log(error)
41
+
42
+ return {
43
+ ...token,
44
+ error: "RefreshAccessTokenError"
45
+ }
46
+ }
47
47
  }
@@ -1,192 +1,192 @@
1
- import type { signOut as nextAuthSignOut, useSession } from "next-auth/react"
2
- import React, { Component, createContext, PropsWithChildren, useContext } from "react"
3
-
4
- type NextAuthSession = ReturnType<typeof useSession>
5
-
6
- export interface KeycloakSession {
7
- accessTokenError: boolean
8
- getAccessToken: () => Promise<string>
9
- }
10
-
11
- export const KeycloakSessionContext = createContext<KeycloakSession>({
12
- accessTokenError: false,
13
- getAccessToken: async () => {
14
- return ""
15
- }
16
- })
17
-
18
- export function useKeycloakSession(): KeycloakSession {
19
- return useContext(KeycloakSessionContext)
20
- }
21
-
22
- async function refreshAccessToken() {
23
- try {
24
- const response = await fetch("/api/auth/session", {
25
- method: "GET",
26
- headers: {
27
- "Content-Type": "application/json"
28
- }
29
- })
30
-
31
- const data = await response.json()
32
-
33
- if (data.error) {
34
- console.error(data.error)
35
- return undefined
36
- }
37
-
38
- return { accessToken: data.accessToken, accessTokenExpires: data.accessTokenExpires }
39
- } catch (e: unknown) {
40
- console.error(e)
41
- return undefined
42
- }
43
- }
44
-
45
- interface KeycloakSessionProviderProps {
46
- session: ReturnType<typeof useSession>
47
- signOut: typeof nextAuthSignOut
48
- }
49
-
50
- interface KeycloakSessionProviderState {
51
- accessToken?: string
52
- accessTokenError: boolean
53
- accessTokenExpires?: number
54
- }
55
-
56
- /**
57
- * Provider for the useKeycloakSession react hook. Has to directly hook into next-auth and next/router
58
- * @param router Next.js router (retrieve with `useRouter()`)
59
- * @param session Next Auth Session (retrieve with `useSession()`)
60
- * @param signOut Next Auth Sign Out function (exported by "next-auth/react")
61
- * @param children
62
- * @constructor
63
- */
64
- export function KeycloakSessionProvider({
65
- session,
66
- signOut,
67
- children
68
- }: PropsWithChildren<{
69
- session: NextAuthSession
70
- signOut: typeof nextAuthSignOut
71
- }>) {
72
- return (
73
- <_KeycloakSessionProvider session={session} signOut={signOut}>
74
- {children}
75
- </_KeycloakSessionProvider>
76
- )
77
- }
78
-
79
- // Proxy class component to prevent unnecessary re-renders
80
- class _KeycloakSessionProvider extends Component<
81
- PropsWithChildren<KeycloakSessionProviderProps>,
82
- KeycloakSessionProviderState
83
- > {
84
- private contextValue
85
-
86
- constructor(props: KeycloakSessionProviderProps) {
87
- super(props)
88
-
89
- this.state = {
90
- accessTokenError: false
91
- }
92
-
93
- this.getAccessToken = this.getAccessToken.bind(this)
94
- this.getContextValue = this.getContextValue.bind(this)
95
-
96
- this.contextValue = {
97
- getAccessToken: this.getAccessToken,
98
- accessTokenError: false
99
- }
100
- }
101
-
102
- private getContextValue() {
103
- if (this.state.accessTokenError !== this.contextValue.accessTokenError) {
104
- this.contextValue = {
105
- getAccessToken: this.getAccessToken,
106
- accessTokenError: this.state.accessTokenError
107
- }
108
- }
109
-
110
- return this.contextValue
111
- }
112
-
113
- async getAccessToken() {
114
- if (
115
- !this.state.accessToken ||
116
- (this.state.accessTokenExpires && Date.now() >= this.state.accessTokenExpires)
117
- ) {
118
- try {
119
- const refreshed = await refreshAccessToken()
120
-
121
- if (refreshed) {
122
- this.setState({
123
- accessTokenError: false,
124
- accessToken: refreshed.accessToken,
125
- accessTokenExpires: refreshed.accessTokenExpires
126
- })
127
- return refreshed.accessToken
128
- } else {
129
- // Refresh failed due to network error
130
- return undefined
131
- }
132
- } catch (e) {
133
- // Refresh failed because keycloak denied the request
134
- console.error(e)
135
- this.setState({
136
- accessTokenError: true,
137
- accessToken: undefined,
138
- accessTokenExpires: undefined
139
- })
140
- return undefined
141
- }
142
- } else return this.state.accessToken
143
- }
144
-
145
- componentDidUpdate() {
146
- if (sessionDataGuard(this.props.session.data)) {
147
- const { error, accessToken, accessTokenExpires } = this.props.session.data
148
-
149
- if (error === "RefreshAccessTokenError") {
150
- // Force sign in to get a new refresh token
151
- this.props.signOut({ redirect: true, callbackUrl: "/" }).then()
152
- } else if (accessToken && accessToken != this.state.accessToken) {
153
- this.setState({
154
- accessToken,
155
- accessTokenExpires
156
- })
157
- } else if (!accessToken) {
158
- this.setState({
159
- accessToken: undefined,
160
- accessTokenExpires: undefined
161
- })
162
- }
163
- }
164
- }
165
-
166
- render() {
167
- return (
168
- <KeycloakSessionContext.Provider value={this.getContextValue()}>
169
- {this.props.children}
170
- </KeycloakSessionContext.Provider>
171
- )
172
- }
173
- }
174
-
175
- function sessionDataGuard(
176
- sessionData: unknown
177
- ): sessionData is { error?: string; accessToken?: string; accessTokenExpires?: number } {
178
- if (sessionData && typeof sessionData === "object") {
179
- if (!("error" in sessionData) || typeof sessionData.error === "string") {
180
- if (!("accessToken" in sessionData) || typeof sessionData.accessToken === "string") {
181
- if (
182
- !("accessTokenExpires" in sessionData) ||
183
- typeof sessionData.accessTokenExpires === "number"
184
- ) {
185
- return true
186
- }
187
- }
188
- }
189
- }
190
-
191
- return false
192
- }
1
+ import type { signOut as nextAuthSignOut, useSession } from "next-auth/react"
2
+ import React, { Component, createContext, PropsWithChildren, useContext } from "react"
3
+
4
+ type NextAuthSession = ReturnType<typeof useSession>
5
+
6
+ export interface KeycloakSession {
7
+ accessTokenError: boolean
8
+ getAccessToken: () => Promise<string>
9
+ }
10
+
11
+ export const KeycloakSessionContext = createContext<KeycloakSession>({
12
+ accessTokenError: false,
13
+ getAccessToken: async () => {
14
+ return ""
15
+ }
16
+ })
17
+
18
+ export function useKeycloakSession(): KeycloakSession {
19
+ return useContext(KeycloakSessionContext)
20
+ }
21
+
22
+ async function refreshAccessToken() {
23
+ try {
24
+ const response = await fetch("/api/auth/session", {
25
+ method: "GET",
26
+ headers: {
27
+ "Content-Type": "application/json"
28
+ }
29
+ })
30
+
31
+ const data = await response.json()
32
+
33
+ if (data.error) {
34
+ console.error(data.error)
35
+ return undefined
36
+ }
37
+
38
+ return { accessToken: data.accessToken, accessTokenExpires: data.accessTokenExpires }
39
+ } catch (e: unknown) {
40
+ console.error(e)
41
+ return undefined
42
+ }
43
+ }
44
+
45
+ interface KeycloakSessionProviderProps {
46
+ session: ReturnType<typeof useSession>
47
+ signOut: typeof nextAuthSignOut
48
+ }
49
+
50
+ interface KeycloakSessionProviderState {
51
+ accessToken?: string
52
+ accessTokenError: boolean
53
+ accessTokenExpires?: number
54
+ }
55
+
56
+ /**
57
+ * Provider for the useKeycloakSession react hook. Has to directly hook into next-auth and next/router
58
+ * @param router Next.js router (retrieve with `useRouter()`)
59
+ * @param session Next Auth Session (retrieve with `useSession()`)
60
+ * @param signOut Next Auth Sign Out function (exported by "next-auth/react")
61
+ * @param children
62
+ * @constructor
63
+ */
64
+ export function KeycloakSessionProvider({
65
+ session,
66
+ signOut,
67
+ children
68
+ }: PropsWithChildren<{
69
+ session: NextAuthSession
70
+ signOut: typeof nextAuthSignOut
71
+ }>) {
72
+ return (
73
+ <_KeycloakSessionProvider session={session} signOut={signOut}>
74
+ {children}
75
+ </_KeycloakSessionProvider>
76
+ )
77
+ }
78
+
79
+ // Proxy class component to prevent unnecessary re-renders
80
+ class _KeycloakSessionProvider extends Component<
81
+ PropsWithChildren<KeycloakSessionProviderProps>,
82
+ KeycloakSessionProviderState
83
+ > {
84
+ private contextValue
85
+
86
+ constructor(props: KeycloakSessionProviderProps) {
87
+ super(props)
88
+
89
+ this.state = {
90
+ accessTokenError: false
91
+ }
92
+
93
+ this.getAccessToken = this.getAccessToken.bind(this)
94
+ this.getContextValue = this.getContextValue.bind(this)
95
+
96
+ this.contextValue = {
97
+ getAccessToken: this.getAccessToken,
98
+ accessTokenError: false
99
+ }
100
+ }
101
+
102
+ private getContextValue() {
103
+ if (this.state.accessTokenError !== this.contextValue.accessTokenError) {
104
+ this.contextValue = {
105
+ getAccessToken: this.getAccessToken,
106
+ accessTokenError: this.state.accessTokenError
107
+ }
108
+ }
109
+
110
+ return this.contextValue
111
+ }
112
+
113
+ async getAccessToken() {
114
+ if (
115
+ !this.state.accessToken ||
116
+ (this.state.accessTokenExpires && Date.now() >= this.state.accessTokenExpires)
117
+ ) {
118
+ try {
119
+ const refreshed = await refreshAccessToken()
120
+
121
+ if (refreshed) {
122
+ this.setState({
123
+ accessTokenError: false,
124
+ accessToken: refreshed.accessToken,
125
+ accessTokenExpires: refreshed.accessTokenExpires
126
+ })
127
+ return refreshed.accessToken
128
+ } else {
129
+ // Refresh failed due to network error
130
+ return undefined
131
+ }
132
+ } catch (e) {
133
+ // Refresh failed because keycloak denied the request
134
+ console.error(e)
135
+ this.setState({
136
+ accessTokenError: true,
137
+ accessToken: undefined,
138
+ accessTokenExpires: undefined
139
+ })
140
+ return undefined
141
+ }
142
+ } else return this.state.accessToken
143
+ }
144
+
145
+ componentDidUpdate() {
146
+ if (sessionDataGuard(this.props.session.data)) {
147
+ const { error, accessToken, accessTokenExpires } = this.props.session.data
148
+
149
+ if (error === "RefreshAccessTokenError") {
150
+ // Force sign in to get a new refresh token
151
+ this.props.signOut({ redirect: true, callbackUrl: "/" }).then()
152
+ } else if (accessToken && accessToken != this.state.accessToken) {
153
+ this.setState({
154
+ accessToken,
155
+ accessTokenExpires
156
+ })
157
+ } else if (!accessToken) {
158
+ this.setState({
159
+ accessToken: undefined,
160
+ accessTokenExpires: undefined
161
+ })
162
+ }
163
+ }
164
+ }
165
+
166
+ render() {
167
+ return (
168
+ <KeycloakSessionContext.Provider value={this.getContextValue()}>
169
+ {this.props.children}
170
+ </KeycloakSessionContext.Provider>
171
+ )
172
+ }
173
+ }
174
+
175
+ function sessionDataGuard(
176
+ sessionData: unknown
177
+ ): sessionData is { error?: string; accessToken?: string; accessTokenExpires?: number } {
178
+ if (sessionData && typeof sessionData === "object") {
179
+ if (!("error" in sessionData) || typeof sessionData.error === "string") {
180
+ if (!("accessToken" in sessionData) || typeof sessionData.accessToken === "string") {
181
+ if (
182
+ !("accessTokenExpires" in sessionData) ||
183
+ typeof sessionData.accessTokenExpires === "number"
184
+ ) {
185
+ return true
186
+ }
187
+ }
188
+ }
189
+ }
190
+
191
+ return false
192
+ }
package/tsconfig.json CHANGED
@@ -1,104 +1,104 @@
1
- {
2
- "compilerOptions": {
3
- /* Visit https://aka.ms/tsconfig to read more about this file */
4
-
5
- /* Projects */
6
- // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
7
- // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8
- // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
9
- // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
10
- // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11
- // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12
-
13
- /* Language and Environment */
14
- "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
15
- // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16
- "jsx": "react", /* Specify what JSX code is generated. */
17
- // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
18
- // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
19
- // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
20
- // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
21
- // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
22
- // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
23
- // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
24
- // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
25
- // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
26
-
27
- /* Modules */
28
- "module": "commonjs", /* Specify what module code is generated. */
29
- "rootDir": "./src", /* Specify the root folder within your source files. */
30
- // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
31
- // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
32
- // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
33
- // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
34
- // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
35
- // "types": [], /* Specify type package names to be included without being referenced in a source file. */
36
- // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
37
- // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
38
- // "resolveJsonModule": true, /* Enable importing .json files. */
39
- // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
40
-
41
- /* JavaScript Support */
42
- // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
43
- // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
44
- // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
45
-
46
- /* Emit */
47
- "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
48
- // "declarationMap": true, /* Create sourcemaps for d.ts files. */
49
- // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
50
- // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
51
- // "outFile": "./lib/index.js", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
52
- "outDir": ".", /* Specify an output folder for all emitted files. */
53
- // "removeComments": true, /* Disable emitting comments. */
54
- // "noEmit": true, /* Disable emitting files from a compilation. */
55
- // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
56
- // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
57
- // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
58
- // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
59
- // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
60
- // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
61
- // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
62
- // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
63
- // "newLine": "crlf", /* Set the newline character for emitting files. */
64
- // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
65
- // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
66
- // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
67
- // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
68
- // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
69
- // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
70
-
71
- /* Interop Constraints */
72
- // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
73
- // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
74
- "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
75
- // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
76
- "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
77
-
78
- /* Type Checking */
79
- "strict": true, /* Enable all strict type-checking options. */
80
- // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
81
- // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
82
- // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
83
- // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
84
- // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
85
- // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
86
- // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
87
- // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
88
- // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
89
- // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
90
- // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
91
- // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
92
- // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
93
- // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
94
- // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
95
- // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
96
- // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
97
- // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
98
-
99
- /* Completeness */
100
- // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
101
- "skipLibCheck": true /* Skip type checking all .d.ts files. */
102
- },
103
- "exclude": ["api", "react", "node_modules"]
104
- }
1
+ {
2
+ "compilerOptions": {
3
+ /* Visit https://aka.ms/tsconfig to read more about this file */
4
+
5
+ /* Projects */
6
+ // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
7
+ // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8
+ // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
9
+ // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
10
+ // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11
+ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12
+
13
+ /* Language and Environment */
14
+ "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
15
+ // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16
+ "jsx": "react", /* Specify what JSX code is generated. */
17
+ // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
18
+ // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
19
+ // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
20
+ // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
21
+ // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
22
+ // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
23
+ // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
24
+ // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
25
+ // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
26
+
27
+ /* Modules */
28
+ "module": "commonjs", /* Specify what module code is generated. */
29
+ "rootDir": "./src", /* Specify the root folder within your source files. */
30
+ // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
31
+ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
32
+ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
33
+ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
34
+ // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
35
+ // "types": [], /* Specify type package names to be included without being referenced in a source file. */
36
+ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
37
+ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
38
+ // "resolveJsonModule": true, /* Enable importing .json files. */
39
+ // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
40
+
41
+ /* JavaScript Support */
42
+ // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
43
+ // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
44
+ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
45
+
46
+ /* Emit */
47
+ "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
48
+ // "declarationMap": true, /* Create sourcemaps for d.ts files. */
49
+ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
50
+ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
51
+ // "outFile": "./lib/index.js", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
52
+ "outDir": ".", /* Specify an output folder for all emitted files. */
53
+ // "removeComments": true, /* Disable emitting comments. */
54
+ // "noEmit": true, /* Disable emitting files from a compilation. */
55
+ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
56
+ // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
57
+ // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
58
+ // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
59
+ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
60
+ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
61
+ // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
62
+ // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
63
+ // "newLine": "crlf", /* Set the newline character for emitting files. */
64
+ // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
65
+ // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
66
+ // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
67
+ // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
68
+ // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
69
+ // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
70
+
71
+ /* Interop Constraints */
72
+ // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
73
+ // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
74
+ "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
75
+ // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
76
+ "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
77
+
78
+ /* Type Checking */
79
+ "strict": true, /* Enable all strict type-checking options. */
80
+ // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
81
+ // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
82
+ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
83
+ // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
84
+ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
85
+ // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
86
+ // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
87
+ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
88
+ // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
89
+ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
90
+ // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
91
+ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
92
+ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
93
+ // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
94
+ // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
95
+ // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
96
+ // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
97
+ // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
98
+
99
+ /* Completeness */
100
+ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
101
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */
102
+ },
103
+ "exclude": ["api", "react", "node_modules"]
104
+ }