@multiplatform.one/keycloak 1.0.36 → 2.0.1
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.
- package/dist/cjs/Authenticated.js +9 -4
- package/dist/cjs/Authenticated.js.map +1 -1
- package/dist/cjs/Authenticated.native.js +7 -22
- package/dist/cjs/Authenticated.native.js.map +2 -2
- package/dist/cjs/Loading.js +25 -0
- package/dist/cjs/Loading.js.map +6 -0
- package/dist/cjs/Loading.native.js +31 -0
- package/dist/cjs/Loading.native.js.map +6 -0
- package/dist/cjs/hooks/useTokensFromState.js +5 -4
- package/dist/cjs/hooks/useTokensFromState.js.map +1 -1
- package/dist/cjs/hooks/useTokensFromState.native.js +6 -5
- package/dist/cjs/hooks/useTokensFromState.native.js.map +2 -2
- package/dist/cjs/keycloak/context.js.map +1 -1
- package/dist/cjs/keycloak/context.native.js.map +1 -1
- package/dist/cjs/keycloak/keycloak.js +10 -7
- package/dist/cjs/keycloak/keycloak.js.map +1 -1
- package/dist/cjs/keycloak/keycloak.native.js +27 -209
- package/dist/cjs/keycloak/keycloak.native.js.map +2 -2
- package/dist/cjs/provider/AfterAuth.js +12 -7
- package/dist/cjs/provider/AfterAuth.js.map +1 -1
- package/dist/cjs/provider/AfterAuth.native.js +6 -4
- package/dist/cjs/provider/AfterAuth.native.js.map +2 -2
- package/dist/cjs/provider/AuthProvider/AuthProvider.js +59 -23
- package/dist/cjs/provider/AuthProvider/AuthProvider.js.map +1 -1
- package/dist/cjs/provider/AuthProvider/AuthProvider.native.js +80 -321
- package/dist/cjs/provider/AuthProvider/AuthProvider.native.js.map +2 -2
- package/dist/cjs/provider/KeycloakProvider.js +4 -1
- package/dist/cjs/provider/KeycloakProvider.js.map +1 -1
- package/dist/cjs/provider/KeycloakProvider.native.js +1 -1
- package/dist/cjs/provider/KeycloakProvider.native.js.map +1 -1
- package/dist/cjs/routes.js +11 -10
- package/dist/cjs/routes.js.map +1 -1
- package/dist/cjs/routes.native.js +89 -333
- package/dist/cjs/routes.native.js.map +2 -2
- package/dist/cjs/session/session.js.map +1 -1
- package/dist/cjs/session/session.native.js +2 -122
- package/dist/cjs/session/session.native.js.map +1 -1
- package/dist/cjs/state.js +10 -14
- package/dist/cjs/state.js.map +1 -1
- package/dist/cjs/state.native.js +20 -11
- package/dist/cjs/state.native.js.map +2 -2
- package/dist/cjs/token.js.map +1 -1
- package/dist/cjs/token.native.js +1 -1
- package/dist/cjs/token.native.js.map +1 -1
- package/dist/esm/Authenticated.js +11 -4
- package/dist/esm/Authenticated.js.map +1 -1
- package/dist/esm/Authenticated.mjs +7 -5
- package/dist/esm/Authenticated.mjs.map +1 -0
- package/dist/esm/Authenticated.native.js +26 -37
- package/dist/esm/Authenticated.native.js.map +1 -6
- package/dist/esm/Loading.js +11 -0
- package/dist/esm/Loading.js.map +6 -0
- package/dist/esm/Loading.mjs +16 -0
- package/dist/esm/Loading.mjs.map +1 -0
- package/dist/esm/Loading.native.js +17 -0
- package/dist/esm/Loading.native.js.map +1 -0
- package/dist/esm/authConfig.mjs +2 -1
- package/dist/esm/authConfig.mjs.map +1 -0
- package/dist/esm/authConfig.native.js +5 -6
- package/dist/esm/authConfig.native.js.map +1 -6
- package/dist/esm/hooks/index.mjs +3 -2
- package/dist/esm/hooks/index.mjs.map +1 -0
- package/dist/esm/hooks/index.native.js +3 -3
- package/dist/esm/hooks/index.native.js.map +1 -6
- package/dist/esm/hooks/useAuthConfig.mjs +2 -1
- package/dist/esm/hooks/useAuthConfig.mjs.map +1 -0
- package/dist/esm/hooks/useAuthConfig.native.js +3 -5
- package/dist/esm/hooks/useAuthConfig.native.js.map +1 -6
- package/dist/esm/hooks/useTokensFromQuery/index.mjs +2 -1
- package/dist/esm/hooks/useTokensFromQuery/index.mjs.map +1 -0
- package/dist/esm/hooks/useTokensFromQuery/index.native.js +2 -4
- package/dist/esm/hooks/useTokensFromQuery/index.native.js.map +1 -6
- package/dist/esm/hooks/useTokensFromState.js +6 -5
- package/dist/esm/hooks/useTokensFromState.js.map +1 -1
- package/dist/esm/hooks/useTokensFromState.mjs +6 -5
- package/dist/esm/hooks/useTokensFromState.mjs.map +1 -0
- package/dist/esm/hooks/useTokensFromState.native.js +7 -9
- package/dist/esm/hooks/useTokensFromState.native.js.map +1 -6
- package/dist/esm/index.mjs +6 -5
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/index.native.js +4 -4
- package/dist/esm/index.native.js.map +1 -6
- package/dist/esm/keycloak/config.mjs +2 -1
- package/dist/esm/keycloak/config.mjs.map +1 -0
- package/dist/esm/keycloak/config.native.js +3 -4
- package/dist/esm/keycloak/config.native.js.map +1 -6
- package/dist/esm/keycloak/context.js.map +1 -1
- package/dist/esm/keycloak/context.mjs +2 -1
- package/dist/esm/keycloak/context.mjs.map +1 -0
- package/dist/esm/keycloak/context.native.js +3 -4
- package/dist/esm/keycloak/context.native.js.map +1 -6
- package/dist/esm/keycloak/index.mjs +2 -1
- package/dist/esm/keycloak/index.mjs.map +1 -0
- package/dist/esm/keycloak/index.native.js +3 -3
- package/dist/esm/keycloak/index.native.js.map +1 -6
- package/dist/esm/keycloak/keycloak.js +14 -11
- package/dist/esm/keycloak/keycloak.js.map +1 -1
- package/dist/esm/keycloak/keycloak.mjs +8 -7
- package/dist/esm/keycloak/keycloak.mjs.map +1 -0
- package/dist/esm/keycloak/keycloak.native.js +112 -317
- package/dist/esm/keycloak/keycloak.native.js.map +1 -6
- package/dist/esm/provider/AfterAuth.js +16 -8
- package/dist/esm/provider/AfterAuth.js.map +1 -1
- package/dist/esm/provider/AfterAuth.mjs +13 -8
- package/dist/esm/provider/AfterAuth.mjs.map +1 -0
- package/dist/esm/provider/AfterAuth.native.js +25 -30
- package/dist/esm/provider/AfterAuth.native.js.map +1 -6
- package/dist/esm/provider/AuthProvider/AuthProvider.js +56 -19
- package/dist/esm/provider/AuthProvider/AuthProvider.js.map +1 -1
- package/dist/esm/provider/AuthProvider/AuthProvider.mjs +21 -14
- package/dist/esm/provider/AuthProvider/AuthProvider.mjs.map +1 -0
- package/dist/esm/provider/AuthProvider/AuthProvider.native.js +104 -364
- package/dist/esm/provider/AuthProvider/AuthProvider.native.js.map +1 -6
- package/dist/esm/provider/AuthProvider/index.mjs +2 -1
- package/dist/esm/provider/AuthProvider/index.mjs.map +1 -0
- package/dist/esm/provider/AuthProvider/index.native.js +2 -2
- package/dist/esm/provider/AuthProvider/index.native.js.map +1 -6
- package/dist/esm/provider/KeycloakProvider.js +4 -1
- package/dist/esm/provider/KeycloakProvider.js.map +1 -1
- package/dist/esm/provider/KeycloakProvider.mjs +3 -2
- package/dist/esm/provider/KeycloakProvider.mjs.map +1 -0
- package/dist/esm/provider/KeycloakProvider.native.js +22 -17
- package/dist/esm/provider/KeycloakProvider.native.js.map +1 -6
- package/dist/esm/provider/index.mjs +3 -2
- package/dist/esm/provider/index.mjs.map +1 -0
- package/dist/esm/provider/index.native.js +3 -3
- package/dist/esm/provider/index.native.js.map +1 -6
- package/dist/esm/routes.js +11 -10
- package/dist/esm/routes.js.map +1 -1
- package/dist/esm/routes.mjs +12 -12
- package/dist/esm/routes.mjs.map +1 -0
- package/dist/esm/routes.native.js +98 -342
- package/dist/esm/routes.native.js.map +1 -6
- package/dist/esm/session/index.mjs +2 -1
- package/dist/esm/session/index.mjs.map +1 -0
- package/dist/esm/session/index.native.js +2 -2
- package/dist/esm/session/index.native.js.map +1 -6
- package/dist/esm/session/session.js.map +1 -1
- package/dist/esm/session/session.mjs +2 -1
- package/dist/esm/session/session.mjs.map +1 -0
- package/dist/esm/session/session.native.js +3 -126
- package/dist/esm/session/session.native.js.map +1 -6
- package/dist/esm/state.js +10 -14
- package/dist/esm/state.js.map +1 -1
- package/dist/esm/state.mjs +11 -14
- package/dist/esm/state.mjs.map +1 -0
- package/dist/esm/state.native.js +22 -15
- package/dist/esm/state.native.js.map +1 -6
- package/dist/esm/token.js.map +1 -1
- package/dist/esm/token.mjs +2 -1
- package/dist/esm/token.mjs.map +1 -0
- package/dist/esm/token.native.js +6 -8
- package/dist/esm/token.native.js.map +1 -6
- package/dist/esm/types.mjs +2 -0
- package/dist/esm/types.mjs.map +1 -0
- package/dist/esm/types.native.js +2 -1
- package/dist/esm/types.native.js.map +1 -6
- package/dist/jsx/Authenticated.js +11 -4
- package/dist/jsx/Authenticated.js.map +1 -1
- package/dist/jsx/Authenticated.mjs +7 -5
- package/dist/jsx/Authenticated.mjs.map +1 -0
- package/dist/jsx/Authenticated.native.js +7 -22
- package/dist/jsx/Authenticated.native.js.map +2 -2
- package/dist/jsx/Loading.js +11 -0
- package/dist/jsx/Loading.js.map +6 -0
- package/dist/jsx/Loading.mjs +16 -0
- package/dist/jsx/Loading.mjs.map +1 -0
- package/dist/jsx/Loading.native.js +13 -0
- package/dist/jsx/Loading.native.js.map +6 -0
- package/dist/jsx/authConfig.mjs +2 -1
- package/dist/jsx/authConfig.mjs.map +1 -0
- package/dist/jsx/hooks/index.mjs +3 -2
- package/dist/jsx/hooks/index.mjs.map +1 -0
- package/dist/jsx/hooks/useAuthConfig.mjs +2 -1
- package/dist/jsx/hooks/useAuthConfig.mjs.map +1 -0
- package/dist/jsx/hooks/useTokensFromQuery/index.mjs +2 -1
- package/dist/jsx/hooks/useTokensFromQuery/index.mjs.map +1 -0
- package/dist/jsx/hooks/useTokensFromState.js +6 -5
- package/dist/jsx/hooks/useTokensFromState.js.map +1 -1
- package/dist/jsx/hooks/useTokensFromState.mjs +6 -5
- package/dist/jsx/hooks/useTokensFromState.mjs.map +1 -0
- package/dist/jsx/hooks/useTokensFromState.native.js +6 -5
- package/dist/jsx/hooks/useTokensFromState.native.js.map +2 -2
- package/dist/jsx/index.mjs +6 -5
- package/dist/jsx/index.mjs.map +1 -0
- package/dist/jsx/keycloak/config.mjs +2 -1
- package/dist/jsx/keycloak/config.mjs.map +1 -0
- package/dist/jsx/keycloak/context.js.map +1 -1
- package/dist/jsx/keycloak/context.mjs +2 -1
- package/dist/jsx/keycloak/context.mjs.map +1 -0
- package/dist/jsx/keycloak/context.native.js.map +1 -1
- package/dist/jsx/keycloak/index.mjs +2 -1
- package/dist/jsx/keycloak/index.mjs.map +1 -0
- package/dist/jsx/keycloak/keycloak.js +14 -11
- package/dist/jsx/keycloak/keycloak.js.map +1 -1
- package/dist/jsx/keycloak/keycloak.mjs +8 -7
- package/dist/jsx/keycloak/keycloak.mjs.map +1 -0
- package/dist/jsx/keycloak/keycloak.native.js +29 -211
- package/dist/jsx/keycloak/keycloak.native.js.map +2 -2
- package/dist/jsx/provider/AfterAuth.js +16 -8
- package/dist/jsx/provider/AfterAuth.js.map +1 -1
- package/dist/jsx/provider/AfterAuth.mjs +13 -8
- package/dist/jsx/provider/AfterAuth.mjs.map +1 -0
- package/dist/jsx/provider/AfterAuth.native.js +7 -4
- package/dist/jsx/provider/AfterAuth.native.js.map +2 -2
- package/dist/jsx/provider/AuthProvider/AuthProvider.js +56 -19
- package/dist/jsx/provider/AuthProvider/AuthProvider.js.map +1 -1
- package/dist/jsx/provider/AuthProvider/AuthProvider.mjs +21 -14
- package/dist/jsx/provider/AuthProvider/AuthProvider.mjs.map +1 -0
- package/dist/jsx/provider/AuthProvider/AuthProvider.native.js +84 -323
- package/dist/jsx/provider/AuthProvider/AuthProvider.native.js.map +2 -2
- package/dist/jsx/provider/AuthProvider/index.mjs +2 -1
- package/dist/jsx/provider/AuthProvider/index.mjs.map +1 -0
- package/dist/jsx/provider/KeycloakProvider.js +4 -1
- package/dist/jsx/provider/KeycloakProvider.js.map +1 -1
- package/dist/jsx/provider/KeycloakProvider.mjs +3 -2
- package/dist/jsx/provider/KeycloakProvider.mjs.map +1 -0
- package/dist/jsx/provider/KeycloakProvider.native.js +1 -1
- package/dist/jsx/provider/KeycloakProvider.native.js.map +1 -1
- package/dist/jsx/provider/index.mjs +3 -2
- package/dist/jsx/provider/index.mjs.map +1 -0
- package/dist/jsx/routes.js +11 -10
- package/dist/jsx/routes.js.map +1 -1
- package/dist/jsx/routes.mjs +12 -12
- package/dist/jsx/routes.mjs.map +1 -0
- package/dist/jsx/routes.native.js +89 -332
- package/dist/jsx/routes.native.js.map +2 -2
- package/dist/jsx/session/index.mjs +2 -1
- package/dist/jsx/session/index.mjs.map +1 -0
- package/dist/jsx/session/session.js.map +1 -1
- package/dist/jsx/session/session.mjs +2 -1
- package/dist/jsx/session/session.mjs.map +1 -0
- package/dist/jsx/session/session.native.js +2 -122
- package/dist/jsx/session/session.native.js.map +1 -1
- package/dist/jsx/state.js +10 -14
- package/dist/jsx/state.js.map +1 -1
- package/dist/jsx/state.mjs +11 -14
- package/dist/jsx/state.mjs.map +1 -0
- package/dist/jsx/state.native.js +19 -11
- package/dist/jsx/state.native.js.map +2 -2
- package/dist/jsx/token.js.map +1 -1
- package/dist/jsx/token.mjs +2 -1
- package/dist/jsx/token.mjs.map +1 -0
- package/dist/jsx/token.native.js +1 -1
- package/dist/jsx/token.native.js.map +1 -1
- package/dist/jsx/types.mjs +2 -0
- package/dist/jsx/types.mjs.map +1 -0
- package/package.json +12 -15
- package/routes/index.d.ts +1 -1
- package/routes/index.js +1 -1
- package/src/@types/expoKeycloakAuth.d.ts +1 -1
- package/src/Authenticated.tsx +41 -15
- package/src/Loading.tsx +37 -0
- package/src/authConfig.ts +2 -2
- package/src/hooks/index.ts +3 -3
- package/src/hooks/useAuthConfig.ts +2 -2
- package/src/hooks/useTokensFromQuery/index.ts +4 -4
- package/src/hooks/useTokensFromState.ts +6 -5
- package/src/index.ts +7 -7
- package/src/keycloak/config.ts +6 -6
- package/src/keycloak/context.ts +3 -3
- package/src/keycloak/index.ts +2 -2
- package/src/keycloak/keycloak.native.ts +35 -27
- package/src/keycloak/keycloak.ts +48 -37
- package/src/provider/AfterAuth.tsx +33 -17
- package/src/provider/AuthProvider/AuthProvider.native.tsx +78 -29
- package/src/provider/AuthProvider/AuthProvider.tsx +143 -81
- package/src/provider/AuthProvider/index.ts +1 -1
- package/src/provider/KeycloakProvider.tsx +12 -9
- package/src/provider/index.ts +3 -3
- package/src/routes.ts +45 -35
- package/src/session/index.ts +1 -1
- package/src/session/session.native.ts +5 -3
- package/src/session/session.ts +14 -7
- package/src/state.ts +12 -16
- package/src/token.ts +9 -6
- package/types/Authenticated.d.ts +3 -3
- package/types/Authenticated.d.ts.map +1 -1
- package/types/Loading.d.ts +6 -0
- package/types/Loading.d.ts.map +1 -0
- package/types/hooks/index.d.ts +3 -3
- package/types/hooks/useTokensFromState.d.ts +1 -1
- package/types/hooks/useTokensFromState.d.ts.map +1 -1
- package/types/index.d.ts +7 -7
- package/types/keycloak/config.d.ts +1 -1
- package/types/keycloak/context.d.ts +1 -1
- package/types/keycloak/context.d.ts.map +1 -1
- package/types/keycloak/index.d.ts +2 -2
- package/types/keycloak/keycloak.d.ts +7 -7
- package/types/keycloak/keycloak.d.ts.map +1 -1
- package/types/keycloak/keycloak.native.d.ts +5 -5
- package/types/keycloak/keycloak.native.d.ts.map +1 -1
- package/types/provider/AfterAuth.d.ts +3 -3
- package/types/provider/AfterAuth.d.ts.map +1 -1
- package/types/provider/AuthProvider/AuthProvider.d.ts +8 -7
- package/types/provider/AuthProvider/AuthProvider.d.ts.map +1 -1
- package/types/provider/AuthProvider/AuthProvider.native.d.ts +3 -3
- package/types/provider/AuthProvider/AuthProvider.native.d.ts.map +1 -1
- package/types/provider/AuthProvider/index.d.ts +1 -1
- package/types/provider/KeycloakProvider.d.ts +4 -4
- package/types/provider/KeycloakProvider.d.ts.map +1 -1
- package/types/provider/index.d.ts +3 -3
- package/types/routes.d.ts +4 -4
- package/types/routes.d.ts.map +1 -1
- package/types/session/index.d.ts +1 -1
- package/types/session/session.d.ts +3 -3
- package/types/session/session.d.ts.map +1 -1
- package/types/session/session.native.d.ts +2 -2
- package/types/session/session.native.d.ts.map +1 -1
- package/types/state.d.ts +4 -6
- package/types/state.d.ts.map +1 -1
- package/types/token.d.ts +2 -2
- package/types/token.d.ts.map +1 -1
|
@@ -19,28 +19,31 @@
|
|
|
19
19
|
* limitations under the License.
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
"use client";
|
|
23
23
|
|
|
24
|
-
import KeycloakClient from
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
import type {
|
|
28
|
-
import
|
|
29
|
-
import
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
24
|
+
import KeycloakClient from "keycloak-js";
|
|
25
|
+
import type { KeycloakInitOptions } from "keycloak-js";
|
|
26
|
+
import { MultiPlatform } from "multiplatform.one";
|
|
27
|
+
import type { SessionProviderProps } from "next-auth/react";
|
|
28
|
+
import { SessionProvider } from "next-auth/react";
|
|
29
|
+
import { useRouter } from "next/router";
|
|
30
|
+
import type { PropsWithChildren } from "react";
|
|
31
|
+
import { type ComponentType, useEffect, useMemo, useState } from "react";
|
|
32
|
+
import { Text } from "tamagui";
|
|
33
|
+
import { Loading } from "../../Loading";
|
|
34
|
+
import { useAuthConfig } from "../../hooks";
|
|
35
|
+
import type { KeycloakConfig } from "../../keycloak";
|
|
36
|
+
import { Keycloak, KeycloakConfigContext } from "../../keycloak";
|
|
37
|
+
import { KeycloakContext } from "../../keycloak/context";
|
|
38
|
+
import { persist, useAuthStore } from "../../state";
|
|
39
|
+
import { validOrRefreshableToken } from "../../token";
|
|
40
|
+
import { AfterAuth } from "../AfterAuth";
|
|
39
41
|
|
|
40
42
|
export interface AuthProviderProps extends PropsWithChildren {
|
|
41
43
|
keycloakConfig: KeycloakConfig;
|
|
42
44
|
keycloakInitOptions?: KeycloakInitOptions;
|
|
43
|
-
sessionProvider?: Omit<SessionProviderProps,
|
|
45
|
+
sessionProvider?: Omit<SessionProviderProps, "children">;
|
|
46
|
+
loadingComponent?: ComponentType;
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
const logger = console;
|
|
@@ -51,17 +54,27 @@ export interface Tokens<B = boolean> {
|
|
|
51
54
|
token?: string | B;
|
|
52
55
|
}
|
|
53
56
|
|
|
54
|
-
export function AuthProvider({
|
|
57
|
+
export function AuthProvider({
|
|
58
|
+
children,
|
|
59
|
+
keycloakConfig,
|
|
60
|
+
keycloakInitOptions,
|
|
61
|
+
loadingComponent,
|
|
62
|
+
sessionProvider,
|
|
63
|
+
}: AuthProviderProps) {
|
|
55
64
|
const { debug, messageHandlerKeys } = useAuthConfig();
|
|
56
65
|
const { query } = MultiPlatform.isNext ? useRouter() : { query: {} };
|
|
57
|
-
const
|
|
66
|
+
const authStore = useAuthStore();
|
|
67
|
+
if (typeof authStore === "undefined") {
|
|
68
|
+
return <Loading loadingComponent={loadingComponent} />;
|
|
69
|
+
}
|
|
58
70
|
const [keycloak, setKeycloak] = useState<Keycloak>();
|
|
59
71
|
const initialRefreshToken = useMemo(
|
|
60
72
|
() =>
|
|
61
73
|
validOrRefreshableToken(
|
|
62
74
|
MultiPlatform.isIframe
|
|
63
|
-
? (
|
|
64
|
-
(
|
|
75
|
+
? ("refreshToken" in query &&
|
|
76
|
+
(query.refreshToken?.toString() || true)) ||
|
|
77
|
+
(persist && authStore.refreshToken) ||
|
|
65
78
|
undefined
|
|
66
79
|
: undefined,
|
|
67
80
|
),
|
|
@@ -71,58 +84,72 @@ export function AuthProvider({ children, sessionProvider, keycloakInitOptions, k
|
|
|
71
84
|
refreshToken: initialRefreshToken,
|
|
72
85
|
token: validOrRefreshableToken(
|
|
73
86
|
MultiPlatform.isIframe
|
|
74
|
-
? (
|
|
87
|
+
? ("token" in query && (query.token?.toString() || true)) ||
|
|
88
|
+
(persist && authStore.token) ||
|
|
89
|
+
undefined
|
|
75
90
|
: undefined,
|
|
76
91
|
initialRefreshToken,
|
|
77
92
|
),
|
|
78
93
|
idToken: validOrRefreshableToken(
|
|
79
94
|
MultiPlatform.isIframe
|
|
80
|
-
? (
|
|
95
|
+
? ("idToken" in query && (query.idToken?.toString() || true)) ||
|
|
96
|
+
(persist && authStore.idToken) ||
|
|
97
|
+
undefined
|
|
81
98
|
: undefined,
|
|
82
99
|
initialRefreshToken,
|
|
83
100
|
),
|
|
84
101
|
});
|
|
85
102
|
|
|
86
103
|
useEffect(() => {
|
|
87
|
-
if (
|
|
88
|
-
|
|
104
|
+
if (
|
|
105
|
+
tokens.token !== true &&
|
|
106
|
+
tokens.refreshToken !== true &&
|
|
107
|
+
tokens.idToken !== true
|
|
108
|
+
)
|
|
109
|
+
return;
|
|
110
|
+
if (debug) logger.debug("post message", JSON.stringify({ type: "LOADED" }));
|
|
89
111
|
(messageHandlerKeys || []).forEach((key: string) => {
|
|
90
|
-
window?.webkit?.messageHandlers?.[key]?.postMessage(
|
|
112
|
+
window?.webkit?.messageHandlers?.[key]?.postMessage(
|
|
113
|
+
JSON.stringify({ type: "LOADED" }),
|
|
114
|
+
);
|
|
91
115
|
});
|
|
92
|
-
window?.ReactNativeWebView?.postMessage(JSON.stringify({ type:
|
|
93
|
-
window?.parent?.postMessage(JSON.stringify({ type:
|
|
116
|
+
window?.ReactNativeWebView?.postMessage(JSON.stringify({ type: "LOADED" }));
|
|
117
|
+
window?.parent?.postMessage(JSON.stringify({ type: "LOADED" }));
|
|
94
118
|
}, []);
|
|
95
119
|
|
|
96
120
|
useEffect(() => {
|
|
97
121
|
if (tokens.refreshToken !== true) return;
|
|
98
122
|
const messageCallback = (e: MessageEvent<any>) => {
|
|
99
123
|
let data = e?.data || null;
|
|
100
|
-
if (typeof data ===
|
|
124
|
+
if (typeof data === "string") {
|
|
101
125
|
try {
|
|
102
126
|
data = JSON.parse(data);
|
|
103
127
|
} catch (err) {}
|
|
104
128
|
}
|
|
105
|
-
if (debug) logger.debug(
|
|
129
|
+
if (debug) logger.debug("received message", JSON.stringify(data));
|
|
106
130
|
const message: MessageSchema = data;
|
|
107
131
|
if (!message.type) return;
|
|
108
|
-
if (message.type.toUpperCase() ===
|
|
109
|
-
if (debug) logger.debug(
|
|
110
|
-
setTokens((tokens) => ({
|
|
111
|
-
|
|
132
|
+
if (message.type.toUpperCase() === "REFRESH_TOKEN" && message.payload) {
|
|
133
|
+
if (debug) logger.debug("setting refresh token", message.payload);
|
|
134
|
+
setTokens((tokens) => ({
|
|
135
|
+
...tokens,
|
|
136
|
+
refreshToken: validOrRefreshableToken(message.payload),
|
|
137
|
+
}));
|
|
138
|
+
window.removeEventListener("message", messageCallback);
|
|
112
139
|
}
|
|
113
140
|
};
|
|
114
141
|
if (debug) {
|
|
115
142
|
logger.debug(
|
|
116
|
-
|
|
143
|
+
"listening for message",
|
|
117
144
|
JSON.stringify({
|
|
118
|
-
type:
|
|
119
|
-
payload:
|
|
145
|
+
type: "REFRESH_TOKEN",
|
|
146
|
+
payload: "<some_refresh_token>",
|
|
120
147
|
}),
|
|
121
148
|
);
|
|
122
149
|
}
|
|
123
|
-
window.addEventListener(
|
|
150
|
+
window.addEventListener("message", messageCallback);
|
|
124
151
|
return () => {
|
|
125
|
-
window.removeEventListener(
|
|
152
|
+
window.removeEventListener("message", messageCallback);
|
|
126
153
|
};
|
|
127
154
|
}, []);
|
|
128
155
|
|
|
@@ -130,32 +157,35 @@ export function AuthProvider({ children, sessionProvider, keycloakInitOptions, k
|
|
|
130
157
|
if (tokens.token !== true) return;
|
|
131
158
|
const messageCallback = (e: MessageEvent<any>) => {
|
|
132
159
|
let data = e?.data || null;
|
|
133
|
-
if (typeof data ===
|
|
160
|
+
if (typeof data === "string") {
|
|
134
161
|
try {
|
|
135
162
|
data = JSON.parse(data);
|
|
136
163
|
} catch (err) {}
|
|
137
164
|
}
|
|
138
|
-
if (debug) logger.debug(
|
|
165
|
+
if (debug) logger.debug("received message", JSON.stringify(data));
|
|
139
166
|
const message: MessageSchema = data;
|
|
140
167
|
if (!message.type) return;
|
|
141
|
-
if (message.type.toUpperCase() ===
|
|
142
|
-
if (debug) logger.debug(
|
|
143
|
-
setTokens((tokens) => ({
|
|
144
|
-
|
|
168
|
+
if (message.type.toUpperCase() === "TOKEN" && message.payload) {
|
|
169
|
+
if (debug) logger.debug("setting token", message.payload);
|
|
170
|
+
setTokens((tokens) => ({
|
|
171
|
+
...tokens,
|
|
172
|
+
token: validOrRefreshableToken(message.payload, tokens.refreshToken),
|
|
173
|
+
}));
|
|
174
|
+
window.removeEventListener("message", messageCallback);
|
|
145
175
|
}
|
|
146
176
|
};
|
|
147
177
|
if (debug) {
|
|
148
178
|
logger.debug(
|
|
149
|
-
|
|
179
|
+
"listening for message",
|
|
150
180
|
JSON.stringify({
|
|
151
|
-
type:
|
|
152
|
-
payload:
|
|
181
|
+
type: "TOKEN",
|
|
182
|
+
payload: "<some_token>",
|
|
153
183
|
}),
|
|
154
184
|
);
|
|
155
185
|
}
|
|
156
|
-
window.addEventListener(
|
|
186
|
+
window.addEventListener("message", messageCallback);
|
|
157
187
|
return () => {
|
|
158
|
-
window.removeEventListener(
|
|
188
|
+
window.removeEventListener("message", messageCallback);
|
|
159
189
|
};
|
|
160
190
|
}, []);
|
|
161
191
|
|
|
@@ -163,85 +193,117 @@ export function AuthProvider({ children, sessionProvider, keycloakInitOptions, k
|
|
|
163
193
|
if (tokens.idToken !== true) return;
|
|
164
194
|
const messageCallback = (e: MessageEvent<any>) => {
|
|
165
195
|
let data = e?.data || null;
|
|
166
|
-
if (typeof data ===
|
|
196
|
+
if (typeof data === "string") {
|
|
167
197
|
try {
|
|
168
198
|
data = JSON.parse(data);
|
|
169
199
|
} catch (err) {}
|
|
170
200
|
}
|
|
171
|
-
if (debug) logger.debug(
|
|
201
|
+
if (debug) logger.debug("received message", JSON.stringify(data));
|
|
172
202
|
const message: MessageSchema = data;
|
|
173
203
|
if (!message.type) return;
|
|
174
|
-
if (message.type.toUpperCase() ===
|
|
175
|
-
if (debug) logger.debug(
|
|
176
|
-
setTokens((tokens) => ({
|
|
177
|
-
|
|
204
|
+
if (message.type.toUpperCase() === "ID_TOKEN" && message.payload) {
|
|
205
|
+
if (debug) logger.debug("setting id token", message.payload);
|
|
206
|
+
setTokens((tokens) => ({
|
|
207
|
+
...tokens,
|
|
208
|
+
idToken: validOrRefreshableToken(
|
|
209
|
+
message.payload,
|
|
210
|
+
tokens.refreshToken,
|
|
211
|
+
),
|
|
212
|
+
}));
|
|
213
|
+
window.removeEventListener("message", messageCallback);
|
|
178
214
|
}
|
|
179
215
|
};
|
|
180
216
|
if (debug) {
|
|
181
217
|
logger.debug(
|
|
182
|
-
|
|
218
|
+
"listening for message",
|
|
183
219
|
JSON.stringify({
|
|
184
|
-
type:
|
|
185
|
-
payload:
|
|
220
|
+
type: "ID_TOKEN",
|
|
221
|
+
payload: "<some_id_token>",
|
|
186
222
|
}),
|
|
187
223
|
);
|
|
188
224
|
}
|
|
189
|
-
window.addEventListener(
|
|
225
|
+
window.addEventListener("message", messageCallback);
|
|
190
226
|
return () => {
|
|
191
|
-
window.removeEventListener(
|
|
227
|
+
window.removeEventListener("message", messageCallback);
|
|
192
228
|
};
|
|
193
229
|
}, []);
|
|
194
230
|
|
|
195
231
|
const keycloakClient = useMemo(
|
|
196
232
|
() =>
|
|
197
|
-
(!MultiPlatform.isNext ||
|
|
233
|
+
(!MultiPlatform.isNext ||
|
|
234
|
+
MultiPlatform.isElectron ||
|
|
235
|
+
MultiPlatform.isIframe) &&
|
|
236
|
+
keycloakConfig
|
|
198
237
|
? new KeycloakClient({
|
|
199
238
|
url: keycloakConfig.url,
|
|
200
239
|
realm: keycloakConfig.realm,
|
|
201
240
|
clientId: keycloakConfig.publicClientId || keycloakConfig.clientId,
|
|
202
241
|
})
|
|
203
242
|
: undefined,
|
|
204
|
-
[
|
|
243
|
+
[
|
|
244
|
+
keycloakInitOptions,
|
|
245
|
+
keycloakConfig,
|
|
246
|
+
tokens.token,
|
|
247
|
+
tokens.refreshToken,
|
|
248
|
+
tokens.idToken,
|
|
249
|
+
],
|
|
205
250
|
);
|
|
206
251
|
|
|
207
252
|
const initOptions = useMemo(() => {
|
|
208
|
-
if (
|
|
253
|
+
if (
|
|
254
|
+
MultiPlatform.isNext &&
|
|
255
|
+
!MultiPlatform.isElectron &&
|
|
256
|
+
!MultiPlatform.isIframe
|
|
257
|
+
)
|
|
258
|
+
return;
|
|
209
259
|
const initOptions: KeycloakInitOptions = {
|
|
210
260
|
...defaultKeycloakInitOptions,
|
|
211
261
|
...keycloakInitOptions,
|
|
212
262
|
scope: [
|
|
213
263
|
...new Set([
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
...(defaultKeycloakInitOptions.scope?.split(
|
|
218
|
-
...(keycloakInitOptions?.scope?.split(
|
|
264
|
+
"email",
|
|
265
|
+
"openid",
|
|
266
|
+
"profile",
|
|
267
|
+
...(defaultKeycloakInitOptions.scope?.split(" ") || []),
|
|
268
|
+
...(keycloakInitOptions?.scope?.split(" ") || []),
|
|
219
269
|
...(keycloakConfig.scopes || []),
|
|
220
270
|
]),
|
|
221
|
-
].join(
|
|
271
|
+
].join(" "),
|
|
222
272
|
};
|
|
223
273
|
if (debug) initOptions.enableLogging = true;
|
|
224
|
-
if (tokens.token && typeof tokens.token ===
|
|
274
|
+
if (tokens.token && typeof tokens.token === "string") {
|
|
225
275
|
initOptions.token = tokens.token;
|
|
226
276
|
initOptions.timeSkew = 0;
|
|
227
|
-
if (tokens.idToken && typeof tokens.idToken ===
|
|
228
|
-
|
|
277
|
+
if (tokens.idToken && typeof tokens.idToken === "string")
|
|
278
|
+
initOptions.idToken = tokens.idToken;
|
|
279
|
+
if (tokens.refreshToken && typeof tokens.refreshToken === "string")
|
|
229
280
|
initOptions.refreshToken = tokens.refreshToken;
|
|
230
281
|
}
|
|
231
|
-
if (
|
|
282
|
+
if (
|
|
283
|
+
(typeof window !== "undefined" && window.self !== window.top) ||
|
|
284
|
+
(tokens.token && !tokens.refreshToken)
|
|
285
|
+
) {
|
|
232
286
|
initOptions.checkLoginIframe = false;
|
|
233
|
-
initOptions.flow =
|
|
287
|
+
initOptions.flow = "implicit";
|
|
234
288
|
initOptions.onLoad = undefined;
|
|
235
289
|
}
|
|
236
290
|
return initOptions;
|
|
237
|
-
}, [
|
|
291
|
+
}, [
|
|
292
|
+
keycloakInitOptions,
|
|
293
|
+
keycloakConfig.scopes,
|
|
294
|
+
tokens.token,
|
|
295
|
+
tokens.idToken,
|
|
296
|
+
tokens.refreshToken,
|
|
297
|
+
]);
|
|
238
298
|
|
|
239
299
|
useEffect(() => {
|
|
240
300
|
function onError() {
|
|
241
|
-
if (keycloakClient && initOptions)
|
|
301
|
+
if (keycloakClient && initOptions)
|
|
302
|
+
setKeycloak(new Keycloak(keycloakConfig, keycloakClient));
|
|
242
303
|
}
|
|
243
304
|
function onUpdate() {
|
|
244
|
-
if (keycloakClient && initOptions)
|
|
305
|
+
if (keycloakClient && initOptions)
|
|
306
|
+
setKeycloak(new Keycloak(keycloakConfig, keycloakClient));
|
|
245
307
|
}
|
|
246
308
|
if (keycloakClient && initOptions) {
|
|
247
309
|
(async () => {
|
|
@@ -268,7 +330,7 @@ export function AuthProvider({ children, sessionProvider, keycloakInitOptions, k
|
|
|
268
330
|
return (
|
|
269
331
|
<KeycloakConfigContext.Provider value={keycloakConfig}>
|
|
270
332
|
<KeycloakContext.Provider value={keycloak}>
|
|
271
|
-
<AfterAuth>{children}</AfterAuth>
|
|
333
|
+
<AfterAuth loadingComponent={loadingComponent}>{children}</AfterAuth>
|
|
272
334
|
</KeycloakContext.Provider>
|
|
273
335
|
</KeycloakConfigContext.Provider>
|
|
274
336
|
);
|
|
@@ -284,8 +346,8 @@ const defaultKeycloakInitOptions: KeycloakInitOptions = {
|
|
|
284
346
|
checkLoginIframe: true,
|
|
285
347
|
checkLoginIframeInterval: 5,
|
|
286
348
|
enableLogging: false,
|
|
287
|
-
onLoad:
|
|
288
|
-
pkceMethod:
|
|
349
|
+
onLoad: "check-sso",
|
|
350
|
+
pkceMethod: "S256",
|
|
289
351
|
};
|
|
290
352
|
|
|
291
353
|
export interface MessageSchema {
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
* limitations under the License.
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import type { PropsWithChildren } from
|
|
25
|
-
import type {
|
|
26
|
-
import { AuthConfigContext } from
|
|
27
|
-
import { AuthProvider } from
|
|
22
|
+
import type { Session } from "next-auth";
|
|
23
|
+
import React, { useMemo } from "react";
|
|
24
|
+
import type { PropsWithChildren } from "react";
|
|
25
|
+
import type { AuthConfig } from "../authConfig";
|
|
26
|
+
import { AuthConfigContext } from "../authConfig";
|
|
27
|
+
import { AuthProvider } from "./AuthProvider";
|
|
28
28
|
|
|
29
29
|
export interface KeycloakProviderProps extends PropsWithChildren, AuthConfig {
|
|
30
30
|
baseUrl?: string;
|
|
@@ -45,7 +45,10 @@ export function KeycloakProvider({
|
|
|
45
45
|
realm,
|
|
46
46
|
session,
|
|
47
47
|
}: KeycloakProviderProps) {
|
|
48
|
-
const authConfig = useMemo(
|
|
48
|
+
const authConfig = useMemo(
|
|
49
|
+
() => ({ debug, disabled, loginRedirectUri }),
|
|
50
|
+
[debug, disabled, loginRedirectUri],
|
|
51
|
+
);
|
|
49
52
|
return (
|
|
50
53
|
<AuthConfigContext.Provider value={authConfig}>
|
|
51
54
|
{disabled ? (
|
|
@@ -54,9 +57,9 @@ export function KeycloakProvider({
|
|
|
54
57
|
<AuthProvider
|
|
55
58
|
sessionProvider={{ session }}
|
|
56
59
|
keycloakConfig={{
|
|
57
|
-
clientId: clientId ||
|
|
60
|
+
clientId: clientId || "app",
|
|
58
61
|
publicClientId,
|
|
59
|
-
realm: realm ||
|
|
62
|
+
realm: realm || "main",
|
|
60
63
|
url: baseUrl,
|
|
61
64
|
}}
|
|
62
65
|
>
|
package/src/provider/index.ts
CHANGED
package/src/routes.ts
CHANGED
|
@@ -19,20 +19,22 @@
|
|
|
19
19
|
* limitations under the License.
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
import
|
|
23
|
-
import type { AuthOptions, CallbacksOptions } from
|
|
24
|
-
import
|
|
25
|
-
import type {
|
|
26
|
-
import type {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
22
|
+
import { jwtDecode } from "jwt-decode";
|
|
23
|
+
import type { AuthOptions, CallbacksOptions } from "next-auth";
|
|
24
|
+
import { getServerSession } from "next-auth";
|
|
25
|
+
import type { JWT } from "next-auth/jwt";
|
|
26
|
+
import type { OAuthUserConfig } from "next-auth/providers";
|
|
27
|
+
import type { Session } from "./session";
|
|
28
|
+
import type { AccessTokenParsed } from "./token";
|
|
29
29
|
|
|
30
|
-
const NextAuth = require(
|
|
31
|
-
|
|
30
|
+
const NextAuth = require("next-auth")
|
|
31
|
+
.default as typeof import("next-auth").default;
|
|
32
|
+
const NextResponse = require("next/server")
|
|
33
|
+
.NextResponse as typeof import("next/server").NextResponse;
|
|
32
34
|
const logger = console;
|
|
33
35
|
let _nextAuth: AuthOptions | undefined;
|
|
34
|
-
const KeycloakProvider = require(
|
|
35
|
-
.default as typeof import(
|
|
36
|
+
const KeycloakProvider = require("next-auth/providers/keycloak")
|
|
37
|
+
.default as typeof import("next-auth/providers/keycloak").default;
|
|
36
38
|
|
|
37
39
|
export function createAuthHandler(options: AuthHandlerOptions) {
|
|
38
40
|
return NextAuth(createNextAuthOptions(options));
|
|
@@ -40,15 +42,17 @@ export function createAuthHandler(options: AuthHandlerOptions) {
|
|
|
40
42
|
|
|
41
43
|
const defaults = {
|
|
42
44
|
keycloak: {
|
|
43
|
-
baseUrl:
|
|
44
|
-
realm:
|
|
45
|
+
baseUrl: "http://localhost:8080",
|
|
46
|
+
realm: "master",
|
|
45
47
|
},
|
|
46
48
|
};
|
|
47
49
|
|
|
48
50
|
export function createLogoutHandler(options: AuthHandlerOptions) {
|
|
49
51
|
return {
|
|
50
52
|
async GET() {
|
|
51
|
-
const idToken = (
|
|
53
|
+
const idToken = (
|
|
54
|
+
(await getServerSession(createNextAuthOptions(options))) as Session
|
|
55
|
+
)?.idToken;
|
|
52
56
|
if (idToken) {
|
|
53
57
|
try {
|
|
54
58
|
await fetch(
|
|
@@ -57,7 +61,7 @@ export function createLogoutHandler(options: AuthHandlerOptions) {
|
|
|
57
61
|
}/protocol/openid-connect/logout?id_token_hint=${idToken}&post_logout_redirect_uri=${encodeURIComponent(
|
|
58
62
|
options.baseUrl,
|
|
59
63
|
)}`,
|
|
60
|
-
{ method:
|
|
64
|
+
{ method: "GET" },
|
|
61
65
|
);
|
|
62
66
|
} catch (err) {
|
|
63
67
|
logger.error(err);
|
|
@@ -72,7 +76,8 @@ export function createLogoutHandler(options: AuthHandlerOptions) {
|
|
|
72
76
|
export function createNextAuthOptions(options: AuthHandlerOptions) {
|
|
73
77
|
if (_nextAuth) return _nextAuth;
|
|
74
78
|
const authorization =
|
|
75
|
-
options.keycloak.authorization &&
|
|
79
|
+
options.keycloak.authorization &&
|
|
80
|
+
typeof options.keycloak.authorization === "object"
|
|
76
81
|
? options.keycloak.authorization
|
|
77
82
|
: {};
|
|
78
83
|
_nextAuth = {
|
|
@@ -85,13 +90,13 @@ export function createNextAuthOptions(options: AuthHandlerOptions) {
|
|
|
85
90
|
params: {
|
|
86
91
|
scope: [
|
|
87
92
|
...new Set([
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
...(authorization.params?.scope?.split(
|
|
93
|
+
"email",
|
|
94
|
+
"openid",
|
|
95
|
+
"profile",
|
|
96
|
+
...(authorization.params?.scope?.split(" ") || []),
|
|
92
97
|
...(options.scopes || []),
|
|
93
98
|
]),
|
|
94
|
-
].join(
|
|
99
|
+
].join(" "),
|
|
95
100
|
},
|
|
96
101
|
},
|
|
97
102
|
...options.keycloak,
|
|
@@ -101,12 +106,14 @@ export function createNextAuthOptions(options: AuthHandlerOptions) {
|
|
|
101
106
|
callbacks: {
|
|
102
107
|
...options.nextAuth?.callbacks,
|
|
103
108
|
async jwt(params) {
|
|
104
|
-
if (typeof options.nextAuth?.callbacks?.jwt ===
|
|
109
|
+
if (typeof options.nextAuth?.callbacks?.jwt === "function") {
|
|
105
110
|
return options.nextAuth?.callbacks.jwt(params);
|
|
106
111
|
}
|
|
107
112
|
const { token, account } = params;
|
|
108
113
|
if (account) {
|
|
109
|
-
const decoded = jwtDecode(
|
|
114
|
+
const decoded = jwtDecode(
|
|
115
|
+
account.access_token || "",
|
|
116
|
+
) as AccessTokenParsed;
|
|
110
117
|
token.decoded = decoded;
|
|
111
118
|
token.accessToken = account.access_token;
|
|
112
119
|
token.idToken = account.id_token;
|
|
@@ -114,18 +121,18 @@ export function createNextAuthOptions(options: AuthHandlerOptions) {
|
|
|
114
121
|
token.refreshToken = account.refresh_token;
|
|
115
122
|
token.roles = decoded.realm_access?.roles;
|
|
116
123
|
return token;
|
|
117
|
-
}
|
|
124
|
+
}
|
|
125
|
+
if (Math.floor(Date.now() / 1000) < Number(token.expiresAt)) {
|
|
118
126
|
return token;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
127
|
+
}
|
|
128
|
+
try {
|
|
129
|
+
return refreshAccessToken(options, token as NextToken);
|
|
130
|
+
} catch (err) {
|
|
131
|
+
return { ...token, err };
|
|
125
132
|
}
|
|
126
133
|
},
|
|
127
134
|
async session(params) {
|
|
128
|
-
if (typeof options.nextAuth?.callbacks?.session ===
|
|
135
|
+
if (typeof options.nextAuth?.callbacks?.session === "function") {
|
|
129
136
|
return options.nextAuth.callbacks.session(params);
|
|
130
137
|
}
|
|
131
138
|
const { session: nextSession, token: nextToken } = params;
|
|
@@ -165,20 +172,23 @@ export interface NextToken extends JWT {
|
|
|
165
172
|
roles: string[];
|
|
166
173
|
}
|
|
167
174
|
|
|
168
|
-
async function refreshAccessToken(
|
|
175
|
+
async function refreshAccessToken(
|
|
176
|
+
options: AuthHandlerOptions,
|
|
177
|
+
nextToken: NextToken,
|
|
178
|
+
) {
|
|
169
179
|
const res = await fetch(
|
|
170
180
|
`${options.keycloak?.baseUrl || defaults.keycloak.baseUrl}/realms/${
|
|
171
181
|
options.keycloak?.realm || defaults.keycloak.realm
|
|
172
182
|
}/protocol/openid-connect/token`,
|
|
173
183
|
{
|
|
174
|
-
method:
|
|
184
|
+
method: "POST",
|
|
175
185
|
headers: {
|
|
176
|
-
|
|
186
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
177
187
|
},
|
|
178
188
|
body: new URLSearchParams({
|
|
179
189
|
client_id: options.keycloak.clientId,
|
|
180
190
|
client_secret: options.keycloak.clientSecret,
|
|
181
|
-
grant_type:
|
|
191
|
+
grant_type: "refresh_token",
|
|
182
192
|
refresh_token: nextToken.refreshToken,
|
|
183
193
|
}),
|
|
184
194
|
},
|
package/src/session/index.ts
CHANGED
|
@@ -19,13 +19,15 @@
|
|
|
19
19
|
* limitations under the License.
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
import type {
|
|
23
|
-
import type {
|
|
22
|
+
import type { UseSessionOptions } from "next-auth/react";
|
|
23
|
+
import type { SessionContextValue } from "./session";
|
|
24
24
|
|
|
25
25
|
export async function getSession() {
|
|
26
26
|
return null;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export function useSession<R extends boolean>(
|
|
29
|
+
export function useSession<R extends boolean>(
|
|
30
|
+
_options?: UseSessionOptions<R>,
|
|
31
|
+
): SessionContextValue<R> {
|
|
30
32
|
return {};
|
|
31
33
|
}
|